Index: uspace/lib/cpp/Makefile
===================================================================
--- uspace/lib/cpp/Makefile	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/Makefile	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -53,22 +53,22 @@
 	src/typeindex.cpp \
 	src/typeinfo.cpp \
-	src/internal/runtime.cpp \
-	src/internal/trycatch.cpp \
-	src/internal/unwind.cpp \
-	src/internal/test/adaptors.cpp \
-	src/internal/test/array.cpp \
-	src/internal/test/bitset.cpp \
-	src/internal/test/deque.cpp \
-	src/internal/test/map.cpp \
-	src/internal/test/memory.cpp \
-	src/internal/test/mock.cpp \
-	src/internal/test/numeric.cpp \
-	src/internal/test/set.cpp \
-	src/internal/test/string.cpp \
-	src/internal/test/test.cpp \
-	src/internal/test/tuple.cpp \
-	src/internal/test/unordered_map.cpp \
-	src/internal/test/unordered_set.cpp \
-	src/internal/test/vector.cpp
+	src/__bits/runtime.cpp \
+	src/__bits/trycatch.cpp \
+	src/__bits/unwind.cpp \
+	src/__bits/test/adaptors.cpp \
+	src/__bits/test/array.cpp \
+	src/__bits/test/bitset.cpp \
+	src/__bits/test/deque.cpp \
+	src/__bits/test/map.cpp \
+	src/__bits/test/memory.cpp \
+	src/__bits/test/mock.cpp \
+	src/__bits/test/numeric.cpp \
+	src/__bits/test/set.cpp \
+	src/__bits/test/string.cpp \
+	src/__bits/test/test.cpp \
+	src/__bits/test/tuple.cpp \
+	src/__bits/test/unordered_map.cpp \
+	src/__bits/test/unordered_set.cpp \
+	src/__bits/test/vector.cpp
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/cpp/include/__bits/abi.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/abi.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/abi.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstddef>
+#include <cstdint>
+#include <typeinfo>
+
+namespace __cxxabiv1
+{
+    /**
+     * Static constructor/destructor helpers.
+     */
+
+    extern "C" int __cxa_atexit(void (*)(void*), void*, void*);
+
+    extern "C" void __cxa_finalize(void*);
+
+    /**
+     * Itanium C++ ABI type infos.
+     * See section 2.9.4 (RTTI Layout) of the Itanium C++ ABI spec.
+     *
+     * Note: The memory representation of these classes must not
+     *       be modified! (Wel, no modifications at all shall be done.)
+     *
+     * Source: https://itanium-cxx-abi.github.io/cxx-abi/abi.html
+     */
+
+    class __fundamental_type_info: public std::type_info
+    {
+        public:
+            virtual ~__fundamental_type_info();
+    };
+
+    class __array_type_info: public std::type_info
+    {
+        public:
+            virtual ~__array_type_info();
+    };
+
+    class __function_type_info: public std::type_info
+    {
+        public:
+            virtual ~__function_type_info();
+    };
+
+    class __enum_type_info: public std::type_info
+    {
+        public:
+            virtual ~__enum_type_info();
+    };
+
+    class __class_type_info: public std::type_info
+    {
+        public:
+            virtual ~__class_type_info();
+    };
+
+    class __si_class_type_info: public __class_type_info
+    {
+        public:
+            virtual ~__si_class_type_info();
+
+            const __class_type_info* __base_type;
+    };
+
+    struct __base_class_type_info
+    {
+        const __class_type_info* __base_type;
+        long __offset_flags;
+
+        enum __ofset_flags_masks
+        {
+            __virtual_mask = 0x1,
+            __public_mask =  0x2,
+            __offset_shift = 0x8
+        };
+    };
+
+    class __vmi_class_type_info: public __class_type_info
+    {
+        public:
+            virtual ~__vmi_class_type_info();
+
+            std::uint32_t __flags;
+            std::uint32_t __base_count;
+
+            __base_class_type_info __base_info[1];
+
+            enum __flags_mask
+            {
+                __non_diamond_repeat_mask = 0x1,
+                __diamond_shaped_mask     = 0x2
+            };
+    };
+
+    class __pbase_type_info: public std::type_info
+    {
+        public:
+            virtual ~__pbase_type_info();
+
+            std::uint32_t __flags;
+            const std::type_info* __pointee;
+
+            enum __masks
+            {
+                __const_mask            = 0x01,
+                __volatile_mask         = 0x02,
+                __restrict_mask         = 0x04,
+                __incomplete_mask       = 0x08,
+                __incomplete_class_mask = 0x10,
+                __transaction_safe_mask = 0x20,
+                __noexcept_mask         = 0x40
+            };
+    };
+
+    class __pointer_type_info: public __pbase_type_info
+    {
+        public:
+            virtual ~__pointer_type_info();
+    };
+
+    class __pointer_to_member_type_info: public __pbase_type_info
+    {
+        public:
+            virtual ~__pointer_to_member_type_info();
+
+            const __class_type_info* __context;
+    };
+
+    extern "C" void* __dynamic_cast(const void*, const __class_type_info*,
+                                    const __class_type_info*, std::ptrdiff_t);
+}
+
+namespace abi = __cxxabiv1;
Index: uspace/lib/cpp/include/__bits/aux.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/aux.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/aux.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_AUX
+#define LIBCPP_AUX
+
+namespace std
+{
+    /**
+     * 20.10.3, helper class:
+     */
+
+    template<class T, T v>
+    struct integral_constant
+    {
+        static constexpr T value = v;
+
+        using value_type = T;
+        using type       = integral_constant<T, v>;
+
+        constexpr operator value_type() const noexcept
+        {
+            return value;
+        }
+
+        constexpr value_type operator()() const noexcept
+        {
+            return value;
+        }
+    };
+
+    using true_type = integral_constant<bool, true>;
+    using false_type = integral_constant<bool, false>;
+}
+
+namespace std::aux
+{
+    /**
+     * Two very handy templates, this allows us
+     * to easily follow the T::type and T::value
+     * convention by simply inheriting from specific
+     * instantiations of these templates.
+     * Examples:
+     *  1) We need a struct with int typedef'd to type:
+     *
+     *      stuct has_type_int: aux::type<int> {};
+     *      typename has_type_int::type x = 1; // x is of type int
+     *
+     *  2) We need a struct with static size_t member called value:
+     *
+     *      struct has_value_size_t: aux::value<size_t, 1u> {};
+     *      std::printf("%u\n", has_value_size_t::value); // prints "1\n"
+     */
+
+    template<class T>
+    struct type_is
+    {
+        using type = T;
+    };
+
+    // For compatibility with integral_constant.
+    template<class T, T v>
+    using value_is = std::integral_constant<T, v>;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/builtins.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/builtins.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/builtins.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_BUILTINS
+#define LIBCPP_BITS_BUILTINS
+
+/**
+ * Note: While the primary target of libcpp is the
+ *       g++ compiler, using builtin functions that would
+ *       unnecessarily limit the library to any specific
+ *       compiler is discouraged and as such all the used
+ *       builtins should be available atleast in g++ and
+ *       clang++.
+ * GCC:  https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
+ * LLVM: https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/Builtins.def
+ *       (If anyone has a better link for LLVM, feel free to update it.)
+ */
+
+#include <cstdlib>
+
+namespace std::aux
+{
+    template<class T>
+    constexpr double log2(T val)
+    {
+        return __builtin_log2(static_cast<double>(val));
+    }
+
+    template<class T>
+    constexpr double pow2(T exp)
+    {
+        return __builtin_pow(2.0, static_cast<double>(exp));
+    }
+
+    template<class T>
+    constexpr size_t pow2u(T exp)
+    {
+        return static_cast<size_t>(pow2(exp));
+    }
+
+    template<class T, class U>
+    constexpr T pow(T base, U exp)
+    {
+        return static_cast<T>(
+            __builtin_pow(static_cast<double>(base), static_cast<double>(exp))
+        );
+    }
+
+    template<class T>
+    constexpr size_t ceil(T val)
+    {
+        return static_cast<size_t>(__builtin_ceil(static_cast<double>(val)));
+    }
+
+    template<class T>
+    constexpr size_t floor(T val)
+    {
+        return static_cast<size_t>(__builtin_floor(static_cast<double>(val)));
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/common.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/common.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/common.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,13 @@
+#ifndef LIBCPP_BITS_COMMON
+#define LIBCPP_BITS_COMMON
+
+/**
+ * According to section 17.2 of the standard,
+ * the restrict qualifier shall be omitted.
+ */
+#define restrict
+
+#undef NULL
+#define NULL nullptr
+
+#endif
Index: uspace/lib/cpp/include/__bits/functional/arithmetic_operations.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/functional/arithmetic_operations.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/functional/arithmetic_operations.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,621 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_FUNCTIONAL_ARITHMETIC_OPERATIONS
+#define LIBCPP_BITS_FUNCTIONAL_ARITHMETIC_OPERATIONS
+
+#include <__bits/utility/forward_move.hpp>
+#include <type_traits>
+
+namespace std
+{
+    /**
+     * 20.9.5, arithmetic operations:
+     */
+
+    template<class T = void>
+    struct plus
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs + rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct minus
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs - rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct multiplies
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs * rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct divides
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs / rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct modulus
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs % rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct negate
+    {
+        constexpr T operator()(const T& x) const
+        {
+            return -x;
+        }
+
+        using argument_type = T;
+        using result_type   = T;
+    };
+
+    namespace aux
+    {
+        /**
+         * Used by some functions like std::set::find to determine
+         * whether a functor is transparent.
+         */
+        struct transparent_t;
+
+        template<class T, class = void>
+        struct is_transparent: false_type
+        { /* DUMMY BODY */ };
+
+        template<class T>
+        struct is_transparent<T, void_t<typename T::is_transparent>>
+            : true_type
+        { /* DUMMY BODY */ };
+
+        template<class T>
+        inline constexpr bool is_transparent_v = is_transparent<T>::value;
+    }
+
+    template<>
+    struct plus<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) + forward<U>(rhs))
+        {
+            return forward<T>(lhs) + forward<T>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct minus<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) - forward<U>(rhs))
+        {
+            return forward<T>(lhs) - forward<T>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct multiplies<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) * forward<U>(rhs))
+        {
+            return forward<T>(lhs) * forward<T>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct divides<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) / forward<U>(rhs))
+        {
+            return forward<T>(lhs) / forward<T>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct modulus<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) % forward<U>(rhs))
+        {
+            return forward<T>(lhs) % forward<T>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct negate<void>
+    {
+        template<class T>
+        constexpr auto operator()(T&& x) const
+            -> decltype(-forward<T>(x))
+        {
+            return -forward<T>(x);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    /**
+     * 20.9.6, comparisons:
+     */
+
+    template<class T = void>
+    struct equal_to
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs == rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<class T = void>
+    struct not_equal_to
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs != rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<class T = void>
+    struct greater
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs > rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<class T = void>
+    struct less
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs < rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<class T = void>
+    struct greater_equal
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs >= rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<class T = void>
+    struct less_equal
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs <= rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<>
+    struct equal_to<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) == forward<U>(rhs))
+        {
+            return forward<T>(lhs) == forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct not_equal_to<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) != forward<U>(rhs))
+        {
+            return forward<T>(lhs) != forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct greater<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) > forward<U>(rhs))
+        {
+            return forward<T>(lhs) > forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct less<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) < forward<U>(rhs))
+        {
+            return forward<T>(lhs) < forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct greater_equal<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) >= forward<U>(rhs))
+        {
+            return forward<T>(lhs) >= forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct less_equal<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) <= forward<U>(rhs))
+        {
+            return forward<T>(lhs) <= forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    /**
+     * 20.9.7, logical operations:
+     */
+
+    template<class T = void>
+    struct logical_and
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs && rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<class T = void>
+    struct logical_or
+    {
+        constexpr bool operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs || rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = bool;
+    };
+
+    template<class T = void>
+    struct logical_not
+    {
+        constexpr bool operator()(const T& x) const
+        {
+            return !x;
+        }
+
+        using argument_type = T;
+        using result_type   = bool;
+    };
+
+    template<>
+    struct logical_and<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) && forward<U>(rhs))
+        {
+            return forward<T>(lhs) && forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct logical_or<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) || forward<U>(rhs))
+        {
+            return forward<T>(lhs) || forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct logical_not<void>
+    {
+        template<class T>
+        constexpr auto operator()(T&& x) const
+            -> decltype(!forward<T>(x))
+        {
+            return !forward<T>(x);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    /**
+     * 20.9.8, bitwise operations:
+     */
+
+    template<class T = void>
+    struct bit_and
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs & rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct bit_or
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs | rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct bit_xor
+    {
+        constexpr T operator()(const T& lhs, const T& rhs) const
+        {
+            return lhs ^ rhs;
+        }
+
+        using first_argument_type  = T;
+        using second_argument_type = T;
+        using result_type          = T;
+    };
+
+    template<class T = void>
+    struct bit_not
+    {
+        constexpr bool operator()(const T& x) const
+        {
+            return ~x;
+        }
+
+        using argument_type = T;
+        using result_type   = T;
+    };
+
+    template<>
+    struct bit_and<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) & forward<U>(rhs))
+        {
+            return forward<T>(lhs) & forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct bit_or<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) | forward<U>(rhs))
+        {
+            return forward<T>(lhs) | forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct bit_xor<void>
+    {
+        template<class T, class U>
+        constexpr auto operator()(T&& lhs, U&& rhs) const
+            -> decltype(forward<T>(lhs) ^ forward<U>(rhs))
+        {
+            return forward<T>(lhs) ^ forward<U>(rhs);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    template<>
+    struct bit_not<void>
+    {
+        template<class T>
+        constexpr auto operator()(T&& x) const
+            -> decltype(~forward<T>(x))
+        {
+            return ~forward<T>(x);
+        }
+
+        using is_transparent = aux::transparent_t;
+    };
+
+    /**
+     * 20.9.9, negators:
+     */
+
+    template<class Predicate>
+    class unary_negate
+    {
+        public:
+            using result_type   = bool;
+            using argument_type = typename Predicate::argument_type;
+
+            constexpr explicit unary_negate(const Predicate& pred)
+                : pred_{pred}
+            { /* DUMMY BODY */ }
+
+            constexpr result_type operator()(const argument_type& arg)
+            {
+                return !pred_(arg);
+            }
+
+        private:
+            Predicate pred_;
+    };
+
+    template<class Predicate>
+    constexpr unary_negate<Predicate> not1(const Predicate& pred)
+    {
+        return unary_negate<Predicate>{pred};
+    }
+
+    template<class Predicate>
+    class binary_negate
+    {
+        public:
+            using result_type          = bool;
+            using first_argument_type  = typename Predicate::first_argument_type;
+            using second_argument_type = typename Predicate::second_argument_type;
+
+            constexpr explicit binary_negate(const Predicate& pred)
+                : pred_{pred}
+            { /* DUMMY BODY */ }
+
+            constexpr result_type operator()(const first_argument_type& arg1,
+                                             const second_argument_type& arg2)
+            {
+                return !pred_(arg1, arg2);
+            }
+
+        private:
+            Predicate pred_;
+    };
+
+    template<class Predicate>
+    constexpr binary_negate<Predicate> not2(const Predicate& pred);
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/functional/bind.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/functional/bind.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/functional/bind.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_FUNCTIONAL_BIND
+#define LIBCPP_BITS_FUNCTIONAL_BIND
+
+#include <__bits/functional/function.hpp>
+#include <__bits/functional/invoke.hpp>
+#include <__bits/functional/reference_wrapper.hpp>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+namespace std
+{
+    /**
+     * 20.9.10, bind:
+     */
+
+    namespace aux
+    {
+        template<int N>
+        struct placeholder_t
+        {
+            constexpr placeholder_t() = default;
+            constexpr placeholder_t(const placeholder_t&) = default;
+            constexpr placeholder_t(placeholder_t&&) = default;
+        };
+    }
+
+    template<class T>
+    struct is_placeholder: integral_constant<int, 0>
+    { /* DUMMY BODY */ };
+
+    template<int N> // Note: const because they are all constexpr.
+    struct is_placeholder<const aux::placeholder_t<N>>
+        : integral_constant<int, N>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    inline constexpr int is_placeholder_v = is_placeholder<T>::value;
+
+    namespace aux
+    {
+        /**
+         * Note: Our internal bind return type has an extra type
+         *       template parameter and an extra bool template parameter.
+         *       We use this for the special version of bind that has
+         *       the return type to have a result_type typedef
+         *       (i.e. when the bool is true, the extra type parameter
+         *       is typedefed as result_type - see the structure below).
+         *       This is just a simplification of the implementation
+         *       so that we don't need to have two return types for
+         *       the two bind functions, because unlike function or
+         *       mem_fn, we know exactly when to make the typedef.
+         */
+
+        template<class, bool = false>
+        struct bind_conditional_result_type
+        { /* DUMMY BODY */ };
+
+        template<class R>
+        struct bind_conditional_result_type<R, true>
+        {
+            using result_type = R;
+        };
+
+        template<class, bool, class, class...>
+        class bind_t;
+
+        /**
+         * Filter class that uses its overloaded operator[]
+         * to filter our placeholders, reference_wrappers and bind
+         * subexpressions and replace them with the correct
+         * arguments (extracts references, calls the subexpressions etc).
+         */
+        template<class... Args>
+        class bind_arg_filter
+        {
+            public:
+                bind_arg_filter(Args&&... args)
+                    : args_{forward<Args>(args)...}
+                { /* DUMMY BODY */ }
+
+                template<class T>
+                constexpr decltype(auto) operator[](T&& t)
+                {
+                    return forward<T>(t);
+                }
+
+                template<int N>
+                constexpr decltype(auto) operator[](const placeholder_t<N>)
+                { // Since placeholders are constexpr, this is the best match for them.
+                    /**
+                     * Come on, it's int! Why not use -1 as not placeholder
+                     * and start them at 0? -.-
+                     */
+                    return get<N - 1>(args_);
+                }
+
+                template<class T>
+                constexpr T& operator[](reference_wrapper<T> ref)
+                {
+                    return ref.get();
+                }
+
+                template<class R, bool B, class F, class... BindArgs>
+                constexpr decltype(auto) operator[](const bind_t<R, B, F, BindArgs...> b)
+                {
+                    return b; // TODO: bind subexpressions
+                }
+
+
+            private:
+                tuple<Args...> args_;
+        };
+
+        template<class R, bool HasResultType, class F, class... Args>
+        class bind_t: public bind_conditional_result_type<R, HasResultType>
+        {
+            public:
+                template<class G, class... BoundArgs>
+                constexpr bind_t(G&& g, BoundArgs&&... args)
+                    : func_{forward<F>(g)},
+                      bound_args_{forward<Args>(args)...}
+                { /* DUMMY BODY */ }
+
+                constexpr bind_t(const bind_t& other) = default;
+                constexpr bind_t(bind_t&& other) = default;
+
+                template<class... ActualArgs>
+                constexpr decltype(auto) operator()(ActualArgs&&... args)
+                {
+                    return invoke_(
+                        make_index_sequence<sizeof...(Args)>{},
+                        forward<ActualArgs>(args)...
+                    );
+                }
+
+            private:
+                function<decay_t<F>> func_;
+                tuple<decay_t<Args>...> bound_args_;
+
+                template<size_t... Is, class... ActualArgs>
+                constexpr decltype(auto) invoke_(
+                    index_sequence<Is...>, ActualArgs&&... args
+                )
+                {
+                    /**
+                     * The expression filter[bound_args_[bind_arg_index<Is>()]]...
+                     * here expands bind_arg_index to 0, 1, ... sizeof...(ActualArgs) - 1
+                     * and then passes this variadic list of indices to the bound_args_
+                     * tuple which extracts the bound args from it.
+                     * Our filter will then have its operator[] called on each of them
+                     * and filter out the placeholders, reference_wrappers etc and changes
+                     * them to the actual arguments.
+                     */
+                    bind_arg_filter<ActualArgs...> filter{forward<ActualArgs>(args)...};
+
+                    return aux::invoke(
+                        func_,
+                        filter[get<Is>(bound_args_)]...
+                    );
+                }
+        };
+    }
+
+    template<class T>
+    struct is_bind_expression: false_type
+    { /* DUMMY BODY */ };
+
+    template<class R, bool B, class F, class... Args>
+    struct is_bind_expression<aux::bind_t<R, B, F, Args...>>
+        : true_type
+    { /* DUMMY BODY */ };
+
+    template<class F, class... Args>
+    aux::bind_t<void, false, F, Args...> bind(F&& f, Args&&... args)
+    {
+        return aux::bind_t<void, false, F, Args...>{forward<F>(f), forward<Args>(args)...};
+    }
+
+    template<class R, class F, class... Args>
+    aux::bind_t<R, true, F, Args...> bind(F&& f, Args&&... args)
+    {
+        return aux::bind_t<R, true, F, Args...>{forward<F>(f), forward<Args>(args)...};
+    }
+
+    namespace placeholders
+    {
+        /**
+         * Note: The number of placeholders is
+         *       implementation defined, we've chosen
+         *       8 because it is a nice number
+         *       and should be enough for any function
+         *       call.
+         * Note: According to the C++14 standard, these
+         *       are all extern non-const. We decided to use
+         *       the C++17 form of them being inline constexpr
+         *       because it is more convenient, makes sense
+         *       and would eventually need to be upgraded
+         *       anyway.
+         */
+        inline constexpr aux::placeholder_t<1> _1;
+        inline constexpr aux::placeholder_t<2> _2;
+        inline constexpr aux::placeholder_t<3> _3;
+        inline constexpr aux::placeholder_t<4> _4;
+        inline constexpr aux::placeholder_t<5> _5;
+        inline constexpr aux::placeholder_t<6> _6;
+        inline constexpr aux::placeholder_t<7> _7;
+        inline constexpr aux::placeholder_t<8> _8;
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/functional/conditional_function_typedefs.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/functional/conditional_function_typedefs.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/functional/conditional_function_typedefs.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_FUNCTION_CONDITIONAL_FUNCTION_TYPEDEFS
+#define LIBCPP_BITS_FUNCTION_CONDITIONAL_FUNCTION_TYPEDEFS
+
+namespace std::aux
+{
+    /**
+     * Note: Some types with possible function-like behavior
+     *       (e.g. function, reference_wrapper, aux::mem_fn_t)
+     *       have to define a type argument type or two types
+     *       first_argument_type and second_argument_type when
+     *       their invocation takes one or two arguments, respectively.
+     *
+     *       The easiest way to conditionally define a type is using
+     *       inheritance and the types below serve exactly for that
+     *       purpose.
+     *
+     *       If we have a type that is specialized as R(Args...)
+     *       for some return type R and argument types Args...,
+     *       we can simply (publicly) inherit from
+     *       conditional_function_typedefs<Args...>. If it is
+     *       templated by some generic type T, we can inherit from
+     *       conditional_function_typedefs<remove_cv_t<remove_reference_t<T>>>
+     *       so that the correct type below gets chosen.
+     */
+
+    template<class... Args>
+    struct conditional_function_typedefs
+    { /* DUMMY BODY */ };
+
+    template<class A>
+    struct conditional_function_typedefs<A>
+    {
+        using argument_type = A;
+    };
+
+    template<class A1, class A2>
+    struct conditional_function_typedefs<A1, A2>
+    {
+        using first_argument_type  = A1;
+        using second_argument_type = A2;
+    };
+
+    template<class R, class... Args>
+    struct conditional_function_typedefs<R(Args...)>
+        : conditional_function_typedefs<Args...>
+    { /* DUMMY BODY */ };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/functional/function.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/functional/function.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/functional/function.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,377 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_FUNCTIONAL_FUNCTION
+#define LIBCPP_BITS_FUNCTIONAL_FUNCTION
+
+#include <__bits/functional/conditional_function_typedefs.hpp>
+#include <__bits/functional/reference_wrapper.hpp>
+#include <typeinfo>
+#include <type_traits>
+
+namespace std
+{
+    /**
+     * 20.9.12, polymorphic function adaptors:
+     */
+
+    namespace aux
+    {
+        // TODO: fix this
+        /* template<class, class T, class... Args> */
+        /* struct is_callable_impl: false_type */
+        /* { /1* DUMMY BODY *1/ }; */
+
+        /* template<class, class R, class... Args> */
+        /* struct is_callable_impl< */
+        /*     void_t<decltype(aux::invoke(declval<R(Args...)>(), declval<Args>()..., R))>, */
+        /*     R, Args... */
+        /* > : true_type */
+        /* { /1* DUMMY BODY *1/ }; */
+
+        /* template<class T> */
+        /* struct is_callable: is_callable_impl<void_t<>, T> */
+        /* { /1* DUMMY BODY *1/ }; */
+
+        template<class Callable, class R, class... Args>
+        R invoke_callable(Callable* clbl, Args&&... args)
+        {
+            return (*clbl)(forward<Args>(args)...);
+        }
+
+        template<class Callable>
+        void copy_callable(Callable* to, Callable* from)
+        {
+            new(to) Callable{*from};
+        }
+
+        template<class Callable>
+        void destroy_callable(Callable* clbl)
+        {
+            if (clbl)
+                clbl->~Callable();
+        }
+    }
+
+    // TODO: implement
+    class bad_function_call;
+
+    template<class>
+    class function; // undefined
+
+    /**
+     * Note: Ideally, this implementation wouldn't
+     *       copy the target if it was a pointer to
+     *       a function, but for the simplicity of the
+     *       implementation, we do copy even in that
+     *       case for now. It would be a nice optimization
+     *       if this was changed in the future.
+     */
+    template<class R, class... Args>
+    class function<R(Args...)>
+        : public aux::conditional_function_typedefs<Args...>
+    {
+        public:
+            using result_type = R;
+
+            /**
+             * 20.9.12.2.1, construct/copy/destroy:
+             */
+
+            function() noexcept
+                : callable_{}, callable_size_{}, call_{},
+                  copy_{}, dest_{}
+            { /* DUMMY BODY */ }
+
+            function(nullptr_t) noexcept
+                : function{}
+            { /* DUMMY BODY */ }
+
+            function(const function& other)
+                : callable_{}, callable_size_{other.callable_size_},
+                  call_{other.call_}, copy_{other.copy_}, dest_{other.dest_}
+            {
+                callable_ = new uint8_t[callable_size_];
+                (*copy_)(callable_, other.callable_);
+            }
+
+            function(function&& other)
+                : callable_{other.callable_}, callable_size_{other.callable_size_},
+                  call_{other.call_}, copy_{other.copy_}, dest_{other.dest_}
+            {
+                other.callable_ = nullptr;
+                other.callable_size_ = size_t{};
+                other.call_ = nullptr;
+                other.copy_ = nullptr;
+                other.dest_ = nullptr;
+            }
+
+            // TODO: shall not participate in overloading unless aux::is_callable<F>
+            template<class F>
+            function(F f)
+                : callable_{}, callable_size_{sizeof(F)},
+                  call_{(call_t)aux::invoke_callable<F, R, Args...>},
+                  copy_{(copy_t)aux::copy_callable<F>},
+                  dest_{(dest_t)aux::destroy_callable<F>}
+            {
+                callable_ = new uint8_t[callable_size_];
+                (*copy_)(callable_, (uint8_t*)&f);
+            }
+
+            /**
+             * Note: For the moment we're ignoring the allocator
+             *       for simplicity of the implementation.
+             */
+
+            template<class A>
+            function(allocator_arg_t, const A& a) noexcept
+                : function{}
+            { /* DUMMY BODY */ }
+
+            template<class A>
+            function(allocator_arg_t, const A& a, nullptr_t) noexcept
+                : function{}
+            { /* DUMMY BODY */ }
+
+            template<class A>
+            function(allocator_arg_t, const A& a, const function& other)
+                : function{other}
+            { /* DUMMY BODY */ }
+
+            template<class A>
+            function(allocator_arg_t, const A& a, function&& other)
+                : function{move(other)}
+            { /* DUMMY BODY */ }
+
+            // TODO: shall not participate in overloading unless aux::is_callable<F>
+            template<class F, class A>
+            function(allocator_arg_t, const A& a, F f)
+                : function{f}
+            { /* DUMMY BODY */ }
+
+            function& operator=(const function& rhs)
+            {
+                function{rhs}.swap(*this);
+
+                return *this;
+            }
+
+            /**
+             * Note: We have to copy call_, copy_
+             *       and dest_ because they can be templated
+             *       by a type F we don't know.
+             */
+            function& operator=(function&& rhs)
+            {
+                clear_();
+
+                callable_ = rhs.callable_;
+                callable_size_ = rhs.callable_size_;
+                call_ = rhs.call_;
+                copy_ = rhs.copy_;
+                dest_ = rhs.dest_;
+
+                rhs.callable_ = nullptr;
+                rhs.callable_size_ = size_t{};
+                rhs.call_ = nullptr;
+                rhs.copy_ = nullptr;
+                rhs.dest_ = nullptr;
+
+                return *this;
+            }
+
+            function& operator=(nullptr_t) noexcept
+            {
+                clear_();
+
+                return *this;
+            }
+
+            // TODO: shall not participate in overloading unless aux::is_callable<F>
+            template<class F>
+            function& operator=(F&& f)
+            {
+                callable_size_ = sizeof(F);
+                callable_ = new uint8_t[callable_size_];
+                call_ = aux::invoke_callable<F, R, Args...>;
+                copy_ = aux::copy_callable<F>;
+                dest_ = aux::destroy_callable<F>;
+
+                (*copy_)(callable_, (uint8_t*)&f);
+            }
+
+            template<class F>
+            function& operator=(reference_wrapper<F> ref) noexcept
+            {
+                return (*this) = ref.get();
+            }
+
+            ~function()
+            {
+                if (callable_)
+                {
+                    (*dest_)(callable_);
+                    delete[] callable_;
+                }
+            }
+
+            /**
+             * 20.9.12.2.2, function modifiers:
+             */
+
+            void swap(function& other) noexcept
+            {
+                std::swap(callable_, other.callable_);
+                std::swap(callable_size_, other.callable_size_);
+                std::swap(call_, other.call_);
+                std::swap(copy_, other.copy_);
+                std::swap(dest_, other.dest_);
+            }
+
+            template<class F, class A>
+            void assign(F&& f, const A& a)
+            {
+                function{allocator_arg, a, forward<F>(f)}.swap(*this);
+            }
+
+            /**
+             * 20.9.12.2.3, function capacity:
+             */
+
+            explicit operator bool() const noexcept
+            {
+                return callable_ != nullptr;
+            }
+
+            /**
+             * 20.9.12.2.4, function invocation:
+             */
+
+            result_type operator()(Args... args) const
+            {
+                // TODO: throw bad_function_call if !callable_ || !call_
+                if constexpr (is_same_v<R, void>)
+                    (*call_)(callable_, forward<Args>(args)...);
+                else
+                    return (*call_)(callable_, forward<Args>(args)...);
+            }
+
+            /**
+             * 20.9.12.2.5, function target access:
+             */
+
+            const type_info& target_type() const noexcept
+            {
+                return typeid(*callable_);
+            }
+
+            template<class T>
+            T* target() noexcept
+            {
+                if (target_type() == typeid(T))
+                    return (T*)callable_;
+                else
+                    return nullptr;
+            }
+
+            template<class T>
+            const T* target() const noexcept
+            {
+                if (target_type() == typeid(T))
+                    return (T*)callable_;
+                else
+                    return nullptr;
+            }
+
+        private:
+            using call_t = R(*)(uint8_t*, Args&&...);
+            using copy_t = void (*)(uint8_t*, uint8_t*);
+            using dest_t = void (*)(uint8_t*);
+
+            uint8_t* callable_;
+            size_t callable_size_;
+            call_t call_;
+            copy_t copy_;
+            dest_t dest_;
+
+            void clear_()
+            {
+                if (callable_)
+                {
+                    (*dest_)(callable_);
+                    delete[] callable_;
+                    callable_ = nullptr;
+                }
+            }
+    };
+
+    /**
+     * 20.9.12.2.6, null pointer comparisons:
+     */
+
+    template<class R, class... Args>
+    bool operator==(const function<R(Args...)>& f, nullptr_t) noexcept
+    {
+        return !f;
+    }
+
+    template<class R, class... Args>
+    bool operator==(nullptr_t, const function<R(Args...)>& f) noexcept
+    {
+        return !f;
+    }
+
+    template<class R, class... Args>
+    bool operator!=(const function<R(Args...)>& f, nullptr_t) noexcept
+    {
+        return (bool)f;
+    }
+
+    template<class R, class... Args>
+    bool operator!=(nullptr_t, const function<R(Args...)>& f) noexcept
+    {
+        return (bool)f;
+    }
+
+    /**
+     * 20.9.12.2.7, specialized algorithms:
+     */
+
+    template<class R, class... Args>
+    void swap(function<R(Args...)>& f1, function<R(Args...)>& f2)
+    {
+        f1.swap(f2);
+    }
+
+    template<class R, class... Args, class Alloc>
+    struct uses_allocator<function<R(Args...)>, Alloc>
+        : true_type
+    { /* DUMMY BODY */ };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/functional/hash.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/functional/hash.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/functional/hash.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_FUNCTIONAL_HASH
+#define LIBCPP_BITS_FUNCTIONAL_HASH
+
+#include <cstdlib>
+#include <cstdint>
+
+namespace std
+{
+    template<class>
+    struct is_arithmetic;
+
+    template<class>
+    struct is_pointer;
+
+    /**
+     * 20.9.13, hash function primary template:
+     */
+
+    namespace aux
+    {
+        template<class T>
+        union converter
+        {
+            T value;
+            uint64_t converted;
+        };
+
+        template<class T>
+        T hash_(uint64_t x) noexcept
+        {
+            /**
+             * Note: std::hash is used for indexing in
+             *       unordered containers, not for cryptography.
+             *       Because of this, we decided to simply convert
+             *       the value to uin64_t, which will help us
+             *       with testing (since in order to create
+             *       a collision in a multiset or multimap
+             *       we simply need 2 values that congruent
+             *       by the size of the table.
+             */
+            return static_cast<T>(x);
+        }
+
+        template<class T>
+        size_t hash(T x) noexcept
+        {
+            static_assert(is_arithmetic<T>::value || is_pointer<T>::value,
+                          "invalid type passed to aux::hash");
+
+            converter<T> conv;
+            conv.value = x;
+
+            return hash_<size_t>(conv.converted);
+        }
+    }
+
+    template<class T>
+    struct hash
+    { /* DUMMY BODY */ };
+
+    template<>
+    struct hash<bool>
+    {
+        size_t operator()(bool x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = bool;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<char>
+    {
+        size_t operator()(char x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = char;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<signed char>
+    {
+        size_t operator()(signed char x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = signed char;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<unsigned char>
+    {
+        size_t operator()(unsigned char x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = unsigned char;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<char16_t>
+    {
+        size_t operator()(char16_t x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = char16_t;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<char32_t>
+    {
+        size_t operator()(char32_t x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = char32_t;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<wchar_t>
+    {
+        size_t operator()(wchar_t x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = wchar_t;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<short>
+    {
+        size_t operator()(short x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = short;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<unsigned short>
+    {
+        size_t operator()(unsigned short x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = unsigned short;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<int>
+    {
+        size_t operator()(int x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = int;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<unsigned int>
+    {
+        size_t operator()(unsigned int x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = unsigned int;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<long>
+    {
+        size_t operator()(long x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = long;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<long long>
+    {
+        size_t operator()(long long x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = long long;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<unsigned long>
+    {
+        size_t operator()(unsigned long x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = unsigned long;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<unsigned long long>
+    {
+        size_t operator()(unsigned long long x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = unsigned long long;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<float>
+    {
+        size_t operator()(float x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = float;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<double>
+    {
+        size_t operator()(double x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = double;
+        using result_type   = size_t;
+    };
+
+    template<>
+    struct hash<long double>
+    {
+        size_t operator()(long double x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = long double;
+        using result_type   = size_t;
+    };
+
+    template<class T>
+    struct hash<T*>
+    {
+        size_t operator()(T* x) const noexcept
+        {
+            return aux::hash(x);
+        }
+
+        using argument_type = T*;
+        using result_type   = size_t;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/functional/invoke.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/functional/invoke.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/functional/invoke.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_FUNCTIONAL_INVOKE
+#define LIBCPP_BITS_FUNCTIONAL_INVOKE
+
+#include <__bits/utility/declval.hpp>
+#include <__bits/utility/forward_move.hpp>
+
+namespace std
+{
+    template<class>
+    struct is_member_function_pointer;
+
+    template<class, class>
+    struct is_base_of;
+
+    template<class>
+    struct is_member_object_pointer;
+}
+
+namespace std::aux
+{
+    /**
+     * 20.9.2, requirements:
+     */
+
+    template<class R, class T, class T1, class... Ts>
+    decltype(auto) invoke(R T::* f, T1&& t1, Ts&&... args)
+    {
+        if constexpr (is_member_function_pointer<decltype(f)>::value)
+        {
+            if constexpr (is_base_of<T, remove_reference_t<T1>>::value)
+                // (1.1)
+                return (t1.*f)(forward<Ts>(args)...);
+            else
+                // (1.2)
+                return ((*t1).*f)(forward<Ts>(args)...);
+        }
+        else if constexpr (is_member_object_pointer<decltype(f)>::value && sizeof...(args) == 0)
+        {
+            /**
+             * Note: Standard requires to N be equal to 1, but we take t1 directly
+             *       so we need sizeof...(args) to be 0.
+             */
+            if constexpr (is_base_of<T, remove_reference_t<T1>>::value)
+                // (1.3)
+                return t1.*f;
+            else
+                // (1.4)
+                return (*t1).*f;
+        }
+        else
+
+        /**
+         * Note: If this condition holds this will not be reachable,
+         *       but a new addition to the standard (17.7 point (8.1))
+         *       prohibits us from simply using false as the condition here,
+         *       so we use this because we know it is false here.
+         */
+        static_assert(is_member_function_pointer<decltype(f)>::value, "invalid invoke");
+    }
+
+    template<class F, class... Args>
+    decltype(auto) invoke(F&& f, Args&&... args)
+    {
+        // (1.5)
+        return f(forward<Args>(args)...);
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/functional/reference_wrapper.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/functional/reference_wrapper.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/functional/reference_wrapper.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_FUNCTIONAL_REFERENCE_WRAPPER
+#define LIBCPP_BITS_FUNCTIONAL_REFERENCE_WRAPPER
+
+#include <__bits/functional/conditional_function_typedefs.hpp>
+#include <__bits/functional/invoke.hpp>
+#include <type_traits>
+
+namespace std
+{
+    /**
+     * 20.9.4, reference_wrapper:
+     */
+
+    template<class T>
+    class reference_wrapper
+        : public aux::conditional_function_typedefs<remove_cv_t<remove_reference_t<T>>>
+    {
+        public:
+            using type = T;
+
+            reference_wrapper(type& val) noexcept
+                : data_{&val}
+            { /* DUMMY BODY */ }
+
+            reference_wrapper(type&&) = delete;
+
+            reference_wrapper(const reference_wrapper& other) noexcept
+                : data_{other.data_}
+            { /* DUMMY BODY */ }
+
+            reference_wrapper& operator=(const reference_wrapper& other) noexcept
+            {
+                data_ = other.data_;
+
+                return *this;
+            }
+
+            operator type&() const noexcept
+            {
+                return *data_;
+            }
+
+            type& get() const noexcept
+            {
+                return *data_;
+            }
+
+            template<class... Args>
+            result_of_t<type&(Args&&...)> operator()(Args&&... args) const
+            {
+                return invoke(*data_, std::forward<Args>(args)...);
+            }
+
+        private:
+            type* data_;
+    };
+
+    template<class T>
+    reference_wrapper<T> ref(T& t) noexcept
+    {
+        return reference_wrapper<T>{t};
+    }
+
+    template<class T>
+    reference_wrapper<const T> cref(const T& t) noexcept
+    {
+        return reference_wrapper<const T>{t};
+    }
+
+    template<class T>
+    void ref(const T&&) = delete;
+
+    template<class T>
+    void cref(const T&&) = delete;
+
+    template<class T>
+    reference_wrapper<T> ref(reference_wrapper<T> t) noexcept
+    {
+        return ref(t.get());
+    }
+
+    template<class T>
+    reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept
+    {
+        return cref(t.get());
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/hash_table.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/hash_table.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/hash_table.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,595 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_HASH_TABLE
+#define LIBCPP_BITS_HASH_TABLE
+
+#include <cstdlib>
+#include <__bits/list.hpp>
+#include <__bits/key_extractors.hpp>
+#include <__bits/hash_table_iterators.hpp>
+#include <__bits/hash_table_policies.hpp>
+#include <iterator>
+#include <limits>
+#include <memory>
+#include <tuple>
+#include <utility>
+
+namespace std::aux
+{
+    /**
+     * To save code, we're going to implement one hash table
+     * for both unordered_map and unordered_set. To do this,
+     * we create one inner hash table that is oblivious to its
+     * held type (and uses a key extractor to get the key from it)
+     * and two proxies that either use plain Key type or a pair
+     * of a key and a value.
+     * Additionally, we will use policies to represent both single
+     * and multi variants of these containers at once.
+     * Note: I am aware the naming is very unimaginative here,
+     *       not my strong side :)
+     */
+
+    template<
+        class Value, class Key, class KeyExtractor,
+        class Hasher, class KeyEq,
+        class Alloc, class Size,
+        class Iterator, class ConstIterator,
+        class LocalIterator, class ConstLocalIterator,
+        class Policy
+    >
+    class hash_table
+    {
+        public:
+            using value_type     = Value;
+            using key_type       = Key;
+            using size_type      = Size;
+            using allocator_type = Alloc;
+            using key_equal      = KeyEq;
+            using hasher         = Hasher;
+            using key_extract    = KeyExtractor;
+
+            using iterator             = Iterator;
+            using const_iterator       = ConstIterator;
+            using local_iterator       = LocalIterator;
+            using const_local_iterator = ConstLocalIterator;
+
+            using node_type = list_node<value_type>;
+
+            using place_type = tuple<
+                hash_table_bucket<value_type, size_type>*,
+                list_node<value_type>*, size_type
+            >;
+
+            hash_table(size_type buckets, float max_load_factor = 1.f)
+                : table_{new hash_table_bucket<value_type, size_type>[buckets]()},
+                  bucket_count_{buckets}, size_{}, hasher_{}, key_eq_{},
+                  key_extractor_{}, max_load_factor_{max_load_factor}
+            { /* DUMMY BODY */ }
+
+            hash_table(size_type buckets, const hasher& hf, const key_equal& eql,
+                       float max_load_factor = 1.f)
+                : table_{new hash_table_bucket<value_type, size_type>[buckets]()},
+                  bucket_count_{buckets}, size_{}, hasher_{hf}, key_eq_{eql},
+                  key_extractor_{}, max_load_factor_{max_load_factor}
+            { /* DUMMY BODY */ }
+
+            hash_table(const hash_table& other)
+                : hash_table{other.bucket_count_, other.hasher_, other.key_eq_,
+                             other.max_load_factor_}
+            {
+                for (const auto& x: other)
+                    insert(x);
+            }
+
+            hash_table(hash_table&& other)
+                : table_{other.table_}, bucket_count_{other.bucket_count_},
+                  size_{other.size_}, hasher_{move(other.hasher_)},
+                  key_eq_{move(other.key_eq_)}, key_extractor_{move(other.key_extractor_)},
+                  max_load_factor_{other.max_load_factor_}
+            {
+                other.table_ = nullptr;
+                other.bucket_count_ = size_type{};
+                other.size_ = size_type{};
+                other.max_load_factor_ = 1.f;
+            }
+
+            hash_table& operator=(const hash_table& other)
+            {
+                hash_table tmp{other};
+                tmp.swap(*this);
+
+                return *this;
+            }
+
+            hash_table& operator=(hash_table&& other)
+            {
+                hash_table tmp{move(other)};
+                tmp.swap(*this);
+
+                return *this;
+            }
+
+            bool empty() const noexcept
+            {
+                return size_ == 0;
+            }
+
+            size_type size() const noexcept
+            {
+                return size_;
+            }
+
+            size_type max_size(allocator_type& alloc)
+            {
+                return allocator_traits<allocator_type>::max_size(alloc);
+            }
+
+            iterator begin() noexcept
+            {
+                auto idx = first_filled_bucket_();
+                return iterator{
+                    table_, idx, bucket_count_,
+                    table_[idx].head
+                };
+            }
+
+            const_iterator begin() const noexcept
+            {
+                return cbegin();
+            }
+
+            iterator end() noexcept
+            {
+                return iterator{};
+            }
+
+            const_iterator end() const noexcept
+            {
+                return cend();
+            }
+
+            const_iterator cbegin() const noexcept
+            {
+                auto idx = first_filled_bucket_();
+                return const_iterator{
+                    table_, idx, bucket_count_,
+                    table_[idx].head
+                };
+            }
+
+            const_iterator cend() const noexcept
+            {
+                return const_iterator{};
+            }
+
+            template<class... Args>
+            auto emplace(Args&&... args)
+            {
+                return Policy::emplace(*this, forward<Args>(args)...);
+            }
+
+            auto insert(const value_type& val)
+            {
+                return Policy::insert(*this, val);
+            }
+
+            auto insert(value_type&& val)
+            {
+                return Policy::insert(*this, forward<value_type>(val));
+            }
+
+            size_type erase(const key_type& key)
+            {
+                return Policy::erase(*this, key);
+            }
+
+            iterator erase(const_iterator it)
+            {
+                auto node = it.node();
+                auto idx = it.idx();
+
+                /**
+                 * Note: This way we will continue on the next bucket
+                 *       if this is the last element in its bucket.
+                 */
+                iterator res{table_, idx, size_, node};
+                ++res;
+
+                if (table_[idx].head == node)
+                {
+                    if (node->next != node)
+                        table_[idx].head = node->next;
+                    else
+                        table_[idx].head = nullptr;
+                }
+                --size_;
+
+                node->unlink();
+                delete node;
+
+                return res;
+            }
+
+            void clear() noexcept
+            {
+                for (size_type i = 0; i < bucket_count_; ++i)
+                    table_[i].clear();
+                size_ = size_type{};
+            }
+
+            void swap(hash_table& other)
+                noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
+                         noexcept(swap(declval<Hasher&>(), declval<Hasher&>())) &&
+                         noexcept(swap(declval<KeyEq&>(), declval<KeyEq&>())))
+            {
+                std::swap(table_, other.table_);
+                std::swap(bucket_count_, other.bucket_count_);
+                std::swap(size_, other.size_);
+                std::swap(hasher_, other.hasher_);
+                std::swap(key_eq_, other.key_eq_);
+                std::swap(max_load_factor_, other.max_load_factor_);
+            }
+
+            hasher hash_function() const
+            {
+                return hasher_;
+            }
+
+            key_equal key_eq() const
+            {
+                return key_eq_;
+            }
+
+            iterator find(const key_type& key)
+            {
+                auto idx = get_bucket_idx_(key);
+                auto head = table_[idx].head;
+
+                if (!head)
+                    return end();
+
+                auto current = head;
+                do
+                {
+                    if (key_eq_(key, key_extractor_(current->value)))
+                        return iterator{table_, idx, size_, current};
+                    current = current->next;
+                }
+                while (current != head);
+
+                return end();
+            }
+
+            const_iterator find(const key_type& key) const
+            {
+                auto idx = get_bucket_idx_(key);
+                auto head = table_[idx].head;
+
+                if (!head)
+                    return end();
+
+                auto current = head;
+                do
+                {
+                    if (key_eq_(key, key_extractor_(current->value)))
+                        return iterator{table_, idx, size_, current};
+                    current = current->next;
+                }
+                while (current != head);
+
+                return end();
+            }
+
+            size_type count(const key_type& key) const
+            {
+                return Policy::count(*this, key);
+            }
+
+            pair<iterator, iterator> equal_range(const key_type& key)
+            {
+                return Policy::equal_range(*this, key);
+            }
+
+            pair<const_iterator, const_iterator> equal_range(const key_type& key) const
+            {
+                return Policy::equal_range_const(*this, key);
+            }
+
+            size_type bucket_count() const noexcept
+            {
+                return bucket_count_;
+            }
+
+            size_type max_bucket_count() const noexcept
+            {
+                return numeric_limits<size_type>::max() /
+                       sizeof(hash_table_bucket<value_type, size_type>);
+            }
+
+            size_type bucket_size(size_type n) const
+            {
+                return table_[n].size();
+            }
+
+            size_type bucket(const key_type& key) const
+            {
+                return get_bucket_idx_(key);
+            }
+
+            local_iterator begin(size_type n)
+            {
+                return local_iterator{table_[n].head, table_[n].head};
+            }
+
+            const_local_iterator begin(size_type n) const
+            {
+                return cbegin(n);
+            }
+
+            local_iterator end(size_type n)
+            {
+                return local_iterator{};
+            }
+
+            const_local_iterator end(size_type n) const
+            {
+                return cend(n);
+            }
+
+            const_local_iterator cbegin(size_type n) const
+            {
+                return const_local_iterator{table_[n].head, table_[n].head};
+            }
+
+            const_local_iterator cend(size_type n) const
+            {
+                return const_local_iterator{};
+            }
+
+            float load_factor() const noexcept
+            {
+                return size_ / static_cast<float>(bucket_count_);
+            }
+
+            float max_load_factor() const noexcept
+            {
+                return max_load_factor_;
+            }
+
+            void max_load_factor(float factor)
+            {
+                if (factor > 0.f)
+                    max_load_factor_ = factor;
+
+                rehash_if_needed();
+            }
+
+            void rehash(size_type count)
+            {
+                if (count < size_ / max_load_factor_)
+                    count = size_ / max_load_factor_;
+
+                /**
+                 * Note: If an exception is thrown, there
+                 *       is no effect. Since this is the only
+                 *       place where an exception (no mem) can
+                 *       be thrown and no changes to this have been
+                 *       made, we're ok.
+                 */
+                hash_table new_table{count, max_load_factor_};
+
+                for (std::size_t i = 0; i < bucket_count_; ++i)
+                {
+                    auto head = table_[i].head;
+                    if (!head)
+                        continue;
+
+                    auto current = head;
+
+                    do
+                    {
+                        auto next = current->next;
+
+                        current->next = current;
+                        current->prev = current;
+
+                        auto where = Policy::find_insertion_spot(
+                            new_table, key_extractor_(current->value)
+                        );
+
+                        /**
+                         * Note: We're rehashing, so we know each
+                         *       key can be inserted.
+                         */
+                        auto new_bucket = get<0>(where);
+                        auto new_successor = get<1>(where);
+
+                        if (new_successor)
+                            new_successor->append(current);
+                        else
+                            new_bucket->append(current);
+
+                        current = next;
+                    } while (current != head);
+
+                    table_[i].head = nullptr;
+                }
+
+                new_table.size_ = size_;
+                swap(new_table);
+
+                delete[] new_table.table_;
+                new_table.table_ = nullptr;
+            }
+
+            void reserve(size_type count)
+            {
+                rehash(count / max_load_factor_ + 1);
+            }
+
+            bool is_eq_to(const hash_table& other) const
+            {
+                if (size() != other.size())
+                    return false;
+
+                auto it = begin();
+                while (it != end())
+                {
+                    /**
+                     * For each key K we will check how many
+                     * instances of K are there in the table.
+                     * Then we will check if the count for K
+                     * is equal to that amount.
+                     */
+
+                    size_type cnt{};
+                    auto tmp = it;
+
+                    while (key_eq_(key_extractor_(*it), key_extractor_(*tmp)))
+                    {
+                        ++cnt;
+                        if (++tmp == end())
+                            break;
+                    }
+
+                    auto other_cnt = other.count(key_extractor_(*it));
+                    if (cnt != other_cnt)
+                        return false;
+
+                    it = tmp; // tmp  is one past *it's key.
+                }
+
+                return true;
+            }
+
+            ~hash_table()
+            {
+                // Lists are deleted in ~hash_table_bucket.
+                if (table_)
+                    delete[] table_;
+            }
+
+            place_type find_insertion_spot(const key_type& key) const
+            {
+                return Policy::find_insertion_spot(*this, key);
+            }
+
+            place_type find_insertion_spot(key_type&& key) const
+            {
+                return Policy::find_insertion_spot(*this, key);
+            }
+
+            const key_type& get_key(const value_type& val) const
+            {
+                return key_extractor_(val);
+            }
+
+            bool keys_equal(const key_type& key, const value_type& val)
+            {
+                return key_eq_(key, key_extractor_(val));
+            }
+
+            bool keys_equal(const key_type& key, const value_type& val) const
+            {
+                return key_eq_(key, key_extractor_(val));
+            }
+
+            hash_table_bucket<value_type, size_type>* table()
+            {
+                return table_;
+            }
+
+            hash_table_bucket<value_type, size_type>* head(size_type idx)
+            {
+                if (idx < bucket_count_)
+                    return table_[idx]->head;
+                else
+                    return nullptr;
+            }
+
+            void rehash_if_needed()
+            {
+                if (size_ > max_load_factor_ * bucket_count_)
+                    rehash(bucket_count_ * bucket_count_growth_factor_);
+            }
+
+            void increment_size()
+            {
+                ++size_;
+
+                rehash_if_needed();
+            }
+
+            void decrement_size()
+            {
+                --size_;
+            }
+
+        private:
+            hash_table_bucket<value_type, size_type>* table_;
+            size_type bucket_count_;
+            size_type size_;
+            hasher hasher_;
+            key_equal key_eq_;
+            key_extract key_extractor_;
+            float max_load_factor_;
+
+            static constexpr float bucket_count_growth_factor_{1.25};
+
+            size_type get_bucket_idx_(const key_type& key) const
+            {
+                return hasher_(key) % bucket_count_;
+            }
+
+            size_type first_filled_bucket_() const
+            {
+                size_type res{};
+                while (res < bucket_count_)
+                {
+                    if (table_[res].head)
+                        return res;
+                    ++res;
+                }
+
+                /**
+                 * Note: This is used for iterators,
+                 *       so we need to return a valid index.
+                 *       But since table_[0].head is nullptr
+                 *       we know that if we return 0 the
+                 *       created iterator will test as equal
+                 *       to end().
+                 */
+                return 0;
+            }
+
+            friend Policy;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/hash_table_bucket.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/hash_table_bucket.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/hash_table_bucket.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_HASH_TABLE_BUCKET
+#define LIBCPP_BITS_HASH_TABLE_BUCKET
+
+#include <__bits/list.hpp>
+
+namespace std::aux
+{
+    template<class Value, class Size>
+    struct hash_table_bucket
+    {
+        /**
+         * Note: We use a doubly linked list because
+         *       we need to use hints, which point to the
+         *       element after the hinted spot.
+         */
+
+        list_node<Value>* head;
+
+        hash_table_bucket()
+            : head{}
+        { /* DUMMY BODY */ }
+
+        Size size() const noexcept
+        {
+            auto current = head;
+            Size res{};
+
+            do
+            {
+                ++res;
+                current = current->next;
+            }
+            while (current != head);
+
+            return res;
+        }
+
+        void append(list_node<Value>* node)
+        {
+            if (!head)
+                head = node;
+            else
+                head->append(node);
+        }
+
+        void prepend(list_node<Value>* node)
+        {
+            if (!head)
+                head = node;
+            else
+                head->prepend(node);
+        }
+
+        void clear()
+        {
+            if (!head)
+                return;
+
+            auto current = head;
+            do
+            {
+                auto tmp = current;
+                current = current->next;
+                delete tmp;
+            }
+            while (current != head);
+
+            head = nullptr;
+        }
+
+        ~hash_table_bucket()
+        {
+            clear();
+        }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/hash_table_iterators.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/hash_table_iterators.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/hash_table_iterators.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,485 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_HASH_TABLE_ITERATORS
+#define LIBCPP_BITS_HASH_TABLE_ITERATORS
+
+#include <__bits/iterator.hpp>
+#include <__bits/list.hpp>
+#include <__bits/hash_table_bucket.hpp>
+#include <iterator>
+
+namespace std::aux
+{
+    template<class Value, class Reference, class Pointer, class Size>
+    class hash_table_iterator
+    {
+        public:
+            using value_type      = Value;
+            using size_type       = Size;
+            using reference       = Reference;
+            using pointer         = Pointer;
+            using difference_type = ptrdiff_t;
+
+            using iterator_category = forward_iterator_tag;
+
+            hash_table_iterator(hash_table_bucket<value_type, size_type>* table = nullptr,
+                                size_type idx = size_type{}, size_type max_idx = size_type{},
+                                list_node<value_type>* current = nullptr)
+                : table_{table}, idx_{idx}, max_idx_{max_idx}, current_{current}
+            { /* DUMMY BODY */ }
+
+            hash_table_iterator(const hash_table_iterator&) = default;
+            hash_table_iterator& operator=(const hash_table_iterator&) = default;
+
+            reference operator*()
+            {
+                return current_->value;
+            }
+
+            pointer operator->()
+            {
+                return &current_->value;
+            }
+
+            hash_table_iterator& operator++()
+            {
+                current_ = current_->next;
+                if (current_ == table_[idx_].head)
+                {
+                    if (idx_ < max_idx_)
+                    {
+                        while (!table_[++idx_].head && idx_ < max_idx_)
+                        { /* DUMMY BODY */ }
+
+                        if (idx_ < max_idx_)
+                            current_ = table_[idx_].head;
+                        else
+                            current_ = nullptr;
+                    }
+                    else
+                        current_ = nullptr;
+                }
+
+                return *this;
+            }
+
+            hash_table_iterator operator++(int)
+            {
+                auto tmp = *this;
+                ++(*this);
+
+                return tmp;
+            }
+
+            list_node<value_type>* node()
+            {
+                return current_;
+            }
+
+            const list_node<value_type>* node() const
+            {
+                return current_;
+            }
+
+            size_type idx() const
+            {
+                return idx_;
+            }
+
+        private:
+            hash_table_bucket<value_type, size_type>* table_;
+            size_type idx_;
+            size_type max_idx_;
+            list_node<value_type>* current_;
+
+            template<class V, class CR, class CP, class S>
+            friend class hash_table_const_iterator;
+    };
+
+    template<class Value, class Ref, class Ptr, class Size>
+    bool operator==(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
+                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class Ref, class Ptr, class Size>
+    bool operator!=(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
+                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class ConstReference, class ConstPointer, class Size>
+    class hash_table_const_iterator
+    {
+        using non_const_iterator_type = hash_table_iterator<
+            Value, get_non_const_ref_t<ConstReference>,
+            get_non_const_ptr_t<ConstPointer>, Size
+        >;
+
+        public:
+            using value_type      = Value;
+            using size_type       = Size;
+            using const_reference = ConstReference;
+            using const_pointer   = ConstPointer;
+            using difference_type = ptrdiff_t;
+
+            using iterator_category = forward_iterator_tag;
+
+            hash_table_const_iterator(const hash_table_bucket<value_type, size_type>* table = nullptr,
+                                      size_type idx = size_type{}, size_type max_idx = size_type{},
+                                      const list_node<value_type>* current = nullptr)
+                : table_{table}, idx_{idx}, max_idx_{max_idx}, current_{current}
+            { /* DUMMY BODY */ }
+
+            hash_table_const_iterator(const hash_table_const_iterator&) = default;
+            hash_table_const_iterator& operator=(const hash_table_const_iterator&) = default;
+
+            hash_table_const_iterator(const non_const_iterator_type& other)
+                : table_{other.table_}, idx_{other.idx_}, max_idx_{other.max_idx_},
+                  current_{other.current_}
+            { /* DUMMY BODY */ }
+
+            hash_table_const_iterator& operator=(const non_const_iterator_type& other)
+            {
+                table_ = other.table_;
+                idx_ = other.idx_;
+                max_idx_ = other.max_idx_;
+                current_ = other.current_;
+
+                return *this;
+            }
+
+            const_reference operator*() const
+            {
+                return current_->value;
+            }
+
+            const_pointer operator->() const
+            {
+                return &current_->value;
+            }
+
+            hash_table_const_iterator& operator++()
+            {
+                current_ = current_->next;
+                if (current_ == table_[idx_].head)
+                {
+                    if (idx_ < max_idx_)
+                    {
+                        while (!table_[++idx_].head && idx_ < max_idx_)
+                        { /* DUMMY BODY */ }
+
+                        if (idx_ < max_idx_)
+                            current_ = table_[idx_].head;
+                        else
+                            current_ = nullptr;
+                    }
+                    else
+                        current_ = nullptr;
+                }
+
+                return *this;
+            }
+
+            hash_table_const_iterator operator++(int)
+            {
+                auto tmp = *this;
+                ++(*this);
+
+                return tmp;
+            }
+
+            list_node<value_type>* node()
+            {
+                return const_cast<list_node<value_type>*>(current_);
+            }
+
+            const list_node<value_type>* node() const
+            {
+                return current_;
+            }
+
+            size_type idx() const
+            {
+                return idx_;
+            }
+
+        private:
+            const hash_table_bucket<value_type, size_type>* table_;
+            size_type idx_;
+            size_type max_idx_;
+            const list_node<value_type>* current_;
+    };
+
+    template<class Value, class CRef, class CPtr, class Size>
+    bool operator==(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
+                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class CRef, class CPtr, class Size>
+    bool operator!=(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
+                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class Ref, class Ptr, class CRef, class CPtr, class Size>
+    bool operator==(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
+                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class Ref, class Ptr, class CRef, class CPtr, class Size>
+    bool operator!=(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
+                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class CRef, class CPtr, class Ref, class Ptr, class Size>
+    bool operator==(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
+                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class CRef, class CPtr, class Ref, class Ptr, class Size>
+    bool operator!=(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
+                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class Reference, class Pointer>
+    class hash_table_local_iterator
+    {
+        public:
+            using value_type      = Value;
+            using reference       = Reference;
+            using pointer         = Pointer;
+            using difference_type = ptrdiff_t;
+
+            using iterator_category = forward_iterator_tag;
+
+            hash_table_local_iterator(list_node<value_type>* head = nullptr,
+                                      list_node<value_type>* current = nullptr)
+                : head_{head}, current_{current}
+            { /* DUMMY BODY */ }
+
+            hash_table_local_iterator(const hash_table_local_iterator&) = default;
+            hash_table_local_iterator& operator=(const hash_table_local_iterator&) = default;
+
+            reference operator*()
+            {
+                return current_->value;
+            }
+
+            pointer operator->()
+            {
+                return &current_->value;
+            }
+
+            hash_table_local_iterator& operator++()
+            {
+                current_ = current_->next;
+                if (current_ == head_)
+                    current_ = nullptr;
+
+                return *this;
+            }
+
+            hash_table_local_iterator operator++(int)
+            {
+                auto tmp = *this;
+                ++(*this);
+
+                return tmp;
+            }
+
+            list_node<value_type>* node()
+            {
+                return current_;
+            }
+
+            const list_node<value_type>* node() const
+            {
+                return current_;
+            }
+
+        private:
+            list_node<value_type>* head_;
+            list_node<value_type>* current_;
+
+            template<class V, class CR, class CP>
+            friend class hash_table_const_local_iterator;
+    };
+
+    template<class Value, class Ref, class Ptr>
+    bool operator==(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
+                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class Ref, class Ptr>
+    bool operator!=(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
+                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class ConstReference, class ConstPointer>
+    class hash_table_const_local_iterator
+    {
+        using non_const_iterator_type = hash_table_local_iterator<
+            Value, get_non_const_ref_t<ConstReference>,
+            get_non_const_ptr_t<ConstPointer>
+        >;
+
+        public:
+            using value_type      = Value;
+            using const_reference = ConstReference;
+            using const_pointer   = ConstPointer;
+            using difference_type = ptrdiff_t;
+
+            using iterator_category = forward_iterator_tag;
+
+            // TODO: requirement for forward iterator is default constructibility, fix others!
+            hash_table_const_local_iterator(const list_node<value_type>* head = nullptr,
+                                            const list_node<value_type>* current = nullptr)
+                : head_{head}, current_{current}
+            { /* DUMMY BODY */ }
+
+            hash_table_const_local_iterator(const hash_table_const_local_iterator&) = default;
+            hash_table_const_local_iterator& operator=(const hash_table_const_local_iterator&) = default;
+
+            hash_table_const_local_iterator(const non_const_iterator_type& other)
+                : head_{other.head_}, current_{other.current_}
+            { /* DUMMY BODY */ }
+
+            hash_table_const_local_iterator& operator=(const non_const_iterator_type& other)
+            {
+                head_ = other.head_;
+                current_ = other.current_;
+
+                return *this;
+            }
+
+            const_reference operator*() const
+            {
+                return current_->value;
+            }
+
+            const_pointer operator->() const
+            {
+                return &current_->value;
+            }
+
+            hash_table_const_local_iterator& operator++()
+            {
+                current_ = current_->next;
+                if (current_ == head_)
+                    current_ = nullptr;
+
+                return *this;
+            }
+
+            hash_table_const_local_iterator operator++(int)
+            {
+                auto tmp = *this;
+                ++(*this);
+
+                return tmp;
+            }
+
+
+            list_node<value_type>* node()
+            {
+                return const_cast<list_node<value_type>*>(current_);
+            }
+
+            const list_node<value_type>* node() const
+            {
+                return current_;
+            }
+
+        private:
+            const list_node<value_type>* head_;
+            const list_node<value_type>* current_;
+    };
+
+    template<class Value, class CRef, class CPtr>
+    bool operator==(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
+                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class CRef, class CPtr>
+    bool operator!=(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
+                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class Ref, class Ptr, class CRef, class CPtr>
+    bool operator==(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
+                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class Ref, class Ptr, class CRef, class CPtr>
+    bool operator!=(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
+                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class CRef, class CPtr, class Ref, class Ptr>
+    bool operator==(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
+                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
+    {
+        return lhs.node() == rhs.node();
+    }
+
+    template<class Value, class CRef, class CPtr, class Ref, class Ptr>
+    bool operator!=(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
+                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/hash_table_policies.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/hash_table_policies.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/hash_table_policies.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,435 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_HASH_TABLE_POLICIES
+#define LIBCPP_BITS_HASH_TABLE_POLICIES
+
+#include <tuple>
+#include <utility>
+
+namespace std::aux
+{
+    struct hash_single_policy
+    {
+        template<class Table, class Key>
+        static typename Table::size_type count(const Table& table, const Key& key)
+        {
+            return table.find(key) == table.end() ? 0 : 1;
+        }
+
+        template<class Table, class Key>
+        static typename Table::place_type find_insertion_spot(const Table& table, const Key& key)
+        {
+            auto idx = table.get_bucket_idx_(key);
+            return make_tuple(
+                &table.table_[idx],
+                table.table_[idx].head,
+                idx
+            );
+        }
+
+        template<class Table, class Key>
+        static typename Table::size_type erase(Table& table, const Key& key)
+        {
+            auto idx = table.get_bucket_idx_(key);
+            auto head = table.table_[idx].head;
+            auto current = head;
+
+            if (!current)
+                return 0;
+
+            do
+            {
+                if (table.keys_equal(key, current->value))
+                {
+                    --table.size_;
+
+                    if (current == head)
+                    {
+                        if (current->next != head)
+                            table.table_[idx].head = current->next;
+                        else
+                            table.table_[idx].head = nullptr;
+                    }
+
+                    current->unlink();
+                    delete current;
+
+                    return 1;
+                }
+                else
+                    current = current->next;
+            }
+            while (current != head);
+
+            return 0;
+        }
+
+        template<class Table, class Key>
+        static pair<
+            typename Table::iterator,
+            typename Table::iterator
+        > equal_range(Table& table, const Key& key)
+        {
+            auto it = table.find(key);
+            return make_pair(it, ++it);
+        }
+
+        template<class Table, class Key>
+        static pair<
+            typename Table::const_iterator,
+            typename Table::const_iterator
+        > equal_range_const(const Table& table, const Key& key)
+        { // Note: We cannot overload by return type, so we use a different name.
+            auto it = table.find(key);
+            return make_pair(it, ++it);
+        }
+
+        /**
+         * Note: We have to duplicate code for emplace, insert(const&)
+         *       and insert(&&) here, because the node (which makes distinction
+         *       between the arguments) is only created if the value isn't
+         *       in the table already.
+         */
+
+        template<class Table, class... Args>
+        static pair<
+            typename Table::iterator, bool
+        > emplace(Table& table, Args&&... args)
+        {
+            using value_type = typename Table::value_type;
+            using node_type  = typename Table::node_type;
+            using iterator   = typename Table::iterator;
+
+            table.increment_size();
+
+            auto val = value_type{forward<Args>(args)...};
+            const auto& key = table.get_key(val);
+            auto [bucket, target, idx] = table.find_insertion_spot(key);
+
+            if (!bucket)
+                return make_pair(table.end(), false);
+
+            if (target && table.keys_equal(key, target->value))
+            {
+                table.decrement_size();
+
+                return make_pair(
+                    iterator{
+                        table.table(), idx, table.bucket_count(),
+                        target
+                    },
+                    false
+                );
+            }
+            else
+            {
+                auto node = new node_type{move(val)};
+                bucket->prepend(node);
+
+                return make_pair(iterator{
+                    table.table(), idx,
+                    table.bucket_count(),
+                    node
+                }, true);
+            }
+        }
+
+        template<class Table, class Value>
+        static pair<
+            typename Table::iterator, bool
+        > insert(Table& table, const Value& val)
+        {
+            using node_type  = typename Table::node_type;
+            using iterator   = typename Table::iterator;
+
+            table.increment_size();
+
+            const auto& key = table.get_key(val);
+            auto [bucket, target, idx] = table.find_insertion_spot(key);
+
+            if (!bucket)
+                return make_pair(table.end(), false);
+
+            if (target && table.keys_equal(key, target->value))
+            {
+                table.decrement_size();
+
+                return make_pair(
+                    iterator{
+                        table.table(), idx, table.bucket_count(),
+                        target
+                    },
+                    false
+                );
+            }
+            else
+            {
+                auto node = new node_type{val};
+                bucket->prepend(node);
+
+                return make_pair(iterator{
+                    table.table(), idx,
+                    table.bucket_count(),
+                    node
+                }, true);
+            }
+        }
+
+        template<class Table, class Value>
+        static pair<
+            typename Table::iterator, bool
+        > insert(Table& table, Value&& val)
+        {
+            using value_type = typename Table::value_type;
+            using node_type  = typename Table::node_type;
+            using iterator   = typename Table::iterator;
+
+            table.increment_size();
+
+            const auto& key = table.get_key(val);
+            auto [bucket, target, idx] = table.find_insertion_spot(key);
+
+            if (!bucket)
+                return make_pair(table.end(), false);
+
+            if (target && table.keys_equal(key, target->value))
+            {
+                table.decrement_size();
+
+                return make_pair(
+                    iterator{
+                        table.table(), idx, table.bucket_count(),
+                        target
+                    },
+                    false
+                );
+            }
+            else
+            {
+                auto node = new node_type{forward<value_type>(val)};
+                bucket->prepend(node);
+
+                return make_pair(iterator{
+                    table.table(), idx,
+                    table.bucket_count(),
+                    node
+                }, true);
+            }
+        }
+    };
+
+    struct hash_multi_policy
+    {
+        template<class Table, class Key>
+        static typename Table::size_type count(const Table& table, const Key& key)
+        {
+            auto head = table.table_[table.get_bucket_idx_(key)].head;
+            if (!head)
+                return 0;
+
+            auto current = head;
+            typename Table::size_type res = 0;
+            do
+            {
+                if (table.keys_equal(key, current->value))
+                    ++res;
+
+                current = current->next;
+            }
+            while (current != head);
+
+            return res;
+        }
+
+        template<class Table, class Key>
+        static typename Table::place_type find_insertion_spot(const Table& table, const Key& key)
+        {
+            auto idx = table.get_bucket_idx_(key);
+            auto head = table.table_[idx].head;
+
+            if (head)
+            {
+                auto current = head;
+                do
+                {
+                    if (table.keys_equal(key, current->value))
+                    {
+                        return make_tuple(
+                            &table.table_[idx],
+                            current,
+                            idx
+                        );
+                    }
+
+                    current = current->next;
+                } while (current != head);
+            }
+
+            return make_tuple(
+                &table.table_[idx],
+                table.table_[idx].head,
+                idx
+            );
+        }
+
+        template<class Table, class Key>
+        static typename Table::size_type erase(Table& table, const Key& key)
+        {
+            auto idx = table.get_bucket_idx_(key);
+            auto head = table.table_[idx].head;
+            auto current = head;
+            table.table_[idx].head = nullptr;
+
+            if (!current)
+                return 0;
+
+            /**
+             * We traverse the list and delete if the keys
+             * equal, if they don't we append the nodes back
+             * to the bucket.
+             */
+            typename Table::size_type res{};
+
+            do
+            {
+                auto tmp = current;
+                current = current->next;
+
+                if (!table.keys_equal(key, tmp->value))
+                    table.table_[idx].append(tmp);
+                else
+                {
+                    ++res;
+                    --table.size_;
+
+                    delete tmp;
+                }
+            }
+            while (current != head);
+
+            return res;
+        }
+
+        template<class Table, class Key>
+        static pair<
+            typename Table::iterator,
+            typename Table::iterator
+        > equal_range(Table& table, const Key& key)
+        {
+            auto first = table.find(key);
+            if (first == table.end())
+                return make_pair(table.end(), table.end());
+
+            auto last = first;
+            do
+            {
+                ++last;
+            } while (table.keys_equal(key, *last));
+
+            return make_pair(first, last);
+        }
+
+        template<class Table, class Key>
+        static pair<
+            typename Table::const_iterator,
+            typename Table::const_iterator
+        > equal_range_const(const Table& table, const Key& key)
+        {
+            auto first = table.find(key);
+            if (first == table.end())
+                return make_pair(table.end(), table.end());
+
+            auto last = first;
+            do
+            {
+                ++last;
+            } while (table.keys_equal(key, *last));
+
+            return make_pair(first, last);
+        }
+
+        template<class Table, class... Args>
+        static typename Table::iterator emplace(Table& table, Args&&... args)
+        {
+            using node_type  = typename Table::node_type;
+
+            auto node = new node_type{forward<Args>(args)...};
+
+            return insert(table, node);
+        }
+
+        template<class Table, class Value>
+        static typename Table::iterator insert(Table& table, const Value& val)
+        {
+            using node_type  = typename Table::node_type;
+
+            auto node = new node_type{val};
+
+            return insert(table, node);
+        }
+
+        template<class Table, class Value>
+        static typename Table::iterator insert(Table& table, Value&& val)
+        {
+            using value_type = typename Table::value_type;
+            using node_type  = typename Table::node_type;
+
+            auto node = new node_type{forward<value_type>(val)};
+
+            return insert(table, node);
+        }
+
+        template<class Table>
+        static typename Table::iterator insert(Table& table, typename Table::node_type* node)
+        {
+            using iterator   = typename Table::iterator;
+
+            table.increment_size();
+
+            const auto& key = table.get_key(node->value);
+            auto [bucket, target, idx] = table.find_insertion_spot(key);
+
+            if (!bucket)
+                table.end();
+
+            if (target && table.keys_equal(key, target->value))
+                target->append(node);
+            else
+                bucket->prepend(node);
+
+            return iterator{
+                table.table(), idx,
+                table.bucket_count(),
+                node
+            };
+        }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/insert_iterator.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/insert_iterator.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/insert_iterator.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_INSERT_ITERATOR
+#define LIBCPP_BITS_INSERT_ITERATOR
+
+namespace std
+{
+    struct forward_iterator_tag;
+}
+
+namespace std::aux
+{
+    /**
+     * Note: Commonly the data structures in this library
+     *       contain a set of insert member functions. These
+     *       are often both iterator based and copy based.
+     *       This iterator can change the copy version into
+     *       an iterator version by creating a count based copy
+     *       iterator.
+     * Usage:
+     *      first == insert_iterator{value}
+     *      last  == insert_iterator{count}
+     *
+     *      So the following code:
+     *          while (first != last)
+     *              *data_++ = *first++;
+     *
+     *      Will insert a copy of value into the data_
+     *      iterator exactly count times.
+     * TODO: Apply this to existing containers?
+     */
+    template<class T>
+    class insert_iterator
+    {
+        public:
+            using difference_type   = unsigned long long;
+            using value_type        = T;
+            using iterator_category = input_iterator_tag;
+            using reference         = value_type&;
+            using pointer           = value_type*;
+
+            explicit insert_iterator(difference_type count, const value_type& val = value_type{})
+                : value_{val}, count_{count}
+            { /* DUMMY BODY */ }
+
+            insert_iterator(const insert_iterator&) = default;
+            insert_iterator& operator=(const insert_iterator&) = default;
+
+            insert_iterator(insert_iterator&&) = default;
+            insert_iterator& operator=(insert_iterator&&) = default;
+
+            const value_type& operator*() const
+            {
+                return value_;
+            }
+
+            const value_type* operator->() const
+            {
+                return &value_;
+            }
+
+            insert_iterator& operator++()
+            {
+                ++count_;
+
+                return *this;
+            }
+
+            insert_iterator operator++(int)
+            {
+                ++count_;
+
+                return insert_iterator{count_ - 1, value_};
+            }
+
+            bool operator==(const insert_iterator& other)
+            {
+                return count_ == other.count_;
+            }
+
+            bool operator!=(const insert_iterator& other)
+            {
+                return count_ != other.count_;
+            }
+
+        private:
+            value_type value_;
+            difference_type count_;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/iomanip.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/iomanip.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/iomanip.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_IOMANIP
+#define LIBCPP_BITS_IOMANIP
+
+#include <ios>
+#include <utility>
+
+namespace std::aux
+{
+    /**
+     * Note: This allows us to lower the amount
+     *       of code duplication in this module
+     *       as we can avoid operator<</>> overloading
+     *       for the manipulators.
+     */
+    template<class Manipulator>
+    struct manip_wrapper
+    {
+        template<class... Args>
+        manip_wrapper(Args&&... args)
+            : manipulator{forward<Args>(args)...}
+        { /* DUMMY BODY */ }
+
+        void operator()(ios_base& str)
+        {
+            manipulator(str);
+        }
+
+        Manipulator manipulator;
+    };
+    template<class Char, class Traits, class Manipulator>
+    basic_ostream<Char, Traits>& operator<<(
+        basic_ostream<Char, Traits>& os, manip_wrapper<Manipulator> manip
+    )
+    {
+        manip(os);
+
+        return os;
+    }
+
+    template<class Char, class Traits, class Manipulator>
+    basic_istream<Char, Traits>& operator>>(
+        basic_istream<Char, Traits>& is, manip_wrapper<Manipulator> manip
+    )
+    {
+        manip(is);
+
+        return is;
+    }
+
+    struct resetiosflags_t
+    {
+        resetiosflags_t(ios_base::fmtflags m);
+
+        void operator()(ios_base& str) const;
+
+        ios_base::fmtflags mask;
+    };
+
+    struct setiosflags_t
+    {
+        setiosflags_t(ios_base::fmtflags m);
+
+        void operator()(ios_base& str) const;
+
+        ios_base::fmtflags mask;
+    };
+
+    struct setbase_t
+    {
+        setbase_t(int b);
+
+        void operator()(ios_base& str) const;
+
+        int base;
+    };
+
+    /**
+     * Note: setfill is only for basic_ostream so
+     *       this is the only case where we overload
+     *       the appropriate operator again.
+     */
+    template<class Char>
+    struct setfill_t
+    {
+        setfill_t(Char c)
+            : fill{c}
+        { /* DUMMY BODY */ }
+
+        template<class Traits>
+        void operator()(basic_ios<Char, Traits>& str) const
+        {
+            str.fill(fill);
+        }
+
+        Char fill;
+    };
+
+    template<class Char, class Traits>
+    basic_ostream<Char, Traits>& operator<<(
+        basic_ostream<Char, Traits>& is,
+        setfill_t<Char> manip
+    )
+    {
+        manip(is);
+
+        return is;
+    }
+
+    struct setprecision_t
+    {
+        setprecision_t(int);
+
+        void operator()(ios_base&) const;
+
+        int prec;
+    };
+
+    struct setw_t
+    {
+        setw_t(int);
+
+        void operator()(ios_base&) const;
+
+        int width;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/iterator.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/iterator.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/iterator.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_ITERATOR
+#define LIBCPP_BITS_ITERATOR
+
+#include <__bits/aux.hpp>
+
+namespace std::aux
+{
+    /**
+     * Used for our custom iterators where we know
+     * that their references/const_references and
+     * pointers/const_pointers differ only in constness.
+     */
+
+    template<class T>
+    struct get_non_const_ref
+        : type_is<T>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct get_non_const_ref<const T&>
+        : type_is<T&>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    using get_non_const_ref_t = typename get_non_const_ref<T>::type;
+
+    template<class T>
+    struct get_non_const_ptr
+        : type_is<T>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct get_non_const_ptr<const T*>
+        : type_is<T*>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    using get_non_const_ptr_t = typename get_non_const_ptr<T>::type;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/key_extractors.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/key_extractors.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/key_extractors.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_KEY_EXTRACTORS
+#define LIBCPP_BITS_KEY_EXTRACTORS
+
+#include <utility>
+
+namespace std::aux
+{
+    template<class Key, class Value>
+    struct key_value_key_extractor
+    {
+        const Key& operator()(const pair<const Key, Value>& p) const noexcept
+        {
+            return p.first;
+        }
+    };
+
+    template<class Key>
+    struct key_no_value_key_extractor
+    {
+        Key& operator()(Key& k) const noexcept
+        {
+            return k;
+        }
+
+        const Key& operator()(const Key& k) const noexcept
+        {
+            return k;
+        }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/list.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/list.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/list.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_LIST
+#define LIBCPP_BITS_LIST
+
+namespace std::aux
+{
+    template<class T>
+    struct list_node
+    {
+        T value;
+        list_node* next;
+        list_node* prev;
+
+        template<class... Args>
+        list_node(Args&&... args)
+            : value{forward<Args>(args)...},
+              next{}, prev{}
+        {
+            next = this;
+            prev = this;
+        }
+
+        list_node(const T& val)
+            : value{val}, next{}, prev{}
+        {
+            next = this;
+            prev = this;
+        }
+
+        list_node(T&& val)
+            : value{forward<T>(val)}, next{}, prev{}
+        {
+            next = this;
+            prev = this;
+        }
+
+        void append(list_node* node)
+        {
+            node->next = next;
+            node->prev = this;
+            next->prev = node;
+            next = node;
+        }
+
+        void prepend(list_node* node)
+        {
+            node->next = this;
+            node->prev = prev;
+            prev->next = node;
+            prev = node;
+        }
+
+        void unlink()
+        {
+            prev->next = next;
+            next->prev = prev;
+            next = this;
+            prev = this;
+        }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/locale.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/locale.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/locale.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_LOCALE
+#define LIBCPP_BITS_LOCALE
+
+#include <impl/string.hpp>
+
+namespace std
+{
+    class locale;
+
+    /**
+     * 22.3.1, class locale:
+     */
+
+    class locale
+    {
+        public:
+            class facet
+            {
+                protected:
+                    explicit facet(size_t refs = 0);
+
+                    virtual ~facet();
+
+                    facet(const facet&) = delete;
+                    void operator=(const facet&) = delete;
+            };
+
+            class id
+            {
+                public:
+                    id() = default;
+
+                    id(const id&) = delete;
+                    void operator=(const id&) = delete;
+            };
+
+            using category = int;
+
+            static const category none     = 0b000'0001;
+            static const category collate  = 0b000'0010;
+            static const category ctype    = 0b000'0100;
+            static const category monetary = 0b000'1000;
+            static const category numeric  = 0b001'0000;
+            static const category time     = 0b010'0000;
+            static const category messages = 0b100'0000;
+            static const category all      = collate | ctype | monetary |
+                                             numeric | time | messages;
+
+            locale() noexcept;
+
+            locale(const locale& other) noexcept;
+
+            explicit locale(const char* name);
+
+            explicit locale(const string& name);
+
+            locale(const locale& other, const char* name, category);
+
+            locale(const locale& other, const string& name, category);
+
+            template<class Facet>
+            locale(const locale& other, Facet* f)
+                : name_{other.name_}
+            { /* DUMMY BODY */ }
+
+            locale(const locale& other, const locale& one, category);
+
+            ~locale() = default;
+
+            const locale& operator=(const locale& other) noexcept;
+
+            template<class Facet>
+            locale combine(const locale& other) const
+            {
+                return other;
+            }
+
+            string name() const;
+
+            bool operator==(const locale& other) const;
+            bool operator!=(const locale& other) const;
+
+            template<class Char, class Traits, class Allocator>
+            bool operator()(const basic_string<Char, Traits, Allocator>& s1,
+                            const basic_string<Char, Traits, Allocator>& s2) const
+            {
+                // TODO: define outside locale
+                /* return use_facet<collate<Char>>(*this).compare( */
+                /*     s1.begin(), s1.end(), s2.begin(), s2.end() */
+                /* ) < 0; */
+                return false;
+            }
+
+            static locale global(const locale&)
+            {
+                return *the_locale_;
+            }
+
+            static const locale& classic()
+            {
+                return *the_locale_;
+            }
+
+        private:
+            string name_;
+
+            // TODO: implement the_locale_
+            static constexpr locale* the_locale_{nullptr};
+
+            template<class Facet>
+            friend bool has_facet(const locale&);
+
+            template<class Facet>
+            bool has_()
+            { // Our single locale atm has all facets.
+                return true;
+            }
+
+            template<class Facet>
+            /* friend const Facet& use_facet(const locale&); */
+            friend Facet use_facet(const locale&);
+
+            template<class Facet>
+            /* const Facet& get_() const */
+            Facet get_() const
+            {
+                return Facet{0U};
+            }
+    };
+
+    template<class Facet>
+    /* const Facet& use_facet(const locale& loc) */
+    Facet use_facet(const locale& loc)
+    {
+        return loc.get_<Facet>();
+    }
+
+    template<class Facet>
+    bool has_facet(const locale& loc)
+    {
+        return loc.has_<Facet>();
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/locale/codecvt.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/locale/codecvt.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/locale/codecvt.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_LOCALE_CODECVT
+#define LIBCPP_BITS_LOCALE_CODECVT
+
+#include <intetnal/locale.hpp>
+#include <string>
+
+namespace std
+{
+    /**
+     * 22.4.1.4, class template codecvt:
+     */
+
+    class codecvt_base
+    {
+        public:
+            enum result
+            {
+                ok, partial, error, noconv
+            };
+    };
+
+    template<class Intern, class Extern, class State>
+    class codecvt: public codecvt_base
+    {
+        public:
+            using intern_type = Intern;
+            using extern_type = Extern;
+            using state_type  = State;
+
+            explicit codecvt(size_t = 0)
+            { /* DUMMY BODY */ }
+
+            result out(state_type& state, const intern_type* from, const intern_type* from_end,
+                       const intern_type*& from_next, extern_type* to, extern_type* to_end,
+                       extern_type*& to_next) const
+            {
+                return do_out(state, from, from_end, from_next, to, to_end, to_next);
+            }
+
+            result unshift(state_type& state, extern_type* to, extern_type* to_end,
+                           extern_type*& to_next) const
+            {
+                return do_unshift(state, to, to_end, to_next);
+            }
+
+            result in(state_type& state, const extern_type* from, const extern_type* from_end,
+                      const extern_type*& from_next, intern_type* to, intern_type* to_end,
+                      intern_type*& to_next) const
+            {
+                return do_in(state, from, from_end, from_next, to, to_end, to_next);
+            }
+
+            int encoding() const noexcept
+            {
+                return do_encoding();
+            }
+
+            bool always_noconv() const noexcept
+            {
+                return do_always_noconv();
+            }
+
+            int length(state_type& state, const extern_type* from, const extern_type* end,
+                       size_t max) const
+            {
+                return do_length(state, from, end, max);
+            }
+
+            int max_length() const noexcept
+            {
+                return do_max_length();
+            }
+
+            static locale::id id;
+
+            ~codecvt() = default;
+
+        protected:
+            virtual result do_out(state_type& state, const intern_type* from, const intern_type* from_end,
+                                  const intern_type*& from_next, extern_type* to, extern_type* to_end,
+                                  extern_type*& to_next) const
+            {
+                // TODO: implement
+                return error;
+            }
+
+            virtual result do_unshift(state_type& state, extern_type* to, extern_type* to_end,
+                                      extern_type*& to_next) const
+            {
+                // TODO: implement
+                return error;
+            }
+
+            virtual result do_in(state_type& state, const extern_type* from, const extern_type* from_end,
+                                 const extern_type*& from_next, intern_type* to, intern_type* to_end,
+                                 intern_type*& to_next) const
+            {
+                // TODO: implement
+                return error;
+            }
+
+            virtual int do_encoding() const noexcept
+            {
+                // TODO: implement
+                return 0;
+            }
+
+            virtual bool do_always_noconv() const noexcept
+            {
+                // TODO: implement
+                return false;
+            }
+
+            virtual int do_length(state_type& state, const extern_type* from, const extern_type* end,
+                                  size_t max) const
+            {
+                // TODO: implement
+                return 0;
+            }
+
+            virtual int do_max_length() const noexcept
+            {
+                // TODO: implement
+                return 0;
+            }
+    };
+
+    template<class Intern, class Extern, class State>
+    locale::id codecvt<Intern, Extern, State>::id{};
+
+    /**
+     * 22.4.1.5, class template codecvt_byname:
+     * Note: Dummy, TODO: implement.
+     */
+
+    template<class Intern, class Extern, class State>
+    class codecvt_byname: public codecvt<Intern, Extern, State>
+    {
+        public:
+            explicit codecvt_byname(const char*, size_t = 0)
+            { /* DUMMY BODY */ }
+
+            explicit codecvt_byname(const string&, size_t = 0)
+            { /* DUMMY BODY */ }
+
+            ~codecvt_byname() = default;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/locale/ctype.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/locale/ctype.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/locale/ctype.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,611 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_LOCALE_CTYPE
+#define LIBCPP_BITS_LOCALE_CTYPE
+
+#include <cctype>
+#include <__bits/locale.hpp>
+#include <impl/string.hpp>
+
+namespace std
+{
+    /**
+     * 22.4.1, the type category:
+     */
+
+    class ctype_base
+    {
+        public:
+            using mask = uint16_t;
+
+            static constexpr mask space  = 0b00'0000'0001;
+            static constexpr mask print  = 0b00'0000'0010;
+            static constexpr mask cntrl  = 0b00'0000'0100;
+            static constexpr mask upper  = 0b00'0000'1000;
+            static constexpr mask lower  = 0b00'0001'0000;
+            static constexpr mask alpha  = 0b00'0010'0000;
+            static constexpr mask digit  = 0b00'0100'0000;
+            static constexpr mask punct  = 0b00'1000'0000;
+            static constexpr mask xdigit = 0b01'0000'0000;
+            static constexpr mask blank  = 0b10'0000'0000;
+            static constexpr mask alnum  = alpha | digit;
+            static constexpr mask graph  = alnum | punct;
+    };
+
+    /**
+     * 22.4.1.1, class template ctype:
+     */
+
+    template<class Char>
+    class ctype: public locale::facet, public ctype_base
+    {
+        public:
+            using char_type = Char;
+
+            explicit ctype(size_t)
+            { /* DUMMY BODY */ }
+
+            bool is(mask m, char_type c) const
+            {
+                return do_is(m, c);
+            }
+
+            const char_type* is(const char_type* low, const char_type* high,
+                                mask* vec) const
+            {
+                return do_is(low, high, vec);
+            }
+
+            const char_type* scan_is(mask m, const char_type* low,
+                                     const char_type* high) const
+            {
+                return do_scan_is(m, low, high);
+            }
+
+            const char_type* scan_not(mask m, const char_type* low,
+                                      const char_type* high) const
+            {
+                return do_scan_not(m, low, high);
+            }
+
+            char_type toupper(char_type c) const
+            {
+                return do_toupper(c);
+            }
+
+            const char_type* toupper(char_type* low, const char_type* high) const
+            {
+                return do_toupper(low, high);
+            }
+
+            char_type tolower(char_type c) const
+            {
+                return do_tolower(c);
+            }
+
+            const char_type* tolower(char_type* low, const char_type* high) const
+            {
+                return do_tolower(low, high);
+            }
+
+            char_type widen(char c) const
+            {
+                return do_widen(c);
+            }
+
+            const char_type* widen(const char* low, const char* high, char_type* to) const
+            {
+                return do_widen(low, high, to);
+            }
+
+            char narrow(char_type c, char def) const
+            {
+                return do_narrow(c, def);
+            }
+
+            const char_type* narrow(const char_type* low, const char_type* high,
+                                    char def, char* to) const
+            {
+                return do_narrow(low, high, def, to);
+            }
+
+            static locale::id id;
+
+            /**
+             * Note: This is a deviation from the standard, because in the
+             *       ISO C++ Standard this function is protected (because
+             *       the instances are reference counted, but in our design
+             *       they are not and as such we did this change).
+             *       (This applies to all constructors of all facets.)
+             */
+            ~ctype() = default;
+
+        protected:
+            virtual bool do_is(mask m, char_type c) const
+            {
+                // TODO: implement
+                return false;
+            }
+
+            virtual const char_type* do_is(const char_type* low, const char_type high,
+                                           mask m) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual const char_type* do_scan_is(mask m, const char_type* low,
+                                                const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual const char_type* do_scan_not(mask m, const char_type* low,
+                                                 const char_type* high) const
+            {
+                // TODO: implement
+                return low;
+            }
+
+            virtual char_type do_toupper(char_type c) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_toupper(char_type* low, const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual char_type do_tolower(char_type c) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_tolower(char_type* low, const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual char_type do_widen(char c) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_widen(const char* low, const char* high,
+                                              char_type* dest) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual char do_narrow(char_type c, char def) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_narrow(const char_type* low, const char_type* high,
+                                               char def, char* dest) const
+            {
+                // TODO: implement
+                return high;
+            }
+    };
+
+    template<class Char>
+    locale::id ctype<Char>::id{};
+
+    /**
+     * 22.4.1.2, class template ctype_byname:
+     * Note: Dummy, TODO: implement.
+     */
+
+    template<class Char>
+    class ctype_byname: public ctype<Char>
+    {
+        public:
+            using mask = typename ctype<Char>::mask;
+
+            explicit ctype_byname(const char* name, size_t = 0)
+            { /* DUMMY BODY */ }
+
+            explicit ctype_byname(const string& name, size_t = 0)
+            { /* DUMMY BODY */ }
+
+        protected:
+            ~ctype_byname() = default;
+    };
+
+    /**
+     * 22.4.1.3, ctype specialziations:
+     */
+
+    template<>
+    class ctype<char>: public locale::facet, public ctype_base
+    {
+        public:
+            using char_type = char;
+
+            explicit ctype(const mask* tab = nullptr, bool del = false, size_t = 0)
+            { /* DUMMY BODY */ }
+
+            bool is(mask m, char_type c) const
+            {
+                return do_is(m, c);
+            }
+
+            const char_type* is(const char_type* low, const char_type* high,
+                                mask* vec) const
+            {
+                return do_is(low, high, vec);
+            }
+
+            const char_type* scan_is(mask m, const char_type* low,
+                                     const char_type* high) const
+            {
+                return do_scan_is(m, low, high);
+            }
+
+            const char_type* scan_not(mask m, const char_type* low,
+                                      const char_type* high) const
+            {
+                return do_scan_not(m, low, high);
+            }
+
+            char_type toupper(char_type c) const
+            {
+                return do_toupper(c);
+            }
+
+            const char_type* toupper(char_type* low, const char_type* high) const
+            {
+                return do_toupper(low, high);
+            }
+
+            char_type tolower(char_type c) const
+            {
+                return do_tolower(c);
+            }
+
+            const char_type* tolower(char_type* low, const char_type* high) const
+            {
+                return do_tolower(low, high);
+            }
+
+            char_type widen(char c) const
+            {
+                return do_widen(c);
+            }
+
+            const char_type* widen(const char* low, const char* high, char_type* to) const
+            {
+                return do_widen(low, high, to);
+            }
+
+            char narrow(char_type c, char def) const
+            {
+                return do_narrow(c, def);
+            }
+
+            const char_type* narrow(const char_type* low, const char_type* high,
+                                    char def, char* to) const
+            {
+                return do_narrow(low, high, def, to);
+            }
+
+            static locale::id id;
+            static const size_t table_size{0};
+
+            const mask* table() const noexcept
+            {
+                return classic_table();
+            }
+
+            static const mask* classic_table() noexcept
+            {
+                return classic_table_;
+            }
+
+            ~ctype() = default;
+
+        protected:
+            virtual bool do_is(mask m, char_type c) const
+            {
+                // TODO: implement, this is a dummy
+                if ((m & space) != 0 && std::isspace(c))
+                    return true;
+                else if ((m & alpha) != 0 && std::isalpha(c))
+                    return true;
+                else if ((m & upper) != 0 && std::isupper(c))
+                    return true;
+                else if ((m & lower) != 0 && std::islower(c))
+                    return true;
+                else if ((m & digit) != 0 && std::isdigit(c))
+                    return true;
+                return false;
+            }
+
+            virtual const char_type* do_is(const char_type* low, const char_type* high,
+                                           mask* m) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual const char_type* do_scan_is(mask m, const char_type* low,
+                                                const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual const char_type* do_scan_not(mask m, const char_type* low,
+                                                 const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual char_type do_toupper(char_type c) const
+            {
+                return std::toupper(c);
+            }
+
+            virtual const char_type* do_toupper(char_type* low, const char_type* high) const
+            {
+                while (low != high)
+                    *low = std::toupper(*low);
+
+                return high;
+            }
+
+            virtual char_type do_tolower(char_type c) const
+            {
+                return std::tolower(c);
+            }
+
+            virtual const char_type* do_tolower(char_type* low, const char_type* high) const
+            {
+                while (low != high)
+                    *low = std::tolower(*low);
+
+                return high;
+            }
+
+            virtual char_type do_widen(char c) const
+            {
+                return c;
+            }
+
+            virtual const char_type* do_widen(const char* low, const char* high,
+                                              char_type* dest) const
+            {
+                while (low != high)
+                    *dest++ = *low++;
+
+                return high;
+            }
+
+            virtual char do_narrow(char_type c, char def) const
+            {
+                return c;
+            }
+
+            virtual const char_type* do_narrow(const char_type* low, const char_type* high,
+                                               char def, char* dest) const
+            {
+                while (low != high)
+                    *dest++ = *low++;
+
+                return high;
+            }
+
+        private:
+            static constexpr mask* classic_table_{nullptr};
+    };
+
+    template<>
+    class ctype<wchar_t>: public locale::facet, public ctype_base
+    {
+        public:
+            using char_type = wchar_t;
+
+            explicit ctype(const mask* tab = nullptr, bool del = false, size_t = 0)
+            { /* DUMMY BODY */ }
+
+            bool is(mask m, char_type c) const
+            {
+                return do_is(m, c);
+            }
+
+            const char_type* is(const char_type* low, const char_type* high,
+                                mask* vec) const
+            {
+                return do_is(low, high, vec);
+            }
+
+            const char_type* scan_is(mask m, const char_type* low,
+                                     const char_type* high) const
+            {
+                return do_scan_is(m, low, high);
+            }
+
+            const char_type* scan_not(mask m, const char_type* low,
+                                      const char_type* high) const
+            {
+                return do_scan_not(m, low, high);
+            }
+
+            char_type toupper(char_type c) const
+            {
+                return do_toupper(c);
+            }
+
+            const char_type* toupper(char_type* low, const char_type* high) const
+            {
+                return do_toupper(low, high);
+            }
+
+            char_type tolower(char_type c) const
+            {
+                return do_tolower(c);
+            }
+
+            const char_type* tolower(char_type* low, const char_type* high) const
+            {
+                return do_tolower(low, high);
+            }
+
+            char_type widen(char c) const
+            {
+                return do_widen(c);
+            }
+
+            const char_type* widen(const char* low, const char* high, char_type* to) const
+            {
+                return do_widen(low, high, to);
+            }
+
+            char narrow(char_type c, char def) const
+            {
+                return do_narrow(c, def);
+            }
+
+            const char_type* narrow(const char_type* low, const char_type* high,
+                                    char def, char* to) const
+            {
+                return do_narrow(low, high, def, to);
+            }
+
+            static locale::id id;
+            static const size_t table_size{0};
+
+            const mask* table() const noexcept
+            {
+                return classic_table();
+            }
+
+            static const mask* classic_table() noexcept
+            {
+                return classic_table_;
+            }
+
+            ~ctype() = default;
+
+        protected:
+            virtual bool do_is(mask m, char_type c) const
+            {
+                // TODO: implement
+                return false;
+            }
+
+            virtual const char_type* do_is(const char_type* low, const char_type* high,
+                                           mask* m) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual const char_type* do_scan_is(mask m, const char_type* low,
+                                                const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual const char_type* do_scan_not(mask m, const char_type* low,
+                                                 const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual char_type do_toupper(char_type c) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_toupper(char_type* low, const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual char_type do_tolower(char_type c) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_tolower(char_type* low, const char_type* high) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+            virtual char_type do_widen(char c) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_widen(const char* low, const char* high,
+                                              char_type* dest) const
+            {
+                // TODO: implement
+                return dest;
+            }
+
+            virtual char do_narrow(char_type c, char def) const
+            {
+                // TODO: implement
+                return c;
+            }
+
+            virtual const char_type* do_narrow(const char_type* low, const char_type* high,
+                                               char def, char* dest) const
+            {
+                // TODO: implement
+                return high;
+            }
+
+        private:
+            static constexpr mask* classic_table_{nullptr};
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/locale/num_get.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/locale/num_get.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/locale/num_get.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_LOCALE_NUM_GET
+#define LIBCPP_BITS_LOCALE_NUM_GET
+
+#include <cerrno>
+#include <cstring>
+#include <__bits/locale.hpp>
+#include <__bits/locale/numpunct.hpp>
+#include <ios>
+#include <iterator>
+#include <limits>
+
+namespace std
+{
+    /**
+     * 22.4.2.1, class template num_get:
+     */
+
+    template<class Char, class InputIterator = istreambuf_iterator<Char>>
+    class num_get: public locale::facet
+    {
+        public:
+            using char_type = Char;
+            using iter_type = InputIterator;
+
+            explicit num_get(size_t refs = 0)
+            { /* DUMMY BODY */ }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, bool& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, long& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, long long& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, unsigned short& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, unsigned int& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, unsigned long& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, unsigned long long& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, float& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, double& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, long double& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            iter_type get(iter_type in, iter_type end, ios_base& base,
+                          ios_base::iostate& err, void*& v) const
+            {
+                return do_get(in, end, base, err, v);
+            }
+
+            static locale::id id;
+
+            ~num_get()
+            { /* DUMMY BODY */ }
+
+        protected:
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, bool& v) const
+            {
+                if (in == end)
+                {
+                    err = ios_base::eofbit;
+                    return in;
+                }
+
+                if ((base.flags() & ios_base::boolalpha) == 0)
+                {
+                    int8_t tmp{};
+                    in = get_integral_<int64_t>(in, end, base, err, tmp);
+
+                    if (tmp == 0)
+                        v = false;
+                    else if (tmp == 1)
+                        v = true;
+                    else
+                    {
+                        v = true;
+                        err = ios_base::failbit;
+                    }
+                }
+                else
+                {
+                    /**
+                     * We track both truename() and falsename()
+                     * at the same time, once either is matched
+                     * or the input is too big without a match
+                     * or the input ends the conversion ends
+                     * and the result is deduced.
+                     */
+
+                    auto loc = base.getloc();
+                    const auto& nt = use_facet<numpunct<char_type>>(loc);
+
+                    auto true_target = nt.truename();
+                    auto false_target = nt.falsename();
+
+                    if (true_target == "" || false_target == "")
+                    {
+                        v = (err == ios_base::failbit);
+                        return in;
+                    }
+
+                    auto true_str = true_target;
+                    auto false_str = false_target;
+
+                    size_t i{};
+                    while (true)
+                    {
+                        if (true_str.size() <= i && false_str.size() <= i)
+                            break;
+                        auto c = *in++;
+
+                        if (i < true_str.size())
+                            true_str[i] = c;
+                        if (i < false_str.size())
+                            false_str[i] = c;
+                        ++i;
+
+                        if (in == end || *in == '\n')
+                        {
+                            err = ios_base::eofbit;
+                            break;
+                        }
+                    }
+
+                    if (i == true_str.size() && true_str == true_target)
+                    {
+                        v = true;
+
+                        if (++in == end)
+                            err = ios_base::eofbit;
+                        else
+                            err = ios_base::goodbit;
+                    }
+                    else if (i == false_str.size() && false_str == false_target)
+                    {
+                        v = false;
+
+                        if (in == end)
+                            err = (ios_base::failbit | ios_base::eofbit);
+                        else
+                            err = ios_base::failbit;
+                    }
+                    else
+                        err = ios_base::failbit;
+                }
+
+                return in;
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, long& v) const
+            {
+                return get_integral_<int64_t>(in, end, base, err, v);
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, long long& v) const
+            {
+                return get_integral_<int64_t>(in, end, base, err, v);
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, unsigned short& v) const
+            {
+                return get_integral_<uint64_t>(in, end, base, err, v);
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, unsigned int& v) const
+            {
+                return get_integral_<uint64_t>(in, end, base, err, v);
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, unsigned long& v) const
+            {
+                return get_integral_<uint64_t>(in, end, base, err, v);
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, unsigned long long& v) const
+            {
+                return get_integral_<uint64_t>(in, end, base, err, v);
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, float& v) const
+            {
+                // TODO: implement
+                return in;
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, double& v) const
+            {
+                // TODO: implement
+                return in;
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, long double& v) const
+            {
+                // TODO: implement
+                return in;
+            }
+
+            iter_type do_get(iter_type in, iter_type end, ios_base& base,
+                             ios_base::iostate& err, void*& v) const
+            {
+                // TODO: implement
+                return in;
+            }
+
+        private:
+            template<class BaseType, class T>
+            iter_type get_integral_(iter_type in, iter_type end, ios_base& base,
+                                    ios_base::iostate& err, T& v) const
+            {
+                BaseType res{};
+                unsigned int num_base{10};
+
+                auto basefield = (base.flags() & ios_base::basefield);
+                if (basefield == ios_base::oct)
+                    num_base = 8;
+                else if (basefield == ios_base::hex)
+                    num_base = 16;
+
+                auto size = fill_buffer_integral_(in, end, base);
+                if (size > 0)
+                {
+                    int ret{};
+                    if constexpr (is_signed<BaseType>::value)
+                        ret = std::hel::str_int64_t(base.buffer_, nullptr, num_base, false, &res);
+                    else
+                        ret = std::hel::str_uint64_t(base.buffer_, nullptr, num_base, false, &res);
+
+                    if (ret != EOK)
+                    {
+                        err |= ios_base::failbit;
+                        v = 0;
+                    }
+                    else if (res > static_cast<BaseType>(numeric_limits<T>::max()))
+                    {
+                        err |= ios_base::failbit;
+                        v = numeric_limits<T>::max();
+                    }
+                    else if (res < static_cast<BaseType>(numeric_limits<T>::min()))
+                    {
+                        err |= ios_base::failbit;
+                        v = numeric_limits<T>::min();
+                    }
+                    else
+                        v = static_cast<T>(res);
+                }
+                else
+                {
+                    err |= ios_base::failbit;
+                    v = 0;
+                }
+
+                return in;
+            }
+
+            size_t fill_buffer_integral_(iter_type& in, iter_type end, ios_base& base) const
+            {
+                if (in == end)
+                    return 0;
+
+                auto loc = base.getloc();
+                const auto& ct = use_facet<ctype<char_type>>(loc);
+                auto hex = ((base.flags() & ios_base::hex) != 0);
+
+                size_t i{};
+                if (*in == '+' || *in == '-')
+                    base.buffer_[i++] = *in++;
+
+                while (in != end && i < ios_base::buffer_size_ - 1)
+                {
+                    auto c = *in;
+                    if (ct.is(ctype_base::digit, c) || (hex &&
+                       ((c >= ct.widen('A') && c <= ct.widen('F')) ||
+                        (c >= ct.widen('a') && c <= ct.widen('f')))))
+                    {
+                        ++in;
+                        base.buffer_[i++] = c;
+                    }
+                    else
+                        break;
+                }
+                base.buffer_[i] = char_type{};
+
+                return i;
+            }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/locale/num_put.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/locale/num_put.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/locale/num_put.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_LOCALE_NUM_PUT
+#define LIBCPP_BITS_LOCALE_NUM_PUT
+
+#include <__bits/locale.hpp>
+#include <__bits/locale/numpunct.hpp>
+#include <ios>
+#include <iterator>
+
+namespace std
+{
+    /**
+     * 22.4.2.2, class template num_put:
+     */
+
+    template<class Char, class OutputIterator = ostreambuf_iterator<Char>>
+    class num_put: public locale::facet
+    {
+        public:
+            using char_type = Char;
+            using iter_type = OutputIterator;
+
+            explicit num_put(size_t refs = 0)
+            { /* DUMMY BODY */ }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, bool v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, long v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, long long v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, unsigned long v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, unsigned long long v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, double v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, long double v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            iter_type put(iter_type it, ios_base& base, char_type fill, const void* v) const
+            {
+                return do_put(it, base, fill, v);
+            }
+
+            ~num_put()
+            { /* DUMMY BODY */ }
+
+        protected:
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, bool v) const
+            {
+                auto loc = base.getloc();
+
+                if ((base.flags() & ios_base::boolalpha) == 0)
+                    return do_put(it, base, fill, (long)v);
+                else
+                {
+                    auto s = v ? use_facet<numpunct<char_type>>(loc).truename()
+                               : use_facet<numpunct<char_type>>(loc).falsename();
+                    for (auto c: s)
+                        *it++ = c;
+                }
+
+                return it;
+            }
+
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, long v) const
+            {
+                auto basefield = (base.flags() & ios_base::basefield);
+                auto uppercase = (base.flags() & ios_base::uppercase);
+
+                int ret{};
+                if (basefield == ios_base::oct)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lo", v);
+                else if ((basefield == ios_base::hex) && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lx", v);
+                else if (basefield == ios_base::hex)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lX", v);
+                else
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%ld", v);
+
+                return put_adjusted_buffer_(it, base, fill, ret);
+            }
+
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, long long v) const
+            {
+                auto basefield = (base.flags() & ios_base::basefield);
+                auto uppercase = (base.flags() & ios_base::uppercase);
+
+                int ret{};
+                if (basefield == ios_base::oct)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llo", v);
+                else if ((basefield == ios_base::hex) && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llx", v);
+                else if (basefield == ios_base::hex)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llX", v);
+                else
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lld", v);
+
+                return put_adjusted_buffer_(it, base, fill, ret);
+            }
+
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, unsigned long v) const
+            {
+                auto basefield = (base.flags() & ios_base::basefield);
+                auto uppercase = (base.flags() & ios_base::uppercase);
+
+                int ret{};
+                if (basefield == ios_base::oct)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lo", v);
+                else if ((basefield == ios_base::hex) && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lx", v);
+                else if (basefield == ios_base::hex)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lX", v);
+                else
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lu", v);
+
+                return put_adjusted_buffer_(it, base, fill, ret);
+            }
+
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, unsigned long long v) const
+            {
+                auto basefield = (base.flags() & ios_base::basefield);
+                auto uppercase = (base.flags() & ios_base::uppercase);
+
+                // TODO: showbase
+                int ret{};
+                if (basefield == ios_base::oct)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llo", v);
+                else if ((basefield == ios_base::hex) && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llx", v);
+                else if (basefield == ios_base::hex)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llX", v);
+                else
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llu", v);
+
+                return put_adjusted_buffer_(it, base, fill, ret);
+            }
+
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, double v) const
+            {
+                auto floatfield = (base.flags() & ios_base::floatfield);
+                auto uppercase = (base.flags() & ios_base::uppercase);
+
+                // TODO: showbase
+                // TODO: precision
+                int ret{};
+                if (floatfield == ios_base::fixed)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%f", v);
+                else if (floatfield == ios_base::scientific && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%e", v);
+                else if (floatfield == ios_base::scientific)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%E", v);
+                else if (floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%a", v);
+                else if (floatfield == (ios_base::fixed | ios_base::scientific))
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%A", v);
+                else if (!uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%g", v);
+                else
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%G", v);
+
+                return put_adjusted_buffer_(it, base, fill, ret);
+            }
+
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, long double v) const
+            {
+                /**
+                 * Note: Long double is not support at the moment in snprintf.
+                 */
+                auto floatfield = (base.flags() & ios_base::floatfield);
+                auto uppercase = (base.flags() & ios_base::uppercase);
+
+                // TODO: showbase
+                // TODO: precision
+                int ret{};
+                if (floatfield == ios_base::fixed)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%Lf", v);
+                else if (floatfield == ios_base::scientific && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%Le", v);
+                else if (floatfield == ios_base::scientific)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%LE", v);
+                else if (floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%La", v);
+                else if (floatfield == (ios_base::fixed | ios_base::scientific))
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%LA", v);
+                else if (!uppercase)
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%Lg", v);
+                else
+                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%LG", v);
+
+                return put_adjusted_buffer_(it, base, fill, ret);
+            }
+
+            iter_type do_put(iter_type it, ios_base& base, char_type fill, const void* v) const
+            {
+                int ret = snprintf(base.buffer_, ios_base::buffer_size_, "%p", v);
+
+                return put_adjusted_buffer_(it, base, fill, ret);
+            }
+
+        private:
+            iter_type put_adjusted_buffer_(iter_type it, ios_base& base, char_type fill, size_t size) const
+            {
+                auto adjustfield = (base.flags() & ios_base::adjustfield);
+
+                size_t to_fill{};
+                size_t width = static_cast<size_t>(base.width());
+
+                if (base.width() > 0 && size < width)
+                    to_fill = width - size;
+
+                if (to_fill > 0)
+                {
+                    if (adjustfield == ios_base::left)
+                    {
+                        it = put_buffer_(it, base, fill, 0, size);
+                        for (size_t i = 0; i < to_fill; ++i)
+                            *it++ = fill;
+                    }
+                    else if (adjustfield == ios_base::right)
+                    {
+                        for (size_t i = 0; i < to_fill; ++i)
+                            *it++ = fill;
+                        it = put_buffer_(it, base, fill, 0, size);
+                    }
+                    else if (adjustfield == ios_base::internal)
+                    {
+                        // TODO: pad after - or 0x/0X
+                    }
+                    else
+                    {
+                        for (size_t i = 0; i < to_fill; ++i)
+                            *it++ = fill;
+                        it = put_buffer_(it, base, fill, 0, size);
+                    }
+                }
+                else
+                    it = put_buffer_(it, base, fill, 0, size);
+                base.width(0);
+
+                return it;
+            }
+
+            iter_type put_buffer_(iter_type it, ios_base& base, char_type fill, size_t start, size_t size) const
+            {
+                const auto& loc = base.getloc();
+                const auto& ct = use_facet<ctype<char_type>>(loc);
+                const auto& punct = use_facet<numpunct<char_type>>(loc);
+
+                for (size_t i = start; i < size; ++i)
+                {
+                    if (base.buffer_[i] == '.')
+                        *it++ = punct.decimal_point();
+                    else
+                        *it++ = ct.widen(base.buffer_[i]);
+                    // TODO: Should do grouping & thousands_sep, but that's a low
+                    //       priority for now.
+                }
+
+                return it;
+            }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/locale/numpunct.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/locale/numpunct.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/locale/numpunct.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_LOCALE_NUMPUNCT
+#define LIBCPP_BITS_LOCALE_NUMPUNCT
+
+#include <__bits/locale.hpp>
+#include <string>
+
+namespace std
+{
+    /**
+     * 22.4.3.1, class template numpunct:
+     */
+
+    template<class Char>
+    class numpunct: public locale::facet
+    {
+        public:
+            using char_type   = Char;
+            using string_type = basic_string<Char>;
+
+            explicit numpunct(size_t refs = 0);
+
+            char_type decimal_point() const
+            {
+                return do_decimal_point();
+            }
+
+            char_type thousands_sep() const
+            {
+                return do_thousands_sep();
+            }
+
+            string_type grouping() const
+            {
+                return do_grouping();
+            }
+
+            string_type truename() const
+            {
+                return do_truename();
+            }
+
+            string_type falsename() const
+            {
+                return do_falsename();
+            }
+
+            ~numpunct();
+
+        protected:
+            char_type do_decimal_point() const;
+            char_type do_thousands_sep() const;
+            string_type do_grouping() const;
+            string_type do_truename() const;
+            string_type do_falsename() const;
+    };
+
+    template<>
+    class numpunct<char>: public locale::facet
+    {
+        public:
+            using char_type   = char;
+            using string_type = basic_string<char>;
+
+            explicit numpunct(size_t refs = 0)
+            { /* DUMMY BODY */ }
+
+            char_type decimal_point() const
+            {
+                return do_decimal_point();
+            }
+
+            char_type thousands_sep() const
+            {
+                return do_thousands_sep();
+            }
+
+            string_type grouping() const
+            {
+                return do_grouping();
+            }
+
+            string_type truename() const
+            {
+                return do_truename();
+            }
+
+            string_type falsename() const
+            {
+                return do_falsename();
+            }
+
+            ~numpunct()
+            { /* DUMMY BODY */ }
+
+        protected:
+            char_type do_decimal_point() const
+            {
+                return '.';
+            }
+
+            char_type do_thousands_sep() const
+            {
+                return ',';
+            }
+
+            string_type do_grouping() const
+            {
+                return "";
+            }
+
+            string_type do_truename() const
+            {
+                return "true";
+            }
+
+            string_type do_falsename() const
+            {
+                return "false";
+            }
+    };
+
+    template<>
+    class numpunct<wchar_t>: public locale::facet
+    {
+        public:
+            using char_type   = wchar_t;
+            using string_type = basic_string<wchar_t>;
+
+            explicit numpunct(size_t refs = 0);
+
+            char_type decimal_point() const
+            {
+                return do_decimal_point();
+            }
+
+            char_type thousands_sep() const
+            {
+                return do_thousands_sep();
+            }
+
+            string_type grouping() const
+            {
+                return do_grouping();
+            }
+
+            string_type truename() const
+            {
+                return do_truename();
+            }
+
+            string_type falsename() const
+            {
+                return do_falsename();
+            }
+
+            ~numpunct();
+
+        protected:
+            char_type do_decimal_point() const
+            {
+                return L'.';
+            }
+
+            char_type do_thousands_sep() const
+            {
+                return L',';
+            }
+
+            string_type do_grouping() const
+            {
+                return L"";
+            }
+
+            string_type do_truename() const
+            {
+                return L"true";
+            }
+
+            string_type do_falsename() const
+            {
+                return L"false";
+            }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/addressof.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/addressof.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/addressof.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_ADDRESSOF
+#define LIBCPP_BITS_MEMORY_ADDRESSOF
+
+namespace std
+{
+    /**
+     * 20.7.12, specialized algorithms:
+     */
+
+    template<class T>
+    T* addressof(T& x) noexcept
+    {
+        return reinterpret_cast<T*>(
+            &const_cast<char&>(
+                reinterpret_cast<const volatile char&>(x)
+        ));
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/allocator_arg.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/allocator_arg.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/allocator_arg.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_ALLOCATOR_ARG
+#define LIBCPP_BITS_MEMORY_ALLOCATOR_ARG
+
+namespace std
+{
+    /**
+     * 20.7.6, allocator argument tag:
+     */
+
+    struct allocator_arg_t
+    { /* DUMMY BODY */ };
+
+    constexpr allocator_arg_t allocator_arg{};
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/allocator_traits.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/allocator_traits.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/allocator_traits.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,255 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_ALLOCATOR_TRAITS
+#define LIBCPP_BITS_MEMORY_ALLOCATOR_TRAITS
+
+#include <cstddef>
+#include <__bits/aux.hpp>
+#include <__bits/memory/addressof.hpp>
+#include <__bits/memory/pointer_traits.hpp>
+#include <__bits/memory/type_getters.hpp>
+#include <limits>
+#include <type_traits>
+
+namespace std
+{
+    /**
+     * 20.7.7, uses_allocator:
+     */
+
+    namespace aux
+    {
+        template<class T, class = void>
+        struct has_allocator_type: false_type
+        { /* DUMMY BODY */ };
+
+        template<class T>
+        struct has_allocator_type<T, void_t<typename T::allocator_type>>
+            : true_type
+        { /* DUMMY BODY */ };
+    }
+
+    template<class T, class Alloc>
+    struct uses_allocator
+        : aux::value_is<
+        bool, aux::has_allocator_type<T>::value && is_convertible_v<
+            Alloc, typename T::allocator_type
+        >
+    >
+    { /* DUMMY BODY */ };
+
+    /**
+     * 20.7.8, allocator traits:
+     */
+
+    template<class Alloc>
+    struct allocator_traits
+    {
+        using allocator_type = Alloc;
+
+        using value_type         = typename Alloc::value_type;
+        using pointer            = typename aux::alloc_get_pointer<Alloc>::type;
+        using const_pointer      = typename aux::alloc_get_const_pointer<Alloc, pointer>::type;
+        using void_pointer       = typename aux::alloc_get_void_pointer<Alloc, pointer>::type;
+        using const_void_pointer = typename aux::alloc_get_const_void_pointer<Alloc, pointer>::type;
+        using difference_type    = typename aux::alloc_get_difference_type<Alloc, pointer>::type;
+        using size_type          = typename aux::alloc_get_size_type<Alloc, difference_type>::type;
+
+        using propagate_on_container_copy_assignment = typename aux::alloc_get_copy_propagate<Alloc>::type;
+        using propagate_on_container_move_assignment = typename aux::alloc_get_move_propagate<Alloc>::type;
+        using propagate_on_container_swap            = typename aux::alloc_get_swap_propagate<Alloc>::type;
+        using is_always_equal                        = typename aux::alloc_get_always_equal<Alloc>::type;
+
+        template<class T>
+        using rebind_alloc = typename aux::alloc_get_rebind_alloc<Alloc, T>;
+
+        template<class T>
+        using rebind_traits = allocator_traits<rebind_alloc<T>>;
+
+        static pointer allocate(Alloc& alloc, size_type n)
+        {
+            return alloc.allocate(n);
+        }
+
+        static pointer allocate(Alloc& alloc, size_type n, const_void_pointer hint)
+        {
+            if constexpr (aux::alloc_has_hint_allocate<Alloc, size_type, const_void_pointer>::value)
+                return alloc.allocate(n, hint);
+            else
+                return alloc.allocate(n);
+        }
+
+        static void deallocate(Alloc& alloc, pointer ptr, size_type n)
+        {
+            alloc.deallocate(ptr, n);
+        }
+
+        template<class T, class... Args>
+        static void construct(Alloc& alloc, T* ptr, Args&&... args)
+        {
+            if constexpr (aux::alloc_has_construct<Alloc, T, Args...>::value)
+                alloc.construct(ptr, forward<Args>(args)...);
+            else
+                ::new(static_cast<void*>(ptr)) T(forward<Args>(args)...);
+        }
+
+        template<class T>
+        static void destroy(Alloc& alloc, T* ptr)
+        {
+            if constexpr (aux::alloc_has_destroy<Alloc, T>::value)
+                alloc.destroy(ptr);
+            else
+                ptr->~T();
+        }
+
+        static size_type max_size(const Alloc& alloc) noexcept
+        {
+            if constexpr (aux::alloc_has_max_size<Alloc>::value)
+                return alloc.max_size();
+            else
+                return numeric_limits<size_type>::max();
+        }
+
+        static Alloc select_on_container_copy_construction(const Alloc& alloc)
+        {
+            if constexpr (aux::alloc_has_select<Alloc>::value)
+                return alloc.select_on_container_copy_construction();
+            else
+                return alloc;
+        }
+    };
+
+    /**
+     * 20.7.9, the default allocator
+     */
+
+    template<class T>
+    class allocator;
+
+    template<>
+    class allocator<void>
+    {
+        public:
+            using pointer       = void*;
+            using const_pointer = const void*;
+            using value_type    = void;
+
+            template<class U>
+            struct rebind
+            {
+                using other = allocator<U>;
+            };
+    };
+
+    template<class T>
+    T* addressof(T& x) noexcept;
+
+    template<class T>
+    class allocator
+    {
+        public:
+            using size_type       = size_t;
+            using difference_type = ptrdiff_t;
+            using pointer         = T*;
+            using const_pointer   = const T*;
+            using reference       = T&;
+            using const_reference = const T&;
+            using value_type      = T;
+
+            template<class U>
+            struct rebind
+            {
+                using other = allocator<U>;
+            };
+
+            using propagate_on_container_move_assignment = true_type;
+            using is_always_equal                        = true_type;
+
+            allocator() noexcept = default;
+
+            allocator(const allocator&) noexcept = default;
+
+            template<class U>
+            allocator(const allocator<U>&) noexcept
+            { /* DUMMY BODY */ }
+
+            ~allocator() = default;
+
+            pointer address(reference x) const noexcept
+            {
+                return addressof(x);
+            }
+
+            const_pointer address(const_reference x) const noexcept
+            {
+                return addressof(x);
+            }
+
+            pointer allocate(size_type n, allocator<void>::const_pointer = 0)
+            {
+                return static_cast<pointer>(::operator new(n * sizeof(value_type)));
+            }
+
+            void deallocate(pointer ptr, size_type n)
+            {
+                ::operator delete(ptr, n);
+            }
+
+            size_type max_size() const noexcept
+            {
+                return numeric_limits<size_type>::max();
+            }
+
+            template<class U, class... Args>
+            void construct(U* ptr, Args&&... args)
+            {
+                ::new((void*)ptr) U(forward<Args>(args)...);
+            }
+
+            template<class U>
+            void destroy(U* ptr)
+            {
+                ptr->~U();
+            }
+    };
+
+    template<class T1, class T2>
+    bool operator==(const allocator<T1>&, const allocator<T2>&) noexcept
+    {
+        return true;
+    }
+
+    template<class T1, class T2>
+    bool operator!=(const allocator<T1>&, const allocator<T2>&) noexcept
+    {
+        return false;
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/misc.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/misc.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/misc.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_MISC
+#define LIBCPP_BITS_MEMORY_MISC
+
+#include <cstdlib>
+#include <iterator>
+#include <new>
+#include <utility>
+
+namespace std
+{
+    /**
+     * 20.7.10, raw storage iterator:
+     */
+
+    template<class OutputIterator, class T>
+    class raw_storage_iterator: public iterator<output_iterator_tag, void, void, void, void>
+    {
+        public:
+            explicit raw_storage_iterator(OutputIterator it)
+                : it_{it}
+            { /* DUMMY BODY */ }
+
+            raw_storage_iterator& operator*()
+            {
+                return *this;
+            }
+
+            raw_storage_iterator& operator=(const T& element)
+            {
+                new(it_) T{element};
+
+                return *this;
+            }
+
+            raw_storage_iterator& operator++()
+            {
+                ++it_;
+
+                return *this;
+            }
+
+            raw_storage_iterator operator++(int)
+            {
+                return raw_storage_iterator{it_++};
+            }
+
+        private:
+            OutputIterator it_;
+    };
+
+    /**
+     * 20.7.11, temporary buffers:
+     */
+
+    template<class T>
+    pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept
+    {
+        T* res{};
+
+        while (n > 0)
+        {
+            res = (T*)malloc(n * sizeof(T));
+
+            if (res)
+                return make_pair(res, n);
+
+            --n;
+        }
+
+        return make_pair(nullptr, ptrdiff_t{});
+    }
+
+    template<class T>
+    void return_temporary_buffer(T* ptr)
+    {
+        free(ptr);
+    }
+
+    /**
+     * 20.7.12, specialized algorithms:
+     */
+
+    template<class Iterator>
+    struct iterator_traits;
+
+    template<class InputIterator, class ForwardIterator>
+    ForwardIterator unitialized_copy(
+        InputIterator first, InputIterator last,
+        ForwardIterator result
+    )
+    {
+        for (; first != last; ++first, ++result)
+            ::new (static_cast<void*>(&*result)) typename iterator_traits<ForwardIterator>::value_type(*first);
+
+        return result;
+    }
+
+    template<class InputIterator, class Size, class ForwardIterator>
+    ForwardIterator unitialized_copy_n(
+        InputIterator first, Size n, ForwardIterator result
+    )
+    {
+        for (; n > 0; ++first, --n, ++result)
+            ::new (static_cast<void*>(&*result)) typename iterator_traits<ForwardIterator>::value_type(*first);
+
+        return result;
+    }
+
+    template<class ForwardIterator, class T>
+    void unitialized_fill(
+        ForwardIterator first, ForwardIterator last, const T& x
+    )
+    {
+        for (; first != last; ++first)
+            ::new (static_cast<void*>(&*first)) typename iterator_traits<ForwardIterator>::value_type(x);
+    }
+
+    template<class ForwardIterator, class Size, class T>
+    ForwardIterator unitialized_fill_n(
+        ForwardIterator first, Size n, const T& x
+    )
+    {
+        for (; n > 0; ++first, --n)
+            ::new (static_cast<void*>(&*first)) typename iterator_traits<ForwardIterator>::value_type(x);
+
+        return first;
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/owner_less.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/owner_less.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/owner_less.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_OWNER_LESS
+#define LIBCPP_BITS_MEMORY_OWNER_LESS
+
+#include <__bits/memory/shared_ptr.hpp>
+#include <__bits/memory/weak_ptr.hpp>
+
+namespace std
+{
+    /**
+     * 20.8.2.4, class template owner_less:
+     */
+
+    template<class>
+    struct owner_less;
+
+    template<class T>
+    struct owner_less<shared_ptr<T>>
+    {
+        using retult_type          = bool;
+        using first_argument_type  = shared_ptr<T>;
+        using second_argument_type = shared_ptr<T>;
+
+        bool operator()(const shared_ptr<T>& lhs, const shared_ptr<T>& rhs) const
+        {
+            return lhs.owner_before(rhs);
+        }
+
+        bool operator()(const shared_ptr<T>& lhs, const weak_ptr<T>& rhs) const
+        {
+            return lhs.owner_before(rhs);
+        }
+
+        bool operator()(const weak_ptr<T>& lhs, const shared_ptr<T>& rhs) const
+        {
+            return lhs.owner_before(rhs);
+        }
+    };
+
+    template<class T>
+    struct owner_less<weak_ptr<T>>
+    {
+        using retult_type          = bool;
+        using first_argument_type  = weak_ptr<T>;
+        using second_argument_type = weak_ptr<T>;
+
+        bool operator()(const weak_ptr<T>& lhs, const weak_ptr<T>& rhs) const
+        {
+            return lhs.owner_before(rhs);
+        }
+
+        bool operator()(const shared_ptr<T>& lhs, const weak_ptr<T>& rhs) const
+        {
+            return lhs.owner_before(rhs);
+        }
+
+        bool operator()(const weak_ptr<T>& lhs, const shared_ptr<T>& rhs) const
+        {
+            return lhs.owner_before(rhs);
+        }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/pointer_traits.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/pointer_traits.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/pointer_traits.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_POINTER_TRAITS
+#define LIBCPP_BITS_MEMORY_POINTER_TRAITS
+
+#include <cstddef>
+#include <__bits/memory/addressof.hpp>
+#include <__bits/memory/type_getters.hpp>
+#include <type_traits>
+
+namespace std
+{
+    /**
+     * 20.7.3, pointer traits:
+     */
+
+    template<class Ptr>
+    struct pointer_traits
+    {
+        using pointer         = Ptr;
+        using element_type    = typename aux::ptr_get_element_type<Ptr>::type;
+        using difference_type = typename aux::ptr_get_difference_type<Ptr>::type;
+
+        template<class U>
+        using rebind = typename aux::ptr_get_rebind<Ptr, U>::type;
+
+        static pointer pointer_to( // If is_void_t<element_type>, this type is unspecified.
+            conditional_t<is_void_v<element_type>, char, element_type&> x
+        )
+        {
+            return Ptr::pointer_to(x);
+        }
+    };
+
+    template<class T>
+    struct pointer_traits<T*>
+    {
+        using pointer         = T*;
+        using element_type    = T;
+        using difference_type = ptrdiff_t;
+
+        template<class U>
+        using rebind = U*;
+
+        static pointer pointer_to(
+            conditional_t<is_void_v<element_type>, char, element_type&> x
+        )
+        {
+            return std::addressof(x);
+        }
+    };
+
+    /**
+     * 20.7.4, pointer safety:
+     */
+
+    // TODO: implement
+
+    /**
+     * 20.7.5, align:
+     */
+
+    // TODO: implement
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/shared_payload.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/shared_payload.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/shared_payload.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_SHARED_PAYLOAD
+#define LIBCPP_BITS_MEMORY_SHARED_PAYLOAD
+
+#include <cinttypes>
+#include <utility>
+
+namespace std
+{
+    template<class>
+    struct default_delete;
+
+    struct allocator_arg_t;
+}
+
+namespace std::aux
+{
+    /**
+     * At the moment we do not have atomics, change this
+     * to std::atomic<long> once we do.
+     */
+    using refcount_t = long;
+
+    /**
+     * This allows us to construct shared_ptr from
+     * a payload pointer in make_shared etc.
+     */
+    struct payload_tag_t
+    { /* DUMMY BODY */ };
+
+    inline constexpr payload_tag_t payload_tag{};
+
+    template<class D, class T>
+    void use_payload_deleter(D* deleter, T* data)
+    {
+        if (deleter)
+            (*deleter)(data);
+    }
+
+    template<class T>
+    class shared_payload_base
+    {
+        public:
+            virtual void destroy() = 0;
+            virtual T* get() const noexcept = 0;
+
+            virtual uint8_t* deleter() const noexcept = 0;
+
+            virtual void increment() noexcept = 0;
+            virtual void increment_weak() noexcept = 0;
+            virtual bool decrement() noexcept = 0;
+            virtual bool decrement_weak() noexcept = 0;
+            virtual refcount_t refs() const noexcept = 0;
+            virtual refcount_t weak_refs() const noexcept = 0;
+            virtual bool expired() const noexcept = 0;
+            virtual shared_payload_base* lock() noexcept = 0;
+
+            virtual ~shared_payload_base() = default;
+    };
+
+    template<class T, class D = default_delete<T>>
+    class shared_payload: public shared_payload_base<T>
+    {
+        public:
+            shared_payload(T* ptr, D deleter = D{})
+                : data_{ptr}, deleter_{deleter},
+                  refcount_{1}, weak_refcount_{1}
+            { /* DUMMY BODY */ }
+
+            template<class... Args>
+            shared_payload(Args&&... args)
+                : data_{new T{forward<Args>(args)...}},
+                  deleter_{}, refcount_{1}, weak_refcount_{1}
+            { /* DUMMY BODY */ }
+
+            template<class Alloc, class... Args>
+            shared_payload(allocator_arg_t, Alloc alloc, Args&&... args)
+                : data_{alloc.allocate(1)},
+                  deleter_{}, refcount_{1}, weak_refcount_{1}
+            {
+                alloc.construct(data_, forward<Args>(args)...);
+            }
+
+            template<class Alloc, class... Args>
+            shared_payload(D deleter, Alloc alloc, Args&&... args)
+                : data_{alloc.allocate(1)},
+                  deleter_{deleter}, refcount_{1}, weak_refcount_{1}
+            {
+                alloc.construct(data_, forward<Args>(args)...);
+            }
+
+            void destroy() override
+            {
+                if (refs() == 0)
+                {
+                    if (data_)
+                    {
+                        deleter_(data_);
+                        data_ = nullptr;
+                    }
+
+                    if (weak_refs() == 0)
+                        delete this;
+                }
+            }
+
+            T* get() const noexcept override
+            {
+                return data_;
+            }
+
+            uint8_t* deleter() const noexcept override
+            {
+                return (uint8_t*)&deleter_;
+            }
+
+            void increment() noexcept override
+            {
+                __atomic_add_fetch(&refcount_, 1, __ATOMIC_ACQ_REL);
+            }
+
+            void increment_weak() noexcept override
+            {
+                __atomic_add_fetch(&weak_refcount_, 1, __ATOMIC_ACQ_REL);
+            }
+
+            bool decrement() noexcept override
+            {
+                if (__atomic_sub_fetch(&refcount_, 1, __ATOMIC_ACQ_REL) == 0)
+                {
+                    /**
+                     * First call to destroy() will delete the held object,
+                     * so it doesn't matter what the weak_refcount_ is,
+                     * but we added one and we need to remove it now.
+                     */
+                    decrement_weak();
+
+                    return true;
+                }
+                else
+                    return false;
+            }
+
+            bool decrement_weak() noexcept override
+            {
+                return __atomic_sub_fetch(&weak_refcount_, 1, __ATOMIC_ACQ_REL) == 0 && refs() == 0;
+            }
+
+            refcount_t refs() const noexcept override
+            {
+                return __atomic_load_n(&refcount_, __ATOMIC_RELAXED);
+            }
+
+            refcount_t weak_refs() const noexcept override
+            {
+                return __atomic_load_n(&weak_refcount_, __ATOMIC_RELAXED);
+            }
+
+            bool expired() const noexcept override
+            {
+                return refs() == 0;
+            }
+
+            shared_payload_base<T>* lock() noexcept override
+            {
+                refcount_t rfs = refs();
+                while (rfs != 0L)
+                {
+                    if (__atomic_compare_exchange_n(&refcount_, &rfs, rfs + 1,
+                                                    true, __ATOMIC_RELAXED,
+                                                    __ATOMIC_RELAXED))
+                    {
+                        return this;
+                    }
+                }
+
+                return nullptr;
+            }
+
+        private:
+            T* data_;
+            D deleter_;
+
+            /**
+             * We're using a trick where refcount_ > 0
+             * means weak_refcount_ has 1 added to it,
+             * this makes it easier for weak_ptrs that
+             * can't decrement the weak_refcount_ to
+             * zero with shared_ptrs using this object.
+             */
+            refcount_t refcount_;
+            refcount_t weak_refcount_;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/shared_ptr.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/shared_ptr.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/shared_ptr.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,646 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_SHARED_PTR
+#define LIBCPP_BITS_MEMORY_SHARED_PTR
+
+#include <exception>
+#include <__bits/functional/arithmetic_operations.hpp>
+#include <__bits/functional/hash.hpp>
+#include <__bits/memory/allocator_arg.hpp>
+#include <__bits/memory/shared_payload.hpp>
+#include <__bits/memory/unique_ptr.hpp>
+#include <__bits/trycatch.hpp>
+#include <type_traits>
+
+namespace std
+{
+    template<class T>
+    class weak_ptr;
+
+    /**
+     * 20.8.2.1, class bad_weak_ptr:
+     */
+
+    class bad_weak_ptr: public exception
+    {
+        public:
+            bad_weak_ptr() noexcept = default;
+
+            const char* what() const noexcept override
+            {
+                return "std::bad_weak_ptr";
+            }
+    };
+
+    /**
+     * 20.8.2.2, class template shared_ptr:
+     */
+
+    template<class T>
+    class shared_ptr
+    {
+        public:
+            using element_type = T;
+
+            /**
+             * 20.8.2.2.1, constructors:
+             */
+
+            constexpr shared_ptr() noexcept
+                : payload_{}, data_{}
+            { /* DUMMY BODY */ }
+
+            template<class U>
+            explicit shared_ptr(
+                U* ptr,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            )
+                : payload_{}, data_{ptr}
+            {
+                try
+                {
+                    payload_ = new aux::shared_payload<T>{ptr};
+                }
+                catch (const bad_alloc&)
+                {
+                    delete ptr;
+
+                    throw;
+                }
+            }
+
+            template<class U, class D>
+            shared_ptr(
+                U* ptr, D deleter,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            )
+                : shared_ptr{}
+            {
+                try
+                {
+                    payload_ = new aux::shared_payload<T, D>{ptr, deleter};
+                }
+                catch (const bad_alloc&)
+                {
+                    deleter(ptr);
+
+                    throw;
+                }
+            }
+
+            template<class U, class D, class A>
+            shared_ptr(
+                U* ptr, D deleter, A,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            )
+                : shared_ptr{}
+            {
+                try
+                {
+                    payload_ = new aux::shared_payload<T, D>{ptr, deleter};
+                }
+                catch (const bad_alloc&)
+                {
+                    deleter(ptr);
+
+                    throw;
+                }
+            }
+
+            template<class D>
+            shared_ptr(nullptr_t ptr, D deleter)
+                : shared_ptr{}
+            { /* DUMMY BODY */ }
+
+            template<class D, class A>
+            shared_ptr(nullptr_t, D deleter, A)
+                : shared_ptr{}
+            { /* DUMMY BODY */ }
+
+            template<class U>
+            shared_ptr(
+                const shared_ptr<U>& other, element_type* ptr,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            )
+                : payload_{other.payload_}, data_{ptr}
+            {
+                if (payload_)
+                    payload_->increment();
+            }
+
+            shared_ptr(const shared_ptr& other)
+                : payload_{other.payload_}, data_{other.data_}
+            {
+                if (payload_)
+                    payload_->increment();
+            }
+
+            template<class U>
+            shared_ptr(
+                const shared_ptr<U>& other,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            )
+                : payload_{other.payload_}, data_{other.data_}
+            {
+                if (payload_)
+                    payload_->increment();
+            }
+
+            shared_ptr(shared_ptr&& other)
+                : payload_{move(other.payload_)}, data_{move(other.data_)}
+            {
+                other.payload_ = nullptr;
+                other.data_ = nullptr;
+            }
+
+            template<class U>
+            shared_ptr(
+                shared_ptr<U>&& other,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            )
+                : payload_{move(other.payload_)}, data_{move(other.data_)}
+            {
+                other.payload_ = nullptr;
+                other.data_ = nullptr;
+            }
+
+            template<class U>
+            explicit shared_ptr(
+                const weak_ptr<U>& other,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            )
+                : payload_{}, data_{}
+            {
+                if (other.expired())
+                    throw bad_weak_ptr{};
+
+                if (other.payload_)
+                {
+                    payload_ = other.payload_->lock();
+                    data_ = payload_->get();
+                }
+            }
+
+            template<class U, class D>
+            shared_ptr(
+                unique_ptr<U, D>&& other,
+                enable_if_t<
+                    is_convertible_v<
+                        typename unique_ptr<U, D>::pointer,
+                        element_type*
+                    >
+                >* = nullptr
+            ) // TODO: if D is a reference type, it should be ref(other.get_deleter())
+                : shared_ptr{other.release(), other.get_deleter()}
+            { /* DUMMY BODY */ }
+
+            constexpr shared_ptr(nullptr_t) noexcept
+                : shared_ptr{}
+            { /* DUMMY BODY */ }
+
+            /**
+             * 20.8.2.2.2, destructor:
+             */
+
+            ~shared_ptr()
+            {
+                remove_payload_();
+            }
+
+            /**
+             * 20.8.2.2.3, assignment:
+             */
+
+            shared_ptr& operator=(const shared_ptr& rhs) noexcept
+            {
+                if (rhs.payload_)
+                    rhs.payload_->increment();
+
+                remove_payload_();
+
+                payload_ = rhs.payload_;
+                data_ = rhs.data_;
+
+                return *this;
+            }
+
+            template<class U>
+            enable_if_t<is_convertible_v<U*, element_type*>, shared_ptr>&
+            operator=(const shared_ptr<U>& rhs) noexcept
+            {
+                if (rhs.payload_)
+                    rhs.payload_->increment();
+
+                remove_payload_();
+
+                payload_ = rhs.payload_;
+                data_ = rhs.data_;
+
+                return *this;
+            }
+
+            shared_ptr& operator=(shared_ptr&& rhs) noexcept
+            {
+                shared_ptr{move(rhs)}.swap(*this);
+
+                return *this;
+            }
+
+            template<class U>
+            shared_ptr& operator=(shared_ptr<U>&& rhs) noexcept
+            {
+                shared_ptr{move(rhs)}.swap(*this);
+
+                return *this;
+            }
+
+            template<class U, class D>
+            shared_ptr& operator=(unique_ptr<U, D>&& rhs)
+            {
+                shared_ptr{move(rhs)}.swap(*this);
+
+                return *this;
+            }
+
+            /**
+             * 20.8.2.2.4, modifiers:
+             */
+
+            void swap(shared_ptr& other) noexcept
+            {
+                std::swap(payload_, other.payload_);
+                std::swap(data_, other.data_);
+            }
+
+            void reset() noexcept
+            {
+                shared_ptr{}.swap(*this);
+            }
+
+            template<class U>
+            void reset(U* ptr)
+            {
+                shared_ptr{ptr}.swap(*this);
+            }
+
+            template<class U, class D>
+            void reset(U* ptr, D deleter)
+            {
+                shared_ptr{ptr, deleter}.swap(*this);
+            }
+
+            template<class U, class D, class A>
+            void reset(U* ptr, D deleter, A alloc)
+            {
+                shared_ptr{ptr, deleter, alloc}.swap(*this);
+            }
+
+            /**
+             * 20.8.2.2.5, observers:
+             */
+
+            element_type* get() const noexcept
+            {
+                return data_;
+            }
+
+            enable_if_t<!is_void_v<T>, T&> operator*() const noexcept
+            {
+                return *data_;
+            }
+
+            T* operator->() const noexcept
+            {
+                return get();
+            }
+
+            long use_count() const noexcept
+            {
+                if (payload_)
+                    return payload_->refs();
+                else
+                    return 0L;
+            }
+
+            bool unique() const noexcept
+            {
+                return use_count() == 1L;
+            }
+
+            explicit operator bool() const noexcept
+            {
+                return get() != nullptr;
+            }
+
+            template<class U>
+            bool owner_before(const shared_ptr<U>& ptr) const
+            {
+                return payload_ < ptr.payload_;
+            }
+
+            template<class U>
+            bool owner_before(const weak_ptr<U>& ptr) const
+            {
+                return payload_ < ptr.payload_;
+            }
+
+        private:
+            aux::shared_payload_base<element_type>* payload_;
+            element_type* data_;
+
+            shared_ptr(aux::payload_tag_t, aux::shared_payload_base<element_type>* payload)
+                : payload_{payload}, data_{payload->get()}
+            { /* DUMMY BODY */ }
+
+            void remove_payload_()
+            {
+                if (payload_)
+                {
+                    auto res = payload_->decrement();
+                    if (res)
+                        payload_->destroy();
+
+                    payload_ = nullptr;
+                }
+
+                if (data_)
+                    data_ = nullptr;
+            }
+
+            template<class U, class... Args>
+            friend shared_ptr<U> make_shared(Args&&...);
+
+            template<class U, class A, class... Args>
+            friend shared_ptr<U> allocate_shared(const A&, Args&&...);
+
+            template<class D, class U>
+            D* get_deleter(const shared_ptr<U>&) noexcept;
+
+            template<class U>
+            friend class weak_ptr;
+    };
+
+    /**
+     * 20.8.2.2.6, shared_ptr creation:
+     * Note: According to the standard, these two functions
+     *       should perform at most one memory allocation
+     *       (should, don't have to :P). It might be better
+     *       to create payloads that embed the type T to
+     *       perform this optimization.
+     */
+
+    template<class T, class... Args>
+    shared_ptr<T> make_shared(Args&&... args)
+    {
+        return shared_ptr<T>{
+            aux::payload_tag,
+            new aux::shared_payload<T>{forward<Args>(args)...}
+        };
+    }
+
+    template<class T, class A, class... Args>
+    shared_ptr<T> allocate_shared(const A& alloc, Args&&... args)
+    {
+        return shared_ptr<T>{
+            aux::payload_tag,
+            new aux::shared_payload<T>{allocator_arg, A{alloc}, forward<Args>(args)...}
+        };
+    }
+
+    /**
+     * 20.8.2.2.7, shared_ptr comparisons:
+     */
+
+    template<class T, class U>
+    bool operator==(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
+    {
+        return lhs.get() == rhs.get();
+    }
+
+    template<class T, class U>
+    bool operator!=(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class T, class U>
+    bool operator<(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
+    {
+        return less<common_type_t<T*, U*>>{}(lhs.get(), rhs.get());
+    }
+
+    template<class T, class U>
+    bool operator>(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
+    {
+        return rhs < lhs;
+    }
+
+    template<class T, class U>
+    bool operator<=(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
+    {
+        return !(rhs < lhs);
+    }
+
+    template<class T, class U>
+    bool operator>=(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
+    {
+        return !(lhs < rhs);
+    }
+
+    template<class T>
+    bool operator==(const shared_ptr<T>& lhs, nullptr_t) noexcept
+    {
+        return !lhs;
+    }
+
+    template<class T>
+    bool operator==(nullptr_t, const shared_ptr<T>& rhs) noexcept
+    {
+        return !rhs;
+    }
+
+    template<class T>
+    bool operator!=(const shared_ptr<T>& lhs, nullptr_t) noexcept
+    {
+        return (bool)lhs;
+    }
+
+    template<class T>
+    bool operator!=(nullptr_t, const shared_ptr<T>& rhs) noexcept
+    {
+        return (bool)rhs;
+    }
+
+    template<class T>
+    bool operator<(const shared_ptr<T>& lhs, nullptr_t) noexcept
+    {
+        return less<T*>{}(lhs.get(), nullptr);
+    }
+
+    template<class T>
+    bool operator<(nullptr_t, const shared_ptr<T>& rhs) noexcept
+    {
+        return less<T*>{}(nullptr, rhs.get());
+    }
+
+    template<class T>
+    bool operator>(const shared_ptr<T>& lhs, nullptr_t) noexcept
+    {
+        return nullptr < lhs;
+    }
+
+    template<class T>
+    bool operator>(nullptr_t, const shared_ptr<T>& rhs) noexcept
+    {
+        return rhs < nullptr;
+    }
+
+    template<class T>
+    bool operator<=(const shared_ptr<T>& lhs, nullptr_t) noexcept
+    {
+        return !(nullptr < lhs);
+    }
+
+    template<class T>
+    bool operator<=(nullptr_t, const shared_ptr<T>& rhs) noexcept
+    {
+        return !(rhs < nullptr);
+    }
+
+    template<class T>
+    bool operator>=(const shared_ptr<T>& lhs, nullptr_t) noexcept
+    {
+        return !(lhs < nullptr);
+    }
+
+    template<class T>
+    bool operator>=(nullptr_t, const shared_ptr<T>& rhs) noexcept
+    {
+        return !(nullptr < rhs);
+    }
+
+    /**
+     * 20.8.2.2.8, shared_ptr specialized algorithms:
+     */
+
+    template<class T>
+    void swap(shared_ptr<T>& lhs, shared_ptr<T>& rhs) noexcept
+    {
+        lhs.swap(rhs);
+    }
+
+    /**
+     * 20.8.2.2.9, shared_ptr casts:
+     */
+
+    template<class T, class U>
+    shared_ptr<T> static_pointer_cast(const shared_ptr<U>& ptr) noexcept
+    {
+        if (!ptr)
+            return shared_ptr<T>{};
+
+        return shared_ptr<T>{
+            ptr, static_cast<T*>(ptr.get())
+        };
+    }
+
+    template<class T, class U>
+    shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& ptr) noexcept
+    {
+        if (auto res = dynamic_cast<T*>(ptr.get()))
+            return shared_ptr<T>{ptr, res};
+        else
+            return shared_ptr<T>{};
+    }
+
+    template<class T, class U>
+    shared_ptr<T> const_pointer_cast(const shared_ptr<U>& ptr) noexcept
+    {
+        if (!ptr)
+            return shared_ptr<T>{};
+
+        return shared_ptr<T>{
+            ptr, const_cast<T*>(ptr.get())
+        };
+    }
+
+    /**
+     * 20.8.2.2.10, shared_ptr get_deleter:
+     */
+
+    template<class D, class T>
+    D* get_deleter(const shared_ptr<T>& ptr) noexcept
+    {
+        if (ptr.payload_)
+            return static_cast<D*>(ptr.payload_->deleter());
+        else
+            return nullptr;
+    }
+
+    /**
+     * 20.8.2.2.11, shared_ptr I/O:
+     */
+
+    template<class Char, class Traits, class T>
+    basic_ostream<Char, Traits>& operator<<(basic_ostream<Char, Traits>& os,
+                                            const shared_ptr<T>& ptr)
+    {
+        return os << ptr.get();
+    }
+
+    /**
+     * 20.8.2.5, class template enable_shared_from_this:
+     */
+
+    // TODO: implement
+
+    /**
+     * 20.8.2.6, shared_ptr atomic access
+     */
+
+    // TODO: implement
+
+    /**
+     * 20.8.2.7, smart pointer hash support:
+     */
+
+    template<class T>
+    struct hash<shared_ptr<T>>
+    {
+        size_t operator()(const shared_ptr<T>& ptr) const noexcept
+        {
+            return hash<T*>{}(ptr.get());
+        }
+
+        using argument_type = shared_ptr<T>;
+        using result_type   = size_t;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/type_getters.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/type_getters.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/type_getters.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_TYPE_GETTERS
+#define LIBCPP_BITS_MEMORY_TYPE_GETTERS
+
+/**
+ * Allocator and pointer traits require us to provide
+ * conditional typedefs based on whether the wrapped
+ * allocator contains them or not. To avoid unnecessary
+ * code clutter in <memory>, we moved them to their
+ * separate header (though note that these metafunctions
+ * have no use outside of <memory>).
+ */
+
+#include <cstddef>
+#include <__bits/aux.hpp>
+#include <type_traits>
+
+namespace std
+{
+    template<class T>
+    struct pointer_traits;
+}
+
+namespace std::aux
+{
+    /**
+     * Pointer traits:
+     */
+
+    template<class Ptr, class = void>
+    struct ptr_get_element_type
+    { /* DUMMY BODY */ };
+
+    template<class Ptr>
+    struct ptr_get_element_type<Ptr, void_t<typename Ptr::element_type>>
+        : aux::type_is<typename Ptr::element_type>
+    { /* DUMMY BODY */ };
+
+    template<template <class, class...> class Ptr, class T, class... Args>
+    struct ptr_get_element_type<
+        Ptr<T, Args...>, void_t<typename Ptr<T, Args...>::element_type>
+    >: aux::type_is<typename Ptr<T, Args...>::element_type>
+    { /* DUMMY BODY */ };
+
+    template<class Ptr, class = void>
+    struct ptr_get_difference_type: aux::type_is<ptrdiff_t>
+    { /* DUMMY BODY */ };
+
+    template<class Ptr>
+    struct ptr_get_difference_type<Ptr, void_t<typename Ptr::difference_type>>
+        : aux::type_is<typename Ptr::difference_type>
+    { /* DUMMY BODY */ };
+
+    template<class Ptr, class U, class = void>
+    struct ptr_get_rebind
+    { /* DUMMY BODY */ };
+
+    template<class Ptr, class U>
+    struct ptr_get_rebind<Ptr, U, void_t<typename Ptr::template rebind<U>>>
+        : aux::type_is<typename Ptr::template rebind<U>>
+    { /* DUMMY BODY */ };
+
+    template<template <class, class...> class Ptr, class T, class... Args, class U>
+    struct ptr_get_rebind<Ptr<T, Args...>, U>
+        : aux::type_is<Ptr<U, Args...>>
+    { /* DUMMY BODY */ };
+
+    /**
+     * Allocator traits:
+     */
+
+    template<class T, class = void>
+    struct alloc_get_pointer: aux::type_is<typename T::value_type*>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct alloc_get_pointer<T, void_t<typename T::pointer>>
+        : aux::type_is<typename T::pointer>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr, class = void>
+    struct alloc_get_const_pointer
+        : aux::type_is<typename pointer_traits<Ptr>::template rebind<const typename T::value_type>>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr>
+    struct alloc_get_const_pointer<T, Ptr, void_t<typename T::const_pointer>>
+        : aux::type_is<typename T::const_pointer>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr, class = void>
+    struct alloc_get_void_pointer
+        : aux::type_is<typename pointer_traits<Ptr>::template rebind<void>>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr>
+    struct alloc_get_void_pointer<T, Ptr, void_t<typename T::void_pointer>>
+        : aux::type_is<typename T::void_pointer>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr, class = void>
+    struct alloc_get_const_void_pointer
+        : aux::type_is<typename pointer_traits<Ptr>::template rebind<const void>>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr>
+    struct alloc_get_const_void_pointer<T, Ptr, void_t<typename T::const_void_pointer>>
+        : aux::type_is<typename T::const_void_pointer>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr, class = void>
+    struct alloc_get_difference_type
+        : aux::type_is<typename pointer_traits<Ptr>::difference_type>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Ptr>
+    struct alloc_get_difference_type<T, Ptr, void_t<typename T::difference_type>>
+        : aux::type_is<typename T::difference_type>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Difference, class = void>
+    struct alloc_get_size_type: aux::type_is<make_unsigned_t<Difference>>
+    { /* DUMMY BODY */ };
+
+    template<class T, class Difference>
+    struct alloc_get_size_type<T, Difference, void_t<typename T::size_type>>
+        : aux::type_is<typename T::size_type>
+    { /* DUMMY BODY */ };
+
+    template<class T, class = void>
+    struct alloc_get_copy_propagate: aux::type_is<false_type>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct alloc_get_copy_propagate<T, void_t<typename T::propagate_on_container_copy_assignment>>
+        : aux::type_is<typename T::propagate_on_container_copy_assignment>
+    { /* DUMMY BODY */ };
+
+    template<class T, class = void>
+    struct alloc_get_move_propagate: aux::type_is<false_type>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct alloc_get_move_propagate<T, void_t<typename T::propagate_on_container_move_assignment>>
+        : aux::type_is<typename T::propagate_on_container_move_assignment>
+    { /* DUMMY BODY */ };
+
+    template<class T, class = void>
+    struct alloc_get_swap_propagate: aux::type_is<false_type>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct alloc_get_swap_propagate<T, void_t<typename T::propagate_on_container_swap>>
+        : aux::type_is<typename T::propagate_on_container_swap>
+    { /* DUMMY BODY */ };
+
+    template<class T, class = void>
+    struct alloc_get_always_equal: aux::type_is<typename is_empty<T>::type>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct alloc_get_always_equal<T, void_t<typename T::is_always_equal>>
+        : aux::type_is<typename T::is_always_equal>
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class T, class = void>
+    struct alloc_get_rebind_alloc
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class T>
+    struct alloc_get_rebind_alloc<Alloc, T, void_t<typename Alloc::template rebind<T>::other>>
+        : aux::type_is<typename Alloc::template rebind<T>::other>
+    { /* DUMMY BODY */ };
+
+    template<template <class, class...> class Alloc, class U, class... Args, class T>
+    struct alloc_get_rebind_alloc<Alloc<U, Args...>, T>
+        : aux::type_is<Alloc<T, Args...>>
+    { /* DUMMY BODY */ };
+
+    /**
+     * These metafunctions are used to check whether an expression
+     * is well-formed for the static functions of allocator_traits:
+     */
+
+    template<class Alloc, class Size, class ConstVoidPointer, class = void>
+    struct alloc_has_hint_allocate: false_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class Size, class ConstVoidPointer>
+    struct alloc_has_hint_allocate<
+        Alloc, Size, ConstVoidPointer, void_t<
+            decltype(declval<Alloc>().alloc(declval<Size>(), declval<ConstVoidPointer>()))
+        >
+    >: true_type
+    { /* DUMMY BODY */ };
+
+    template<class, class Alloc, class T, class... Args>
+    struct alloc_has_construct_impl: false_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class T, class... Args>
+    struct alloc_has_construct_impl<
+        void_t<decltype(declval<Alloc>().construct(declval<T*>(), forward<Args>(declval<Args>())...))>,
+        Alloc, T, Args...
+    >: true_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class T, class = void>
+    struct alloc_has_destroy: false_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class T>
+    struct alloc_has_destroy<Alloc, T, void_t<decltype(declval<Alloc>().destroy(declval<T>()))>>
+        : true_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class T, class... Args>
+    struct alloc_has_construct
+        : alloc_has_construct_impl<void_t<>, Alloc, T, Args...>
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class = void>
+    struct alloc_has_max_size: false_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc>
+    struct alloc_has_max_size<Alloc, void_t<decltype(declval<Alloc>().max_size())>>
+        : true_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc, class = void>
+    struct alloc_has_select: false_type
+    { /* DUMMY BODY */ };
+
+    template<class Alloc>
+    struct alloc_has_select<
+        Alloc, void_t<
+            decltype(declval<Alloc>().select_on_container_copy_construction())
+        >
+    >: true_type
+    { /* DUMMY BODY */ };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/unique_ptr.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/unique_ptr.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/unique_ptr.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,649 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_UNIQUE_PTR
+#define LIBCPP_BITS_MEMORY_UNIQUE_PTR
+
+#include <__bits/aux.hpp>
+#include <__bits/functional/hash.hpp>
+#include <type_traits>
+#include <utility>
+
+namespace std
+{
+    /**
+     * 20.8, smart pointers:
+     */
+
+    template<class T>
+    struct default_delete
+    {
+        default_delete() noexcept = default;
+
+        template<class U, class = enable_if_t<is_convertible_v<U*, T*>, void>>
+        default_delete(const default_delete<U>&) noexcept
+        { /* DUMMY BODY */ }
+
+        template<class U>
+        void operator()(U* ptr)
+        {
+            delete ptr;
+        }
+    };
+
+    template<class T>
+    struct default_delete<T[]>
+    {
+        default_delete() noexcept = default;
+
+        template<class U, class = enable_if_t<is_convertible_v<U(*)[], T(*)[]>, void>>
+        default_delete(const default_delete<U[]>&) noexcept
+        { /* DUMMY BODY */ }
+
+        template<class U, class = enable_if_t<is_convertible_v<U(*)[], T(*)[]>, void>>
+        void operator()(U* ptr)
+        {
+            delete[] ptr;
+        }
+    };
+
+    template<class T, class D = default_delete<T>>
+    class unique_ptr;
+
+    namespace aux
+    {
+        template<class P, class D, class = void>
+        struct get_unique_pointer: type_is<typename P::element_type*>
+        { /* DUMMY BODY */ };
+
+        template<class P, class D>
+        struct get_unique_pointer<P, D, void_t<typename remove_reference_t<D>::pointer>>
+            : type_is<typename remove_reference_t<D>::pointer>
+        { /* DUMMY BODY */ };
+    }
+
+    template<class T, class D>
+    class unique_ptr
+    {
+        public:
+            using element_type = T;
+            using deleter_type = D;
+            using pointer      = typename aux::get_unique_pointer<unique_ptr<T, D>, D>::type;
+
+            /**
+             * 20.8.1.2.1, constructors:
+             */
+
+            constexpr unique_ptr() noexcept
+                : ptr_{}, deleter_{}
+            { /* DUMMY BODY */ }
+
+            explicit unique_ptr(pointer ptr) noexcept
+                : ptr_{ptr}, deleter_{}
+            { /* DUMMY BODY */ }
+
+            unique_ptr(pointer ptr, /* TODO */ int d) noexcept;
+
+            unique_ptr(pointer ptr, /* TODO */ char d) noexcept;
+
+            unique_ptr(unique_ptr&& other)
+                : ptr_{move(other.ptr_)}, deleter_{forward<deleter_type>(other.deleter_)}
+            {
+                other.ptr_ = nullptr;
+            }
+
+            constexpr unique_ptr(nullptr_t)
+                : unique_ptr{}
+            { /* DUMMY BODY */ }
+
+            template<
+                class U, class E,
+                class = enable_if_t<
+                    is_convertible_v<
+                        typename unique_ptr<U, E>::pointer,
+                        pointer
+                    >, void
+                >
+            >
+            unique_ptr(unique_ptr<U, E>&& other) noexcept
+                : ptr_{move(other.ptr_)}, deleter_{forward<D>(other.deleter_)}
+            {
+                other.ptr_ = nullptr;
+            }
+
+            /**
+             * 20.8.1.2.2, destructor:
+             */
+
+            ~unique_ptr()
+            {
+                if (ptr_)
+                    deleter_(ptr_);
+            }
+
+            /**
+             * 20.8.1.2.3, assignment:
+             */
+
+            unique_ptr& operator=(unique_ptr&& rhs) noexcept
+            {
+                reset(rhs.release());
+                deleter_ = forward<deleter_type>(rhs.get_deleter());
+
+                return *this;
+            }
+
+            template<
+                class U, class E,
+                class = enable_if_t<
+                    is_convertible_v<
+                        typename unique_ptr<U, E>::pointer,
+                        pointer
+                    > && !is_array_v<U>, void
+                >
+            >
+            unique_ptr& operator=(unique_ptr<U, E>&& rhs) noexcept
+            {
+                reset(rhs.release());
+                deleter_ = forward<E>(rhs.get_deleter());
+
+                return *this;
+            }
+
+            unique_ptr& operator=(nullptr_t) noexcept
+            {
+                reset();
+
+                return *this;
+            }
+
+            /**
+             * 20.8.1.2.4, observers:
+             */
+
+            add_lvalue_reference_t<element_type> operator*() const
+            {
+                return *ptr_;
+            }
+
+            pointer operator->() const noexcept
+            {
+                return ptr_;
+            }
+
+            pointer get() const noexcept
+            {
+                return ptr_;
+            }
+
+            deleter_type& get_deleter() noexcept
+            {
+                return deleter_;
+            }
+
+            const deleter_type& get_deleter() const noexcept
+            {
+                return deleter_;
+            }
+
+            explicit operator bool() const noexcept
+            {
+                return ptr_ != nullptr;
+            }
+
+            /**
+             * 20.8.1.2.5, modifiers:
+             */
+
+            pointer release() noexcept
+            {
+                auto ret = ptr_;
+                ptr_ = nullptr;
+
+                return ret;
+            }
+
+            void reset(pointer ptr = pointer{}) noexcept
+            {
+                /**
+                 * Note: Order is significant, deleter may delete
+                 *       *this.
+                 */
+                auto old = ptr_;
+                ptr_ = ptr;
+
+                if (old)
+                    deleter_(old);
+            }
+
+            void swap(unique_ptr& other) noexcept
+            {
+                std::swap(ptr_, other.ptr_);
+                std::swap(deleter_, other.deleter_);
+            }
+
+            unique_ptr(const unique_ptr&) = delete;
+            unique_ptr& operator=(const unique_ptr&) = delete;
+
+        private:
+            pointer ptr_;
+            deleter_type deleter_;
+    };
+
+    namespace aux
+    {
+        template<class From, class To>
+        struct is_convertible_array: is_convertible<From(*)[], To(*)[]>
+        { /* DUMMY BODY */ };
+
+        template<class From, class To>
+        inline constexpr bool is_convertible_array_v = is_convertible_array<From, To>::value;
+
+        template<class T, class D, class U, class E>
+        struct compatible_ptrs: integral_constant<
+              bool,
+              is_array_v<U> && is_same_v<
+                typename unique_ptr<T, D>::pointer,
+                typename unique_ptr<T, D>::element_type*
+              > && is_same_v<
+                typename unique_ptr<U, E>::pointer,
+                typename unique_ptr<U, E>::element_type*
+              > && is_convertible_array_v<
+                typename unique_ptr<T, D>::element_type,
+                typename unique_ptr<U, E>::element_type
+              > && ((is_reference_v<D> && is_same_v<D, E>) ||
+                   (!is_reference_v<D> && is_convertible_v<E, D>))
+        >
+        { /* DUMMY BODY */ };
+
+        template<class T, class D, class U, class E>
+        inline constexpr bool compatible_ptrs_v = compatible_ptrs<T, D, U, E>::value;
+    }
+
+    template<class T, class D>
+    class unique_ptr<T[], D>
+    {
+        public:
+            using element_type = T;
+            using deleter_type = D;
+            using pointer      = typename aux::get_unique_pointer<unique_ptr<T[], D>, D>::type;
+
+            /**
+             * 20.8.1.3.1, constructors:
+             */
+
+            constexpr unique_ptr() noexcept
+                : ptr_{}, deleter_{}
+            { /* DUMMY BODY */ }
+
+            template<
+                class U,
+                class = enable_if_t<
+                    is_same_v<U, T> || aux::is_convertible_array_v<U, T>, void
+                >
+            >
+            explicit unique_ptr(U ptr) noexcept
+                : ptr_{ptr}, deleter_{}
+            { /* DUMMY BODY */ }
+
+            template<
+                class U, class E,
+                class = enable_if_t<aux::compatible_ptrs_v<T, D, U, E>, void>
+            >
+            unique_ptr(U ptr, /* TODO */ int d) noexcept;
+
+            template<
+                class U, class E,
+                class = enable_if_t<aux::compatible_ptrs_v<T, D, U, E>, void>
+            >
+            unique_ptr(U ptr, /* TODO */ char d) noexcept;
+
+            unique_ptr(unique_ptr&& other) noexcept
+                : ptr_{move(other.ptr_)}, deleter_{forward<deleter_type>(other.deleter_)}
+            {
+                other.ptr_ = nullptr;
+            }
+
+            template<
+                class U, class E,
+                class = enable_if_t<
+                    is_same_v<U, pointer> ||
+                    (is_same_v<pointer, element_type*> && is_pointer_v<U> &&
+                     aux::is_convertible_array_v<remove_pointer_t<U>, element_type>),
+                    void
+                >
+            >
+            unique_ptr(unique_ptr<U, E>&& other) noexcept
+                : ptr_{move(other.ptr_)}, deleter_{forward<D>(other.deleter_)}
+            {
+                other.ptr_ = nullptr;
+            }
+
+            constexpr unique_ptr(nullptr_t) noexcept
+                : unique_ptr{}
+            { /* DUMMY BODY */ }
+
+            ~unique_ptr()
+            {
+                if (ptr_)
+                    deleter_(ptr_);
+            }
+
+            /**
+             * 20.8.1.3.2, assignment:
+             */
+
+            unique_ptr& operator=(unique_ptr&& rhs) noexcept
+            {
+                reset(rhs.release());
+                deleter_ = forward<deleter_type>(rhs.get_deleter());
+
+                return *this;
+            }
+
+            template<
+                class U, class E,
+                class = enable_if_t<aux::compatible_ptrs_v<T, D, U, E>, void>
+            >
+            unique_ptr& operator=(unique_ptr<U, E>&& rhs) noexcept
+            {
+                reset(rhs.release());
+                deleter_ = forward<E>(rhs.get_deleter());
+
+                return *this;
+            }
+
+            unique_ptr& operator=(nullptr_t) noexcept
+            {
+                reset();
+
+                return *this;
+            }
+
+            /**
+             * 20.8.1.3.3, observers:
+             */
+
+            element_type& operator[](size_t idx) const
+            {
+                return ptr_[idx];
+            }
+
+            pointer get() const noexcept
+            {
+                return ptr_;
+            }
+
+            deleter_type& get_deleter() noexcept
+            {
+                return deleter_;
+            }
+
+            const deleter_type& get_deleter() const noexcept
+            {
+                return deleter_;
+            }
+
+            explicit operator bool() const noexcept
+            {
+                return ptr_ != nullptr;
+            }
+
+            /**
+             * 20.8.1.3.4, modifiers:
+             */
+
+            pointer release() noexcept
+            {
+                auto ret = ptr_;
+                ptr_ = nullptr;
+
+                return ret;
+            }
+
+            template<
+                class U,
+                class = enable_if_t<
+                    is_same_v<U, pointer> ||
+                    (is_same_v<pointer, element_type*> && is_pointer_v<U> &&
+                     aux::is_convertible_array_v<remove_pointer_t<U>, element_type>),
+                    void
+                >
+            >
+            void reset(U ptr) noexcept
+            {
+                /**
+                 * Note: Order is significant, deleter may delete
+                 *       *this.
+                 */
+                auto old = ptr_;
+                ptr_ = ptr;
+
+                if (old)
+                    deleter_(old);
+            }
+
+            void reset(nullptr_t = nullptr) noexcept
+            {
+                reset(pointer{});
+            }
+
+            void swap(unique_ptr& other) noexcept
+            {
+                std::swap(ptr_, other.ptr_);
+                std::swap(deleter_, other.deleter_);
+            }
+
+            unique_ptr(const unique_ptr&) = delete;
+            unique_ptr& operator=(const unique_ptr&) = delete;
+
+        private:
+            pointer ptr_;
+            deleter_type deleter_;
+    };
+
+    namespace aux
+    {
+        template<class T>
+        struct is_unbound_array: false_type
+        { /* DUMMY BODY */ };
+
+        template<class T>
+        struct is_unbound_array<T[]>: true_type
+        { /* DUMMY BODY */ };
+
+        template<class T>
+        struct is_bound_array: false_type
+        { /* DUMMY BODY */ };
+
+        template<class T, size_t N>
+        struct is_bound_array<T[N]>: true_type
+        { /* DUMMY BODY */ };
+    }
+
+    template<
+        class T, class... Args,
+        class = enable_if_t<!is_array_v<T>, void>
+    >
+    unique_ptr<T> make_unique(Args&&... args)
+    {
+        return unique_ptr<T>(new T(forward<Args>(args)...));
+    }
+
+    template<
+        class T, class = enable_if_t<aux::is_unbound_array<T>::value, void>
+    >
+    unique_ptr<T> make_unique(size_t n)
+    {
+        return unique_ptr<T>(new remove_extent_t<T>[n]());
+    }
+
+    template<
+        class T, class... Args,
+        class = enable_if_t<aux::is_bound_array<T>::value, void>
+    >
+    void make_unique(Args&&...) = delete;
+
+    template<class T, class D>
+    void swap(unique_ptr<T, D>& lhs, unique_ptr<T, D>& rhs) noexcept
+    {
+        lhs.swap(rhs);
+    }
+
+    template<class T1, class D1, class T2, class D2>
+    bool operator==(const unique_ptr<T1, D1>& lhs,
+                    const unique_ptr<T2, D2>& rhs)
+    {
+        return lhs.get() == rhs.get();
+    }
+
+    template<class T1, class D1, class T2, class D2>
+    bool operator!=(const unique_ptr<T1, D1>& lhs,
+                    const unique_ptr<T2, D2>& rhs)
+    {
+        return lhs.get() != rhs.get();
+    }
+
+    template<class T1, class D1, class T2, class D2>
+    bool operator<(const unique_ptr<T1, D1>& lhs,
+                   const unique_ptr<T2, D2>& rhs)
+    {
+        return lhs.get() < rhs.get();
+    }
+
+    template<class T1, class D1, class T2, class D2>
+    bool operator<=(const unique_ptr<T1, D1>& lhs,
+                    const unique_ptr<T2, D2>& rhs)
+    {
+        return !(rhs < lhs);
+    }
+
+    template<class T1, class D1, class T2, class D2>
+    bool operator>(const unique_ptr<T1, D1>& lhs,
+                   const unique_ptr<T2, D2>& rhs)
+    {
+        return rhs < lhs;
+    }
+
+    template<class T1, class D1, class T2, class D2>
+    bool operator>=(const unique_ptr<T1, D1>& lhs,
+                    const unique_ptr<T2, D2>& rhs)
+    {
+        return !(lhs < rhs);
+    }
+
+    template<class T, class D>
+    bool operator==(const unique_ptr<T, D>& ptr, nullptr_t) noexcept
+    {
+        return !ptr;
+    }
+
+    template<class T, class D>
+    bool operator==(nullptr_t, const unique_ptr<T, D>& ptr) noexcept
+    {
+        return !ptr;
+    }
+
+    template<class T, class D>
+    bool operator!=(const unique_ptr<T, D>& ptr, nullptr_t) noexcept
+    {
+        return static_cast<bool>(ptr);
+    }
+
+    template<class T, class D>
+    bool operator!=(nullptr_t, const unique_ptr<T, D>& ptr) noexcept
+    {
+        return static_cast<bool>(ptr);
+    }
+
+    template<class T, class D>
+    bool operator<(const unique_ptr<T, D>& ptr, nullptr_t)
+    {
+        return ptr.get() < nullptr;
+    }
+
+    template<class T, class D>
+    bool operator<(nullptr_t, const unique_ptr<T, D>& ptr)
+    {
+        return nullptr < ptr.get();
+    }
+
+    template<class T, class D>
+    bool operator<=(const unique_ptr<T, D>& ptr, nullptr_t)
+    {
+        return !(nullptr < ptr);
+    }
+
+    template<class T, class D>
+    bool operator<=(nullptr_t, const unique_ptr<T, D>& ptr)
+    {
+        return !(ptr < nullptr);
+    }
+
+    template<class T, class D>
+    bool operator>(const unique_ptr<T, D>& ptr, nullptr_t)
+    {
+        return nullptr < ptr;
+    }
+
+    template<class T, class D>
+    bool operator>(nullptr_t, const unique_ptr<T, D>& ptr)
+    {
+        return ptr < nullptr;
+    }
+
+    template<class T, class D>
+    bool operator>=(const unique_ptr<T, D>& ptr, nullptr_t)
+    {
+        return !(ptr < nullptr);
+    }
+
+    template<class T, class D>
+    bool operator>=(nullptr_t, const unique_ptr<T, D>& ptr)
+    {
+        return !(nullptr < ptr);
+    }
+
+    /**
+     * 20.8.2.7, smart pointer hash support:
+     */
+
+    template<class T, class D>
+    struct hash<unique_ptr<T, D>>
+    {
+        size_t operator()(const unique_ptr<T, D>& ptr) const noexcept
+        {
+            return hash<typename unique_ptr<T, D>::pointer>{}(ptr.get());
+        }
+
+        using argument_type = unique_ptr<T, D>;
+        using result_type   = size_t;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/memory/weak_ptr.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/memory/weak_ptr.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/memory/weak_ptr.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_MEMORY_WEAK_PTR
+#define LIBCPP_BITS_MEMORY_WEAK_PTR
+
+#include <__bits/memory/shared_payload.hpp>
+#include <type_traits>
+#include <utility>
+
+namespace std
+{
+    template<class T>
+    class shared_ptr;
+
+    /**
+     * 20.8.2.3, class template weak_ptr:
+     */
+
+    template<class T>
+    class weak_ptr
+    {
+        public:
+            using element_type = T;
+
+            /**
+             * 20.8.2.3.1, constructors:
+             */
+
+            constexpr weak_ptr() noexcept
+                : payload_{}
+            { /* DUMMY BODY */ }
+
+            template<class U>
+            weak_ptr(
+                const shared_ptr<U>& other,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            ) noexcept
+                : payload_{other.payload_}
+            {
+                if (payload_)
+                    payload_->increment_weak();
+            }
+
+            weak_ptr(const weak_ptr& other) noexcept
+                : payload_{other.payload_}
+            {
+                if (payload_)
+                    payload_->increment_weak();
+            }
+
+            template<class U>
+            weak_ptr(
+                const weak_ptr<U>& other,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            ) noexcept
+                : payload_{other.payload_}
+            {
+                if (payload_)
+                    payload_->increment_weak();
+            }
+
+            weak_ptr(weak_ptr&& other) noexcept
+                : payload_{other.payload_}
+            {
+                other.payload_ = nullptr;
+            }
+
+            template<class U>
+            weak_ptr(
+                weak_ptr<U>&& other,
+                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
+            ) noexcept
+                : payload_{other.payload_}
+            {
+                other.payload_ = nullptr;
+            }
+
+            /**
+             * 20.8.2.3.2, destructor:
+             */
+
+            ~weak_ptr()
+            {
+                remove_payload_();
+            }
+
+            /**
+             * 20.8.2.3.3, assignment:
+             */
+
+            weak_ptr& operator=(const weak_ptr& rhs) noexcept
+            {
+                remove_payload_();
+
+                payload_ = rhs.payload_;
+                if (payload_)
+                    payload_->increment_weak();
+
+                return *this;
+            }
+
+            template<class U>
+            weak_ptr& operator=(const weak_ptr<U>& rhs) noexcept
+            {
+                weak_ptr{rhs}.swap(*this);
+
+                return *this;
+            }
+
+            template<class U>
+            weak_ptr& operator=(const shared_ptr<U>& rhs) noexcept
+            {
+                weak_ptr{rhs}.swap(*this);
+
+                return *this;
+            }
+
+            weak_ptr& operator=(weak_ptr&& rhs) noexcept
+            {
+                weak_ptr{move(rhs)}.swap(*this);
+
+                return *this;
+            }
+
+            template<class U>
+            weak_ptr& operator=(
+                weak_ptr<U>&& rhs
+            ) noexcept
+            {
+                weak_ptr{move(rhs)}.swap(*this);
+
+                return *this;
+            }
+
+            /**
+             * 20.8.2.3.4, modifiers:
+             */
+
+            void swap(weak_ptr& other) noexcept
+            {
+                std::swap(payload_, other.payload_);
+            }
+
+            void reset() noexcept
+            {
+                weak_ptr{}.swap(*this);
+            }
+
+            /**
+             * 20.8.2.3.5, observers:
+             */
+
+            long use_count() const noexcept
+            {
+                if (payload_)
+                    return payload_->refs();
+                else
+                    return 0L;
+            }
+
+            bool expired() const noexcept
+            {
+                return use_count() == 0L;
+            }
+
+            shared_ptr<T> lock() const noexcept
+            {
+                return shared_ptr{aux::payload_tag, payload_->lock()};
+            }
+
+            template<class U>
+            bool owner_before(const shared_ptr<U>& other) const
+            {
+                return payload_ < other.payload_;
+            }
+
+            template<class U>
+            bool owner_before(const weak_ptr<U>& other) const
+            {
+                return payload_ < other.payload_;
+            }
+
+        private:
+            aux::shared_payload_base<T>* payload_;
+
+            void remove_payload_()
+            {
+                if (payload_ && payload_->decrement_weak())
+                    payload_->destroy();
+                payload_ = nullptr;
+            }
+
+            template<class U>
+            friend class shared_ptr;
+    };
+
+    /**
+     * 20.8.2.3.6, specialized algorithms:
+     */
+
+    template<class T>
+    void swap(weak_ptr<T>& lhs, weak_ptr<T>& rhs) noexcept
+    {
+        lhs.swap(rhs);
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/rbtree.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/rbtree.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/rbtree.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_RBTREE
+#define LIBCPP_BITS_RBTREE
+
+#include <__bits/key_extractors.hpp>
+#include <__bits/rbtree_iterators.hpp>
+#include <__bits/rbtree_node.hpp>
+#include <__bits/rbtree_policies.hpp>
+
+namespace std::aux
+{
+    template<
+        class Value, class Key, class KeyExtractor,
+        class KeyComp, class Alloc, class Size,
+        class Iterator, class ConstIterator,
+        class Policy, class Node
+    >
+    class rbtree
+    {
+        public:
+            using value_type     = Value;
+            using key_type       = Key;
+            using size_type      = Size;
+            using allocator_type = Alloc;
+            using key_compare    = KeyComp;
+            using key_extract    = KeyExtractor;
+
+            using iterator       = Iterator;
+            using const_iterator = ConstIterator;
+
+            using reverse_iterator       = std::reverse_iterator<iterator>;
+            using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+
+            using node_type = Node;
+
+            rbtree(const key_compare& kcmp = key_compare{})
+                : root_{nullptr}, size_{}, key_compare_{},
+                  key_extractor_{}
+            { /* DUMMY BODY */ }
+
+            rbtree(const rbtree& other)
+                : rbtree{other.key_compare_}
+            {
+                for (const auto& x: other)
+                    insert(x);
+            }
+
+            rbtree(rbtree&& other)
+                : root_{other.root_}, size_{other.size_},
+                  key_compare_{move(other.key_compare_)},
+                  key_extractor_{move(other.key_extractor_)}
+            {
+                other.root_ = nullptr;
+                other.size_ = size_type{};
+            }
+
+            rbtree& operator=(const rbtree& other)
+            {
+                auto tmp{other};
+                tmp.swap(*this);
+
+                return *this;
+            }
+
+            rbtree& operator=(rbtree&& other)
+            {
+                rbtree tmp{move(other)};
+                tmp.swap(*this);
+
+                return *this;
+            }
+
+            bool empty() const noexcept
+            {
+                return size_ == 0U;
+            }
+
+            size_type size() const noexcept
+            {
+                return size_;
+            }
+
+            size_type max_size(allocator_type& alloc)
+            {
+                return allocator_traits<allocator_type>::max_size(alloc);
+            }
+
+            iterator begin()
+            {
+                return iterator{find_smallest_(), false};
+            }
+
+            const_iterator begin() const
+            {
+                return cbegin();
+            }
+
+            iterator end()
+            {
+                /**
+                 * In case we have lists of nodes
+                 * we need to get the actual end
+                 * from the largest node.
+                 */
+                auto res = find_largest_();
+                if (res)
+                    return iterator{res->get_end(), true};
+                else
+                    return iterator{res, true};
+            }
+
+            const_iterator end() const
+            {
+                return cend();
+            }
+
+            reverse_iterator rbegin()
+            {
+                return make_reverse_iterator(end());
+            }
+
+            const_reverse_iterator rbegin() const
+            {
+                return make_reverse_iterator(cend());
+            }
+
+            reverse_iterator rend()
+            {
+                return make_reverse_iterator(begin());
+            }
+
+            const_reverse_iterator rend() const
+            {
+                return make_reverse_iterator(cbegin());
+            }
+
+            const_iterator cbegin() const
+            {
+                return const_iterator{find_smallest_(), false};
+            }
+
+            const_iterator cend() const
+            {
+                auto res = find_largest_();
+                if (res)
+                    return const_iterator{res->get_end(), true};
+                else
+                    return const_iterator{res, true};
+            }
+
+            const_reverse_iterator crbegin() const
+            {
+                return make_reverse_iterator(cend());
+            }
+
+            const_reverse_iterator crend() const
+            {
+                return make_reverse_iterator(cbegin());
+            }
+
+            template<class... Args>
+            auto emplace(Args&&... args)
+            {
+                return Policy::emplace(*this, forward<Args>(args)...);
+            }
+
+            auto insert(const value_type& val)
+            {
+                return Policy::insert(*this, val);
+            }
+
+            auto insert(value_type&& val)
+            {
+                return Policy::insert(*this, forward<value_type>(val));
+            }
+
+            size_type erase(const key_type& key)
+            {
+                return Policy::erase(*this, key);
+            }
+
+            iterator erase(const_iterator it)
+            {
+                if (it == cend())
+                    return end();
+
+                auto node = const_cast<node_type*>(it.node());
+
+                node = delete_node(node);
+                if (!node)
+                    return iterator{find_largest_(), true};
+                else
+                    return iterator{const_cast<node_type*>(node), false};
+            }
+
+            void clear() noexcept
+            {
+                if (root_)
+                {
+                    delete root_;
+                    root_ = nullptr;
+                    size_ = size_type{};
+                }
+            }
+
+            void swap(rbtree& other)
+                noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
+                         noexcept(swap(declval<KeyComp&>(), declval<KeyComp&>())))
+            {
+                std::swap(root_, other.root_);
+                std::swap(size_, other.size_);
+                std::swap(key_compare_, other.key_compare_);
+                std::swap(key_extractor_, other.key_extractor_);
+            }
+
+            key_compare key_comp() const
+            {
+                return key_compare_;
+            }
+
+            iterator find(const key_type& key)
+            {
+                auto node = find_(key);
+                if (node)
+                    return iterator{node, false};
+                else
+                    return end();
+            }
+
+            const_iterator find(const key_type& key) const
+            {
+                auto node = find_(key);
+                if (node)
+                    return const_iterator{node, false};
+                else
+                    return end();
+            }
+
+            size_type count(const key_type& key) const
+            {
+                return Policy::count(*this, key);
+            }
+
+            iterator upper_bound(const key_type& key)
+            {
+                return Policy::upper_bound(*this, key);
+            }
+
+            const_iterator upper_bound(const key_type& key) const
+            {
+                return Policy::upper_bound_const(*this, key);
+            }
+
+            iterator lower_bound(const key_type& key)
+            {
+                return Policy::lower_bound(*this, key);
+            }
+
+            const_iterator lower_bound(const key_type& key) const
+            {
+                return Policy::lower_bound_const(*this, key);
+            }
+
+            pair<iterator, iterator> equal_range(const key_type& key)
+            {
+                return Policy::equal_range(*this, key);
+            }
+
+            pair<const_iterator, const_iterator> equal_range(const key_type& key) const
+            {
+                return Policy::equal_range_const(*this, key);
+            }
+
+            bool is_eq_to(const rbtree& other) const
+            {
+                if (size_ != other.size())
+                    return false;
+
+                auto it1 = begin();
+                auto it2 = other.begin();
+
+                // TODO: this doesn't compare values :/
+                while (keys_equal(*it1++, *it2++))
+                { /* DUMMY BODY */ }
+
+                return (it1 == end()) && (it2 == other.end());
+            }
+
+            const key_type& get_key(const value_type& val) const
+            {
+                return key_extractor_(val);
+            }
+
+            bool keys_comp(const key_type& key, const value_type& val) const
+            {
+                return key_compare_(key, key_extractor_(val));
+            }
+
+            bool keys_equal(const key_type& k1, const key_type& k2) const
+            {
+                return !key_compare_(k1, k2) && !key_compare_(k2, k1);
+            }
+
+            node_type* find_parent_for_insertion(const key_type& key) const
+            {
+                auto current = root_;
+                auto parent = current;
+
+                while (current)
+                {
+                    parent = current;
+                    if (key_compare_(key, key_extractor_(current->value)))
+                        current = current->left();
+                    else if (key_compare_(key_extractor_(current->value), key))
+                        current = current->right();
+                    else
+                        return current;
+                }
+
+                return parent;
+            }
+
+            node_type* delete_node(const node_type* n)
+            {
+                auto node = const_cast<node_type*>(n);
+                if (!node)
+                    return nullptr;
+
+                --size_;
+
+                auto succ = node->successor();
+                if (auto tmp = node->get_node_for_deletion(); tmp != nullptr)
+                {
+                    /**
+                     * This will kick in multi containers,
+                     * we popped one node from a list of nodes
+                     * with equivalent keys and we can delete it
+                     * and return the successor which was the next
+                     * in the list.
+                     */
+                    delete tmp;
+
+                    update_root_(succ); // Incase the first in list was root.
+                    return succ;
+                }
+                else if (node == root_)
+                { // Only executed if root_ is unique.
+                    root_ = nullptr;
+                    delete node;
+
+                    return nullptr;
+                }
+
+                if (node->left() && node->right())
+                {
+                    node->swap(succ);
+                    if (succ && !succ->parent())
+                        root_ = succ;
+
+                    // Node now has at most one child.
+                    // Also: If succ was nullptr, the swap
+                    //       didn't do anything and we can
+                    //       safely delete node.
+                    return delete_node(node);
+                }
+
+                auto child = node->right() ? node->right() : node->left();
+                if (!child)
+                {
+                    // Simply remove the node.
+                    // TODO: repair here too?
+                    node->unlink();
+                    delete node;
+                }
+                else
+                {
+                    // Replace with the child.
+                    child->parent(node->parent());
+                    if (node->is_left_child())
+                        child->parent()->left(child);
+                    else if (node->is_right_child())
+                        child->parent()->right(child);
+                    node->parent(nullptr);
+                    node->left(nullptr);
+                    node->right(nullptr);
+
+                    // Repair if needed.
+                    repair_after_erase_(node, child);
+                    update_root_(child);
+
+                    delete node;
+                }
+
+                return succ;
+            }
+
+            void insert_node(node_type* node, node_type* parent)
+            {
+                Policy::insert(*this, node, parent);
+            }
+
+        private:
+            node_type* root_;
+            size_type size_;
+            key_compare key_compare_;
+            key_extract key_extractor_;
+
+            node_type* find_(const key_type& key) const
+            {
+                auto current = root_;
+                while (current != nullptr)
+                {
+                    if (key_compare_(key, key_extractor_(current->value)))
+                        current = current->left();
+                    else if (key_compare_(key_extractor_(current->value), key))
+                        current = current->right();
+                    else
+                        return current;
+                }
+
+                return nullptr;
+            }
+
+            node_type* find_smallest_() const
+            {
+                if (root_)
+                    return root_->find_smallest();
+                else
+                    return nullptr;
+            }
+
+            node_type* find_largest_() const
+            {
+                if (root_)
+                    return root_->find_largest();
+                else
+                    return nullptr;
+            }
+
+            void update_root_(const node_type* node)
+            {
+                if (!node)
+                    return;
+
+                root_ = const_cast<node_type*>(node);
+                while (root_->parent())
+                    root_ = root_->parent();
+            }
+
+            void repair_after_insert_(const node_type* node)
+            {
+                // TODO: implement
+            }
+
+            void repair_after_erase_(const node_type* node, const node_type* child)
+            {
+                // TODO: implement
+            }
+
+            friend Policy;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/rbtree_iterators.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/rbtree_iterators.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/rbtree_iterators.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_RBTREE_ITERATORS
+#define LIBCPP_BITS_RBTREE_ITERATORS
+
+#include <__bits/iterator.hpp>
+#include <__bits/rbtree_node.hpp>
+#include <iterator>
+
+namespace std::aux
+{
+    /**
+     * Note: In order for these iterators to be reversible,
+     *       the end state of an iterator is represented by a flag
+     *       which can be set from true to false in operator--
+     *       (i.e. decrementing end iterator) or set from false to
+     *       true in operator++ (i.e. incrementing last before end
+     *       iterator).
+     */
+
+    template<class Value, class Reference, class Pointer, class Size, class Node>
+    class rbtree_iterator
+    {
+        public:
+            using value_type      = Value;
+            using size_type       = Size;
+            using reference       = Reference;
+            using pointer         = Pointer;
+            using difference_type = ptrdiff_t;
+
+            using iterator_category = bidirectional_iterator_tag;
+
+            using node_type = Node;
+
+            rbtree_iterator(node_type* current = nullptr, bool end = true)
+                : current_{current}, end_{end}
+            { /* DUMMY BODY */ }
+
+            rbtree_iterator(const rbtree_iterator&) = default;
+            rbtree_iterator& operator=(const rbtree_iterator&) = default;
+
+            reference operator*() const
+            {
+                return current_->value;
+            }
+
+            pointer operator->() const
+            {
+                return &current_->value;
+            }
+
+            rbtree_iterator& operator++()
+            {
+                if (end_)
+                    return *this;
+
+                if (current_)
+                {
+                    auto next = current_->successor();
+                    if (next)
+                        current_ = next;
+                    else
+                        end_ = true;
+                }
+
+                return *this;
+            }
+
+            rbtree_iterator operator++(int)
+            {
+                auto tmp = *this;
+                ++(*this);
+
+                return tmp;
+            }
+
+            rbtree_iterator& operator--()
+            {
+                if (end_)
+                {
+                    end_ = false;
+
+                    return *this;
+                }
+
+                if (current_)
+                {
+                    auto next = current_->predecessor();
+                    if (next)
+                        current_ = next;
+                    else
+                        end_ = true;
+                }
+
+                return *this;
+            }
+
+            rbtree_iterator operator--(int)
+            {
+                auto tmp = *this;
+                --(*this);
+
+                return tmp;
+            }
+
+            const node_type* node() const
+            {
+                return current_;
+            }
+
+            node_type* node()
+            {
+                return current_;
+            }
+
+            bool end() const
+            {
+                return end_;
+            }
+
+        private:
+            node_type* current_;
+            bool end_;
+    };
+
+    template<class Val, class Ref, class Ptr, class Sz, class N>
+    bool operator==(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
+                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
+    {
+        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
+    }
+
+    template<class Val, class Ref, class Ptr, class Sz, class N>
+    bool operator!=(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
+                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Value, class ConstReference, class ConstPointer, class Size, class Node>
+    class rbtree_const_iterator
+    {
+        using non_const_iterator_type = rbtree_iterator<
+            Value, get_non_const_ref_t<ConstReference>,
+            get_non_const_ptr_t<ConstPointer>, Size, Node
+        >;
+
+        public:
+            using value_type      = Value;
+            using size_type       = Size;
+            using const_reference = ConstReference;
+            using const_pointer   = ConstPointer;
+            using difference_type = ptrdiff_t;
+
+            using iterator_category = bidirectional_iterator_tag;
+
+            // For iterator_traits.
+            using reference = ConstReference;
+            using pointer   = ConstPointer;
+
+            using node_type = Node;
+
+            rbtree_const_iterator(const node_type* current = nullptr, bool end = true)
+                : current_{current}, end_{end}
+            { /* DUMMY BODY */ }
+
+            rbtree_const_iterator(const rbtree_const_iterator&) = default;
+            rbtree_const_iterator& operator=(const rbtree_const_iterator&) = default;
+
+            rbtree_const_iterator(const non_const_iterator_type& other)
+                : current_{other.node()}, end_{other.end()}
+            { /* DUMMY BODY */ }
+
+            rbtree_const_iterator& operator=(const non_const_iterator_type& other)
+            {
+                current_ = other.node();
+                end_ = other.end();
+
+                return *this;
+            }
+
+            const_reference operator*() const
+            {
+                return current_->value;
+            }
+
+            const_pointer operator->() const
+            {
+                return &current_->value;
+            }
+
+            rbtree_const_iterator& operator++()
+            {
+                if (end_)
+                    return *this;
+
+                if (current_)
+                {
+                    auto next = current_->successor();
+                    if (next)
+                        current_ = next;
+                    else
+                        end_ = true;
+                }
+
+                return *this;
+            }
+
+            rbtree_const_iterator operator++(int)
+            {
+                auto tmp = *this;
+                ++(*this);
+
+                return tmp;
+            }
+
+            rbtree_const_iterator& operator--()
+            {
+                if (end_)
+                {
+                    end_ = false;
+
+                    return *this;
+                }
+
+                if (current_)
+                {
+                    auto next = current_->predecessor();
+                    if (next)
+                        current_ = next;
+                    else
+                        end_ = true;
+                }
+
+                return *this;
+            }
+
+            rbtree_const_iterator operator--(int)
+            {
+                auto tmp = *this;
+                --(*this);
+
+                return tmp;
+            }
+
+            const node_type* node() const
+            {
+                return current_;
+            }
+
+            bool end() const
+            {
+                return end_;
+            }
+
+        private:
+            const node_type* current_;
+            bool end_;
+    };
+
+    template<class Val, class CRef, class CPtr, class Sz, class N>
+    bool operator==(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
+                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
+    {
+        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
+    }
+
+    template<class Val, class CRef, class CPtr, class Sz, class N>
+    bool operator!=(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
+                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Val, class Ref, class Ptr, class CRef, class CPtr, class Sz, class N>
+    bool operator==(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
+                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
+    {
+        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
+    }
+
+    template<class Val, class Ref, class Ptr, class CRef, class CPtr, class Sz, class N>
+    bool operator!=(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
+                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+
+    template<class Val, class CRef, class CPtr, class Ref, class Ptr, class Sz, class N>
+    bool operator==(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
+                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
+    {
+        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
+    }
+
+    template<class Val, class CRef, class CPtr, class Ref, class Ptr, class Sz, class N>
+    bool operator!=(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
+                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
+    {
+        return !(lhs == rhs);
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/rbtree_node.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/rbtree_node.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/rbtree_node.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,728 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_RBTREE_NODE
+#define LIBCPP_BITS_RBTREE_NODE
+
+#include <cassert>
+#include <utility>
+
+namespace std::aux
+{
+    enum class rbcolor
+    {
+        red, black
+    };
+
+    template<class Node>
+    struct rbtree_utils
+    {
+        static Node* grandparent(Node* node)
+        {
+            if (node && node->parent())
+                return node->parent()->parent();
+            else
+                return nullptr;
+        }
+
+        static Node* brother(Node* node)
+        {
+            if (node && node->parent())
+            {
+                if (node == node->parent()->left())
+                    return node->parent()->right();
+                else
+                    return node->parent()->left();
+            }
+            else
+                return nullptr;
+        }
+
+        static Node* uncle(Node* node)
+        {
+            auto gp = grandparent(node);
+            if (gp)
+            {
+                if (node->parent() == gp->left())
+                    return gp->right();
+                else
+                    return gp->left();
+            }
+            else
+                return nullptr;
+        }
+
+        static bool is_left_child(const Node* node)
+        {
+            if (!node)
+                return false;
+
+            if (node->parent())
+                return node->parent()->left() == node;
+            else
+                return false;
+        }
+
+        static bool is_right_child(const Node* node)
+        {
+            if (!node)
+                return false;
+
+            if (node->parent())
+                return node->parent()->right() == node;
+            else
+                return false;
+        }
+
+        static void rotate_left(Node* node)
+        {
+            // TODO: implement
+        }
+
+        static void rotate_right(Node* node)
+        {
+            // TODO: implement
+        }
+
+        static Node* find_smallest(Node* node)
+        {
+            return const_cast<Node*>(find_smallest(const_cast<const Node*>(node)));
+        }
+
+        static const Node* find_smallest(const Node* node)
+        {
+            if (!node)
+                return nullptr;
+
+            while (node->left())
+                node = node->left();
+
+            return node;
+        }
+
+        static Node* find_largest(Node* node)
+        {
+            return const_cast<Node*>(find_largest(const_cast<const Node*>(node)));
+        }
+
+        static const Node* find_largest(const Node* node)
+        {
+            if (!node)
+                return nullptr;
+
+            while (node->right())
+                node = node->right();
+
+            return node;
+        }
+
+        static Node* successor(Node* node)
+        {
+            return const_cast<Node*>(successor(const_cast<const Node*>(node)));
+        }
+
+        static const Node* successor(const Node* node)
+        {
+            if (!node)
+                return nullptr;
+
+            if (node->right())
+                return find_smallest(node->right());
+            else
+            {
+                while (node && !is_left_child(node))
+                    node = node->parent();
+
+                if (node)
+                    return node->parent();
+                else
+                    return node;
+            }
+        }
+
+        static Node* predecessor(Node* node)
+        {
+            return const_cast<Node*>(predecessor(const_cast<const Node*>(node)));
+        }
+
+        static const Node* predecessor(const Node* node)
+        {
+            if (!node)
+                return nullptr;
+
+            if (node->left())
+                return find_largest(node->left());
+            else
+            {
+                while (node && is_left_child(node))
+                    node = node->parent();
+
+                if (node)
+                    return node->parent();
+                else
+                    return node;
+            }
+        }
+
+        static void add_left_child(Node* node, Node* child)
+        {
+            if (!node || !child)
+                return;
+
+            node->left(child);
+            child->parent(node);
+        }
+
+        static void add_right_child(Node* node, Node* child)
+        {
+            if (!node || !child)
+                return;
+
+            node->right(child);
+            child->parent(node);
+        }
+
+        static void swap(Node* node1, Node* node2)
+        {
+            if (!node1 || !node2)
+                return;
+
+            auto parent1 = node1->parent();
+            auto left1 = node1->left();
+            auto right1 = node1->right();
+            auto is_right1 = is_right_child(node1);
+
+            auto parent2 = node2->parent();
+            auto left2 = node2->left();
+            auto right2 = node2->right();
+            auto is_right2 = is_right_child(node2);
+
+            assimilate(node1, parent2, left2, right2, is_right2);
+            assimilate(node2, parent1, left1, right1, is_right1);
+        }
+
+        static void assimilate(
+            Node* node, Node* p, Node* l, Node* r, bool is_r
+        )
+        {
+            if (!node)
+                return;
+
+            node->parent(p);
+            if (node->parent())
+            {
+                if (is_r)
+                    node->parent()->right(node);
+                else
+                    node->parent()->left(node);
+            }
+
+            node->left(l);
+            if (node->left())
+                node->left()->parent(node);
+
+            node->right(r);
+            if (node->right())
+                node->right()->parent(node);
+        }
+    };
+
+    template<class T>
+    struct rbtree_single_node
+    {
+        using utils = rbtree_utils<rbtree_single_node<T>>;
+
+        public:
+            T value;
+            rbcolor color;
+
+            template<class... Args>
+            rbtree_single_node(Args&&... args)
+                : value{forward<Args>(args)...}, color{rbcolor::red},
+                  parent_{}, left_{}, right_{}
+            { /* DUMMY BODY */ }
+
+            rbtree_single_node* parent() const
+            {
+                return parent_;
+            }
+
+            void parent(rbtree_single_node* node)
+            {
+                parent_ = node;
+            }
+
+            rbtree_single_node* left() const
+            {
+                return left_;
+            }
+
+            void left(rbtree_single_node* node)
+            {
+                left_ = node;
+            }
+
+            rbtree_single_node* right() const
+            {
+                return right_;
+            }
+
+            void right(rbtree_single_node* node)
+            {
+                right_ = node;
+            }
+
+            rbtree_single_node* grandparent()
+            {
+                return utils::grandparent(this);
+            }
+
+            rbtree_single_node* brother()
+            {
+                return utils::brother(this);
+            }
+
+            rbtree_single_node* uncle()
+            {
+                return utils::uncle(this);
+            }
+
+            bool is_left_child() const
+            {
+                return utils::is_left_child(this);
+            }
+
+            bool is_right_child() const
+            {
+                return utils::is_right_child(this);
+            }
+
+            void rotate_left()
+            {
+                utils::rotate_left(this);
+            }
+
+            void rotate_right()
+            {
+                utils::rotate_right(this);
+            }
+
+            rbtree_single_node* find_smallest()
+            {
+                return utils::find_smallest(this);
+            }
+
+            const rbtree_single_node* find_smallest() const
+            {
+                return utils::find_smallest(this);
+            }
+
+            rbtree_single_node* find_largest()
+            {
+                return utils::find_largest(this);
+            }
+
+            const rbtree_single_node* find_largest() const
+            {
+                return utils::find_largest(this);
+            }
+
+            rbtree_single_node* successor()
+            {
+                return utils::successor(this);
+            }
+
+            const rbtree_single_node* successor() const
+            {
+                return utils::successor(this);
+            }
+
+            rbtree_single_node* predecessor()
+            {
+                return utils::predecessor(this);
+            }
+
+            const rbtree_single_node* predecessor() const
+            {
+                return utils::predecessor(this);
+            }
+
+            void add_left_child(rbtree_single_node* node)
+            {
+                utils::add_left_child(this, node);
+            }
+
+            void add_right_child(rbtree_single_node* node)
+            {
+                utils::add_right_child(this, node);
+            }
+
+            void swap(rbtree_single_node* other)
+            {
+                utils::swap(this, other);
+            }
+
+            void unlink()
+            {
+                if (is_left_child())
+                    parent_->left_ = nullptr;
+                else if (is_right_child())
+                    parent_->right_ = nullptr;
+            }
+
+            rbtree_single_node* get_node_for_deletion()
+            {
+                return nullptr;
+            }
+
+            rbtree_single_node* get_end()
+            {
+                return this;
+            }
+
+            const rbtree_single_node* get_end() const
+            {
+                return this;
+            }
+
+            ~rbtree_single_node()
+            {
+                parent_ = nullptr;
+                if (left_)
+                    delete left_;
+                if (right_)
+                    delete right_;
+            }
+
+        private:
+            rbtree_single_node* parent_;
+            rbtree_single_node* left_;
+            rbtree_single_node* right_;
+    };
+
+    template<class T>
+    struct rbtree_multi_node
+    {
+        using utils = rbtree_utils<rbtree_multi_node<T>>;
+
+        public:
+            T value;
+            rbcolor color;
+
+            template<class... Args>
+            rbtree_multi_node(Args&&... args)
+                : value{forward<Args>(args)...}, color{rbcolor::red},
+                  parent_{}, left_{}, right_{}, next_{}, first_{}
+            {
+                first_ = this;
+            }
+
+            rbtree_multi_node* parent() const
+            {
+                return parent_;
+            }
+
+            void parent(rbtree_multi_node* node)
+            {
+                parent_ = node;
+
+                auto tmp = first_;
+                while (tmp)
+                {
+                    tmp->parent_ = node;
+                    tmp = tmp->next_;
+                }
+            }
+
+            rbtree_multi_node* left() const
+            {
+                return left_;
+            }
+
+            void left(rbtree_multi_node* node)
+            {
+                left_ = node;
+
+                auto tmp = first_;
+                while (tmp)
+                {
+                    tmp->left_ = node;
+                    tmp = tmp->next_;
+                }
+            }
+
+            rbtree_multi_node* right() const
+            {
+                return right_;
+            }
+
+            void right(rbtree_multi_node* node)
+            {
+                right_ = node;
+
+                auto tmp = first_;
+                while (tmp)
+                {
+                    tmp->right_ = node;
+                    tmp = tmp->next_;
+                }
+            }
+
+            rbtree_multi_node* grandparent()
+            {
+                return utils::grandparent(this);
+            }
+
+            rbtree_multi_node* brother()
+            {
+                return utils::brother(this);
+            }
+
+            rbtree_multi_node* uncle()
+            {
+                return utils::uncle(this);
+            }
+
+            bool is_left_child() const
+            {
+                return utils::is_left_child(this);
+            }
+
+            bool is_right_child()
+            {
+                return utils::is_right_child(this);
+            }
+
+            void rotate_left()
+            {
+                utils::rotate_left(this);
+            }
+
+            void rotate_right()
+            {
+                utils::rotate_right(this);
+            }
+
+            rbtree_multi_node* find_smallest()
+            {
+                return utils::find_smallest(this);
+            }
+
+            const rbtree_multi_node* find_smallest() const
+            {
+                return utils::find_smallest(this);
+            }
+
+            rbtree_multi_node* find_largest()
+            {
+                return utils::find_largest(this);
+            }
+
+            const rbtree_multi_node* find_largest() const
+            {
+                return utils::find_largest(this);
+            }
+
+            rbtree_multi_node* successor()
+            {
+                return const_cast<
+                    rbtree_multi_node*
+                >(const_cast<const rbtree_multi_node*>(this)->successor());
+            }
+
+            const rbtree_multi_node* successor() const
+            {
+                if (next_)
+                    return next_;
+                else
+                    return utils::successor(this);
+            }
+
+            rbtree_multi_node* predecessor()
+            {
+                return const_cast<
+                    rbtree_multi_node*
+                >(const_cast<const rbtree_multi_node*>(this)->predecessor());
+            }
+
+            const rbtree_multi_node* predecessor() const
+            {
+                if (this != first_)
+                {
+                    auto tmp = first_;
+                    while (tmp->next_ != this)
+                        tmp = tmp->next_;
+
+                    return tmp;
+                }
+                else
+                {
+                    auto tmp = utils::predecessor(this);
+
+                    /**
+                     * If tmp was duplicate, we got a pointer
+                     * to the first node in the list. So we need
+                     * to move to the end.
+                     */
+                    while (tmp->next_ != nullptr)
+                        tmp = tmp->next_;
+
+                    return tmp;
+                }
+            }
+
+            void add_left_child(rbtree_multi_node* node)
+            {
+                utils::add_left_child(this, node);
+            }
+
+            void add_right_child(rbtree_multi_node* node)
+            {
+                utils::add_right_child(this, node);
+            }
+
+            void swap(rbtree_multi_node* other)
+            {
+                utils::swap(this, other);
+            }
+
+            rbtree_multi_node* get_node_for_deletion()
+            {
+                /**
+                 * To make sure we delete nodes in
+                 * the order of their insertion
+                 * (not required, but sensical), we
+                 * update then list and return this
+                 * for deletion.
+                 */
+                if (next_)
+                {
+                    // Make next the new this.
+                    next_->first_ = next_;
+                    if (is_left_child())
+                        parent_->left_ = next_;
+                    else if (is_right_child())
+                        parent_->right_ = next_;
+
+                    if (left_)
+                        left_->parent_ = next_;
+                    if (right_)
+                        right_->parent_ = next_;
+
+                    /**
+                     * Update the first_ pointer
+                     * of the rest of the list.
+                     */
+                    auto tmp = next_->next_;
+                    while (tmp)
+                    {
+                        tmp->first_ = next_;
+                        tmp = tmp->next_;
+                    }
+
+                    /**
+                     * Otherwise destructor could
+                     * destroy them.
+                     */
+                    parent_ = nullptr;
+                    left_ = nullptr;
+                    right_ = nullptr;
+                    next_ = nullptr;
+                    first_ = nullptr;
+
+                    return this; // This will get deleted.
+                }
+                else
+                    return nullptr;
+            }
+
+            void unlink()
+            {
+                if (is_left_child())
+                    parent_->left_ = nullptr;
+                else if (is_right_child())
+                    parent_->right_ = nullptr;
+            }
+
+            void add(rbtree_multi_node* node)
+            {
+                if (next_)
+                    next_->add(node);
+                else
+                {
+                    next_ = node;
+                    next_->first_ = first_;
+                    next_->parent_ = parent_;
+                    next_->left_ = left_;
+                    next_->right_ = right_;
+                }
+            }
+
+            rbtree_multi_node* get_end()
+            {
+                return const_cast<rbtree_multi_node*>(
+                    const_cast<const rbtree_multi_node*>(this)->get_end()
+                );
+            }
+
+            const rbtree_multi_node* get_end() const
+            {
+                if (!next_)
+                    return this;
+                else
+                {
+                    auto tmp = next_;
+                    while (tmp->next_)
+                        tmp = tmp->next_;
+
+                    return tmp;
+                }
+            }
+
+            ~rbtree_multi_node()
+            {
+                parent_ = nullptr;
+                if (left_)
+                    delete left_;
+                if (right_)
+                    delete right_;
+
+                // TODO: delete the list
+            }
+
+        private:
+            rbtree_multi_node* parent_;
+            rbtree_multi_node* left_;
+            rbtree_multi_node* right_;
+
+            rbtree_multi_node* next_;
+            rbtree_multi_node* first_;
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/rbtree_policies.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/rbtree_policies.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/rbtree_policies.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_RBTREE_POLICIES
+#define LIBCPP_BITS_RBTREE_POLICIES
+
+#include <__bits/rbtree_node.hpp>
+#include <utility>
+
+namespace std::aux
+{
+    struct rbtree_single_policy
+    {
+        template<class Tree, class Key>
+        static typename Tree::size_type count(const Tree& tree, const Key& key)
+        {
+            return tree.find(key) == tree.end() ? 0 : 1;
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::size_type erase(Tree& tree, const Key& key)
+        {
+            using size_type = typename Tree::size_type;
+
+            auto it = tree.find(key);
+            if (it == tree.end())
+                return size_type{};
+            else
+                tree.delete_node(it.node());
+            return size_type{1};
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::iterator lower_bound(const Tree& tree, const Key& key)
+        {
+            using iterator  = typename Tree::iterator;
+            using node_type = typename Tree::node_type;
+
+            auto it = lower_bound_const(tree, key);
+
+            return iterator{const_cast<node_type*>(it.node()), it.end()};
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::const_iterator lower_bound_const(const Tree& tree, const Key& key)
+        {
+            using const_iterator = typename Tree::const_iterator;
+
+            auto node = tree.find_parent_for_insertion(key);
+            const_iterator it{node, false};
+            auto beg = tree.begin();
+            auto end = tree.end();
+
+            if (tree.key_compare_(tree.get_key(*it), key))
+            {
+                // Predecessor.
+                if (it != end)
+                    return ++it;
+                else
+                    return it;
+            }
+            else if (tree.key_compare_(key, tree.get_key(*it)))
+            {
+                // Successor.
+                if (it != beg)
+                    return --it;
+                else
+                    return it;
+            }
+            else // Perfect match.
+                return it;
+
+            return it;
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::iterator upper_bound(const Tree& tree, const Key& key)
+        {
+            using iterator  = typename Tree::iterator;
+            using node_type = typename Tree::node_type;
+
+            auto it = upper_bound_const(tree, key);
+
+            return iterator{const_cast<node_type*>(it.node()), it.end()};
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::const_iterator upper_bound_const(const Tree& tree, const Key& key)
+        {
+            /**
+             * If key isn't in the tree, we get it's
+             * predecessor or tree.end(). If key is
+             * in the tree, we get it. So unless it
+             * is equal to end(), we can increment it
+             * to get the upper bound.
+             */
+            auto it = lower_bound_const(tree, key);
+            if (it == tree.end())
+                return it;
+            else
+                return ++it;
+        }
+
+        template<class Tree, class Key>
+        static pair<
+            typename Tree::iterator,
+            typename Tree::iterator
+        > equal_range(Tree& tree, const Key& key)
+        {
+            return make_pair(
+                lower_bound(tree, key),
+                upper_bound(tree, key)
+            );
+        }
+
+        template<class Tree, class Key>
+        static pair<
+            typename Tree::const_iterator,
+            typename Tree::const_iterator
+        > equal_range_const(const Tree& tree, const Key& key)
+        {
+            return make_pair(
+                lower_bound_const(tree, key),
+                upper_bound_const(tree, key)
+            );
+        }
+
+        /**
+         * Note: We have to duplicate code for emplace, insert(const&)
+         *       and insert(&&) here, because the node (which makes distinction
+         *       between the arguments) is only created if the value isn't
+         *       in the tree already.
+         */
+
+        template<class Tree, class... Args>
+        static pair<
+            typename Tree::iterator, bool
+        > emplace(Tree& tree, Args&&... args)
+        {
+            using value_type = typename Tree::value_type;
+            using iterator   = typename Tree::iterator;
+            using node_type  = typename Tree::node_type;
+
+            auto val = value_type{forward<Args>(args)...};
+            auto parent = tree.find_parent_for_insertion(tree.get_key(val));
+
+            if (parent && tree.keys_equal(tree.get_key(parent->value), tree.get_key(val)))
+                return make_pair(iterator{parent, false}, false);
+
+            auto node = new node_type{move(val)};
+
+            return insert(tree, node, parent);
+        }
+
+        template<class Tree, class Value>
+        static pair<
+            typename Tree::iterator, bool
+        > insert(Tree& tree, const Value& val)
+        {
+            using iterator  = typename Tree::iterator;
+            using node_type = typename Tree::node_type;
+
+            auto parent = tree.find_parent_for_insertion(tree.get_key(val));
+            if (parent && tree.keys_equal(tree.get_key(parent->value), tree.get_key(val)))
+                return make_pair(iterator{parent, false}, false);
+
+            auto node = new node_type{val};
+
+            return insert(tree, node, parent);
+        }
+
+        template<class Tree, class Value>
+        static pair<
+            typename Tree::iterator, bool
+        > insert(Tree& tree, Value&& val)
+        {
+            using iterator  = typename Tree::iterator;
+            using node_type = typename Tree::node_type;
+
+            auto parent = tree.find_parent_for_insertion(tree.get_key(val));
+            if (parent && tree.keys_equal(tree.get_key(parent->value), tree.get_key(val)))
+                return make_pair(iterator{parent, false}, false);
+
+            auto node = new node_type{forward<Value>(val)};
+
+            return insert(tree, node, parent);
+        }
+
+        template<class Tree>
+        static pair<
+            typename Tree::iterator, bool
+        > insert(
+            Tree& tree, typename Tree::node_type* node,
+            typename Tree::node_type* parent
+        )
+        {
+            using iterator  = typename Tree::iterator;
+
+            if (!node)
+                return make_pair(tree.end(), false);
+
+            ++tree.size_;
+            if (!parent)
+            {
+                node->color = rbcolor::black;
+                tree.root_ = node;
+            }
+            else
+            {
+                if (tree.keys_comp(tree.get_key(node->value), parent->value))
+                    parent->add_left_child(node);
+                else
+                    parent->add_right_child(node);
+
+                tree.repair_after_insert_(node);
+                tree.update_root_(node);
+            }
+
+            return make_pair(iterator{node, false}, true);
+        }
+    };
+
+    struct rbtree_multi_policy
+    {
+        template<class Tree, class Key>
+        static typename Tree::size_type count(const Tree& tree, const Key& key)
+        {
+            using size_type = typename Tree::size_type;
+
+            auto it = tree.find(key);
+            if (it == tree.end())
+                return size_type{};
+
+            size_type res{};
+            while (it != tree.end() && tree.keys_equal(tree.get_key(*it), key))
+            {
+                ++res;
+                ++it;
+            }
+
+            return res;
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::size_type erase(Tree& tree, const Key& key)
+        {
+            using size_type = typename Tree::size_type;
+
+            auto it = tree.find(key);
+            if (it == tree.end())
+                return size_type{};
+
+            size_type res{};
+            while (it != tree.end() && tree.keys_equal(tree.get_key(*it), key))
+            {
+                ++res;
+                it = tree.erase(it);
+            }
+
+            return res;
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::iterator lower_bound(const Tree& tree, const Key& key)
+        {
+            auto it = lower_bound_const(tree, key);
+
+            return typename Tree::iterator{
+                const_cast<typename Tree::node_type*>(it.node()), it.end()
+            };
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::const_iterator lower_bound_const(const Tree& tree, const Key& key)
+        {
+            using const_iterator = typename Tree::const_iterator;
+
+            auto node = tree.find_parent_for_insertion(key);
+            const_iterator it{node, false};
+            auto beg = tree.begin();
+            auto end = tree.end();
+
+            if (tree.keys_comp(key, *it))
+                --it; // Incase we are on a successor.
+            while (tree.keys_equal(tree.get_key(*it), key) && it != beg)
+                --it; // Skip keys that are equal.
+            if (it != beg)
+                ++it; // If we moved all the way to the start, key is the smallest.
+
+            if (tree.key_compare_(tree.get_key(*it), key))
+            {
+                // Predecessor.
+                if (it != end)
+                    return ++it;
+                else
+                    return it;
+            }
+
+            return it;
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::iterator upper_bound(const Tree& tree, const Key& key)
+        {
+            auto it = upper_bound_const(tree, key);
+
+            return typename Tree::iterator{
+                const_cast<typename Tree::node_type*>(it.node()), it.end()
+            };
+        }
+
+        template<class Tree, class Key>
+        static typename Tree::const_iterator upper_bound_const(const Tree& tree, const Key& key)
+        {
+            /**
+             * If key isn't in the tree, we get it's
+             * predecessor or tree.end(). If key is
+             * in the tree, we get it. So unless it
+             * is equal to end(), we keep incrementing
+             * until we get to the next key.
+             */
+            auto it = lower_bound(tree, key);
+            if (it == tree.end())
+                return it;
+            else if (tree.keys_equal(tree.get_key(*it), key))
+            {
+                while (it != tree.end() && tree.keys_equal(tree.get_key(*it), key))
+                    ++it;
+
+                return it;
+            }
+
+            return it;
+        }
+
+        template<class Tree, class Key>
+        static pair<
+            typename Tree::iterator,
+            typename Tree::iterator
+        > equal_range(const Tree& tree, const Key& key)
+        {
+            return make_pair(
+                lower_bound(tree, key),
+                upper_bound(tree, key)
+            );
+        }
+
+        template<class Tree, class Key>
+        static pair<
+            typename Tree::const_iterator,
+            typename Tree::const_iterator
+        > equal_range_const(const Tree& tree, const Key& key)
+        {
+            return make_pair(
+                lower_bound_const(tree, key),
+                upper_bound_const(tree, key)
+            );
+        }
+
+        template<class Tree, class... Args>
+        static typename Tree::iterator emplace(Tree& tree, Args&&... args)
+        {
+            using node_type  = typename Tree::node_type;
+
+            auto node = new node_type{forward<Args>(args)...};
+
+            return insert(tree, node);
+        }
+
+        template<class Tree, class Value>
+        static typename Tree::iterator insert(Tree& tree, const Value& val)
+        {
+            using node_type = typename Tree::node_type;
+
+            auto node = new node_type{val};
+
+            return insert(tree, node);
+        }
+
+        template<class Tree, class Value>
+        static typename Tree::iterator insert(Tree& tree, Value&& val)
+        {
+            using node_type = typename Tree::node_type;
+
+            auto node = new node_type{forward<Value>(val)};
+
+            return insert(tree, node);
+        }
+
+        template<class Tree>
+        static typename Tree::iterator insert(
+            Tree& tree, typename Tree::node_type* node,
+            typename Tree::node_type* = nullptr
+        )
+        {
+            using iterator  = typename Tree::iterator;
+
+            if (!node)
+                return tree.end();
+
+            auto parent = tree.find_parent_for_insertion(tree.get_key(node->value));
+
+            ++tree.size_;
+            if (!parent)
+            {
+                node->color = rbcolor::black;
+                tree.root_ = node;
+            }
+            else
+            {
+                if (tree.keys_comp(tree.get_key(node->value), parent->value))
+                    parent->add_left_child(node);
+                else if (tree.keys_comp(tree.get_key(parent->value), node->value))
+                    parent->add_right_child(node);
+                else
+                {
+                    parent->add(node); // List of nodes with equivalent keys.
+                    tree.update_root_(parent);
+
+                    return iterator{node, false};
+                }
+
+                tree.repair_after_insert_(node);
+                tree.update_root_(node);
+            }
+
+            return iterator{node, false};
+        }
+    };
+}
+
+#endif
+
Index: uspace/lib/cpp/include/__bits/result_of.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/result_of.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/result_of.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_RESULT_OF
+#define LIBCPP_BITS_RESULT_OF
+
+#include <__bits/invoke.hpp>
+
+namespace std
+{
+    /**
+     * Note: This doesn't work, C++14 standard allows for F
+     *       to be any complete type, our implementation
+     *       currently works like the C++11 version where
+     *       F has to be callable.
+     * TODO: Fix this.
+     */
+
+    template<class>
+    struct result_of;
+
+    template<class F, class... Args>
+    class result_of<F(Args...)>: aux::type_is<
+        decltype(aux::invoke(declval<F>(), declval<ArgTypes>()...))
+    >
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    using result_of_t = typename result_of<T>::type;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/streambufs.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/streambufs.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/streambufs.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_STREAMBUFS
+#define LIBCPP_STREAMBUFS
+
+#include <iosfwd>
+#include <cstdio>
+#include <streambuf>
+
+namespace std::aux
+{
+    template<class Char, class Traits = char_traits<Char>>
+    class stdin_streambuf : public basic_streambuf<Char, Traits>
+    {
+        public:
+            stdin_streambuf()
+                : basic_streambuf<Char, Traits>{}, buffer_{nullptr}
+            { /* DUMMY BODY */ }
+
+            virtual ~stdin_streambuf()
+            {
+                if (buffer_)
+                    delete[] buffer_;
+            }
+
+        protected:
+            using traits_type = Traits;
+            using char_type   = typename traits_type::char_type;
+            using int_type    = typename traits_type::int_type;
+            using off_type    = typename traits_type::off_type;
+
+            using basic_streambuf<Char, Traits>::input_begin_;
+            using basic_streambuf<Char, Traits>::input_next_;
+            using basic_streambuf<Char, Traits>::input_end_;
+
+            int_type underflow() override
+            {
+                if (!this->gptr())
+                {
+                    buffer_ = new char_type[buf_size_];
+                    input_begin_ = input_next_ = input_end_ = buffer_;
+                }
+
+                off_type i{};
+                if (input_next_ < input_end_)
+                {
+                    auto idx = static_cast<off_type>(input_next_ - input_begin_);
+                    auto count = buf_size_ - idx;
+
+                    for (; i < count; ++i, ++idx)
+                        buffer_[i] = buffer_[idx];
+                }
+
+                for (; i < buf_size_; ++i)
+                {
+                    auto c = fgetc(in_);
+                    putchar(c); // TODO: Temporary source of feedback.
+                    if (c == traits_type::eof())
+                        break;
+
+                    buffer_[i] = static_cast<char_type>(c);
+
+                    if (buffer_[i] == '\n')
+                    {
+                        ++i;
+                        break;
+                    }
+                }
+
+                input_next_ = input_begin_;
+                input_end_ = input_begin_ + i;
+
+                if (i == 0)
+                    return traits_type::eof();
+
+                return traits_type::to_int_type(*input_next_);
+            }
+
+            int_type uflow() override
+            {
+                auto res = underflow();
+                ++input_next_;
+
+                return res;
+            }
+
+            void imbue(const locale& loc)
+            {
+                this->locale_ = loc;
+            }
+
+        private:
+            FILE* in_{stdin};
+
+            char_type* buffer_;
+
+            static constexpr off_type buf_size_{128};
+    };
+
+    template<class Char, class Traits = char_traits<Char>>
+    class stdout_streambuf: public basic_streambuf<Char, Traits>
+    {
+        public:
+            stdout_streambuf()
+                : basic_streambuf<Char, Traits>{}
+            { /* DUMMY BODY */ }
+
+            virtual ~stdout_streambuf()
+            { /* DUMMY BODY */ }
+
+        protected:
+            using traits_type = Traits;
+            using char_type   = typename traits_type::char_type;
+            using int_type    = typename traits_type::int_type;
+            using off_type    = typename traits_type::off_type;
+
+            int_type overflow(int_type c = traits_type::eof()) override
+            {
+                if (!traits_type::eq_int_type(c, traits_type::eof()))
+                {
+                    auto cc = traits_type::to_char_type(c);
+                    fwrite(&cc, sizeof(char_type), 1, out_);
+                }
+
+                return traits_type::not_eof(c);
+            }
+
+            streamsize xsputn(const char_type* s, streamsize n) override
+            {
+                return fwrite(s, sizeof(char_type), n, out_);
+            }
+
+            int sync() override
+            {
+                if (fflush(out_))
+                    return -1;
+                return 0;
+            }
+
+        private:
+            FILE* out_{stdout};
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/string.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/string.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/string.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_STRING
+#define LIBCPP_BITS_STRING
+
+#include <ios>
+#include <string>
+
+namespace std
+{
+    /**
+     * 21.4.8.9, inserters and extractors:
+     */
+
+    template<class Char, class Traits, class Allocator>
+    basic_istream<Char, Traits>& operator>>(basic_istream<Char, Traits>& is,
+                                            basic_string<Char, Traits, Allocator>& str)
+    {
+        using sentry = typename basic_istream<Char, Traits>::sentry;
+        sentry sen{is, false};
+
+        if (sen)
+        {
+            str.erase();
+
+            auto max_size = is.width();
+            if (max_size <= 0)
+                max_size = static_cast<streamsize>(str.max_size());
+
+            streamsize i{};
+            for(; i < max_size; ++i)
+            {
+                auto ic = is.rdbuf()->sgetc();
+                if (Traits::eq_int_type(ic, Traits::eof()))
+                {
+                    is.setstate(ios_base::eofbit);
+                    break;
+                }
+
+                auto c = Traits::to_char_type(ic);
+                if(isspace(c, is.getloc()))
+                    break;
+
+                str.push_back(c);
+                is.rdbuf()->sbumpc();
+            }
+
+            if (i == 0)
+                is.setstate(ios_base::failbit);
+        }
+        else
+            is.setstate(ios_base::failbit);
+
+        return is;
+    }
+
+    template<class Char, class Traits, class Allocator>
+    basic_ostream<Char, Traits>& operator<<(basic_ostream<Char, Traits>& os,
+                                            const basic_string<Char, Traits, Allocator>& str)
+    {
+        // TODO: determine padding as described in 27.7.3.6.1
+        using sentry = typename basic_ostream<Char, Traits>::sentry;
+        sentry sen{os};
+
+        if (sen)
+        {
+            auto width = os.width();
+            auto size = str.size();
+
+            size_t to_pad{};
+            if (width > 0)
+                to_pad = (static_cast<size_t>(width) - size);
+
+            if (to_pad > 0)
+            {
+                if ((os.flags() & ios_base::adjustfield) != ios_base::left)
+                {
+                    for (std::size_t i = 0; i < to_pad; ++i)
+                        os.put(os.fill());
+                }
+
+                os.rdbuf()->sputn(str.data(), size);
+
+                if ((os.flags() & ios_base::adjustfield) == ios_base::left)
+                {
+                    for (std::size_t i = 0; i < to_pad; ++i)
+                        os.put(os.fill());
+                }
+            }
+            else
+                os.rdbuf()->sputn(str.data(), size);
+
+            os.width(0);
+        }
+
+        return os;
+    }
+
+    template<class Char, class Traits, class Allocator>
+    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>& is,
+                                         basic_string<Char, Traits, Allocator>& str,
+                                         Char delim)
+    {
+        typename basic_istream<Char, Traits>::sentry sen{is, true};
+
+        if (sen)
+        {
+            str.clear();
+            streamsize count{};
+
+            while (true)
+            {
+                auto ic = is.rdbuf()->sbumpc();
+                if (Traits::eq_int_type(ic, Traits::eof()))
+                {
+                    is.setstate(ios_base::eofbit);
+                    break;
+                }
+
+                auto c = Traits::to_char_type(ic);
+                if (Traits::eq(c, delim))
+                    break;
+
+                str.push_back(c);
+                ++count;
+
+                if (count >= static_cast<streamsize>(str.max_size()))
+                {
+                    is.setstate(ios_base::failbit);
+                    break;
+                }
+            }
+
+            if (count == 0)
+                is.setstate(ios_base::failbit);
+        }
+        else
+            is.setstate(ios_base::failbit);
+
+        return is;
+    }
+
+    template<class Char, class Traits, class Allocator>
+    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>&& is,
+                                         basic_string<Char, Traits, Allocator>& str,
+                                         Char delim)
+    {
+        return getline(is, str, delim);
+    }
+
+    template<class Char, class Traits, class Allocator>
+    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>& is,
+                                         basic_string<Char, Traits, Allocator>& str)
+    {
+        return getline(is, str, is.widen('\n'));
+    }
+
+    template<class Char, class Traits, class Allocator>
+    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>&& is,
+                                         basic_string<Char, Traits, Allocator>& str)
+    {
+        return getline(is, str, is.widen('\n'));
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/stringfwd.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/stringfwd.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/stringfwd.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_STRINGFWD
+#define LIBCPP_BITS_STRINGFWD
+
+namespace std
+{
+    template<class Char>
+    struct char_traits;
+
+    template<class T>
+    struct allocator;
+
+    template<
+        class Char,
+        class Traits = char_traits<Char>,
+        class Allocator = allocator<Char>
+    >
+    class basic_string;
+
+    using string  = basic_string<char>;
+    using wstring = basic_string<wchar_t>;
+
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/test/mock.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/test/mock.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/test/mock.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_TEST_MOCK
+#define LIBCPP_BITS_TEST_MOCK
+
+#include <cstdlib>
+#include <tuple>
+
+namespace std::test
+{
+    /**
+     * Auxiliary type that lets us to monitor the number
+     * of calls to various functions for the purposes
+     * of testing smart pointers and other features of
+     * the library.
+     */
+    struct mock
+    {
+        static size_t constructor_calls;
+        static size_t copy_constructor_calls;
+        static size_t destructor_calls;
+        static size_t move_constructor_calls;
+
+        mock()
+        {
+            ++constructor_calls;
+        }
+
+        mock(const mock&)
+        {
+            ++copy_constructor_calls;
+        }
+
+        mock(mock&&)
+        {
+            ++move_constructor_calls;
+        }
+
+        ~mock()
+        {
+            ++destructor_calls;
+        }
+
+        static void clear()
+        {
+            constructor_calls = size_t{};
+            copy_constructor_calls = size_t{};
+            destructor_calls = size_t{};
+            move_constructor_calls = size_t{};
+        }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/test/test.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/test/test.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/test/test.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_TEST_TEST
+#define LIBCPP_TEST_TEST
+
+#include <utility>
+#include <iterator>
+#include <type_traits>
+
+namespace std::test
+{
+    class test_suite
+    {
+        public:
+            virtual bool run(bool) = 0;
+            virtual const char* name() = 0;
+
+            virtual ~test_suite() = default;
+
+            unsigned int get_failed() const noexcept;
+
+            unsigned int get_succeeded() const noexcept;
+
+        protected:
+            void report(bool, const char*);
+            void start();
+            bool end();
+
+            unsigned int failed_{};
+            unsigned int succeeded_{};
+            bool ok_{true};
+            bool report_{true};
+
+            template<class... Args>
+            void test_eq(const char* tname, Args&&... args)
+            {
+                if (!assert_eq(std::forward<Args>(args)...))
+                {
+                    report(false, tname);
+                    ++failed_;
+                    ok_ = false;
+                }
+                else
+                {
+                    report(true, tname);
+                    ++succeeded_;
+                }
+            }
+
+            template<class T, class U>
+            bool assert_eq(const T& lhs, const U& rhs)
+            {
+                return lhs == rhs;
+            }
+
+            template<class Iterator1, class Iterator2>
+            bool assert_eq(Iterator1 first1, Iterator1 last1,
+                           Iterator2 first2, Iterator2 last2)
+            {
+                auto len1 = std::distance(first1, last1);
+                auto len2 = std::distance(first2, last2);
+
+                using common_t = std::common_type_t<decltype(len1), decltype(len2)>;
+                auto len1_common = static_cast<common_t>(len1);
+                auto len2_common = static_cast<common_t>(len2);
+
+                if (len1_common != len2_common)
+                    return false;
+
+                while (first1 != last1)
+                {
+                    if (*first1++ != *first2++)
+                        return false;
+                }
+
+                return true;
+            }
+
+            template<class Iterator, class Container>
+            void test_contains(const char* tname, Iterator first,
+                               Iterator last, const Container& cont)
+            {
+                if (!assert_contains(first, last, cont))
+                {
+                    report(false, tname);
+                    ++failed_;
+                    ok_ = false;
+                }
+                else
+                {
+                    report(true, tname);
+                    ++succeeded_;
+                }
+            }
+
+            template<class Iterator1, class Iterator2, class Container>
+            void test_contains_multi(const char* tname, Iterator1 first1,
+                               Iterator1 last1, Iterator2 first2,
+                               const Container& cont)
+            {
+                if (!assert_contains_multi(first1, last1, first2, cont))
+                {
+                    report(false, tname);
+                    ++failed_;
+                    ok_ = false;
+                }
+                else
+                {
+                    report(true, tname);
+                    ++succeeded_;
+                }
+            }
+
+            template<class Iterator, class Container>
+            bool assert_contains(Iterator first, Iterator last, const Container& cont)
+            {
+                while (first != last)
+                {
+                    if (cont.find(*first++) == cont.end())
+                        return false;
+                }
+
+                return true;
+            }
+
+            template<class Iterator1, class Iterator2, class Container>
+            bool assert_contains_multi(Iterator1 first1, Iterator1 last1,
+                                       Iterator2 first2, const Container& cont)
+            {
+                while (first1 != last1)
+                {
+                    if (cont.count(*first1++) != *first2++)
+                        return false;
+                }
+
+                return true;
+            }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/test/tests.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/test/tests.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/test/tests.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_TESTS
+#define LIBCPP_TESTS
+
+#include <cstdio>
+#include <__bits/test/test.hpp>
+#include <vector>
+
+namespace std::test
+{
+    class test_set
+    {
+        public:
+            test_set() = default;
+
+            template<class T>
+            void add()
+            {
+                tests_.push_back(new T{});
+            }
+
+            bool run(bool report)
+            {
+                bool res{true};
+                unsigned int succeeded{};
+                unsigned int failed{};
+
+                for (auto test: tests_)
+                {
+                    res &= test->run(report);
+                    succeeded += test->get_succeeded();
+                    failed += test->get_failed();
+                }
+
+                if (report)
+                {
+                    std::printf("\n");
+                    if (res)
+                        std::printf("[TESTS SUCCEEDED!]");
+                    else
+                        std::printf("[TESTS FAILED]");
+                    std::printf("[%u OK][%u FAIL][%u TOTAL]\n",
+                                succeeded, failed, (succeeded + failed));
+                }
+
+                return res;
+            }
+
+            ~test_set()
+            {
+                // TODO: Gimme unique_ptr!
+                for (auto ptr: tests_)
+                    delete ptr;
+            }
+        private:
+            std::vector<test_suite*> tests_{};
+    };
+
+    class array_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+            array_test() = default;
+            ~array_test() = default;
+    };
+
+    class vector_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+            vector_test() = default;
+            ~vector_test() = default;
+
+        private:
+            void test_construction_and_assignment();
+            void test_insert();
+            void test_erase();
+    };
+
+    class string_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_construction_and_assignment();
+            void test_append();
+            void test_insert();
+            void test_erase();
+            void test_replace();
+            void test_copy();
+            void test_find();
+            void test_substr();
+            void test_compare();
+    };
+
+    class bitset_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_constructors_and_assignment();
+            void test_strings();
+            void test_operations();
+    };
+
+    class deque_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_constructors_and_assignment();
+            void test_resizing();
+            void test_push_pop();
+            void test_operations();
+    };
+
+    class tuple_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_constructors_and_assignment();
+            void test_creation();
+            void test_tie_and_structured_bindings();
+            void test_tuple_ops();
+    };
+
+    class map_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_constructors_and_assignment();
+            void test_histogram();
+            void test_emplace_insert();
+            void test_bounds_and_ranges();
+            void test_multi();
+            void test_reverse_iterators();
+            void test_multi_bounds_and_ranges();
+    };
+
+    class set_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_constructors_and_assignment();
+            void test_emplace_insert();
+            void test_bounds_and_ranges();
+            void test_multi();
+            void test_reverse_iterators();
+            void test_multi_bounds_and_ranges();
+    };
+
+    class unordered_map_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_constructors_and_assignment();
+            void test_histogram();
+            void test_emplace_insert();
+            void test_multi();
+    };
+
+    class unordered_set_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_constructors_and_assignment();
+            void test_emplace_insert();
+            void test_multi();
+    };
+
+    class numeric_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_algorithms();
+            void test_complex();
+    };
+
+    class adaptors_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_queue();
+            void test_priority_queue();
+            void test_stack();
+    };
+
+    class memory_test: public test_suite
+    {
+        public:
+            bool run(bool) override;
+            const char* name() override;
+
+        private:
+            void test_unique_ptr();
+            void test_shared_ptr();
+            void test_weak_ptr();
+            void test_allocators();
+            void test_pointers();
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/thread.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/thread.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/thread.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_THREAD
+#define LIBCPP_BITS_THREAD
+
+namespace std::hel
+{
+    extern "C" {
+        #include <fibril.h>
+        #include <fibril_synch.h>
+    }
+}
+
+#include <chrono>
+
+namespace std::aux
+{
+    struct fibril_tag
+    { /* DUMMY BODY */ };
+
+    struct thread_tag
+    { /* DUMMY BODY */ };
+
+    template<class>
+    struct threading_policy;
+
+    template<>
+    struct threading_policy<fibril_tag>
+    {
+        using mutex_type        = hel::fibril_mutex_t;
+        using thread_type       = hel::fid_t;
+        using condvar_type      = hel::fibril_condvar_t;
+        using time_unit         = hel::suseconds_t;
+        using shared_mutex_type = hel::fibril_rwlock_t;
+
+        struct thread
+        {
+            template<class Callable, class Payload>
+            static thread_type create(Callable clbl, Payload& pld)
+            {
+                return hel::fibril_create(clbl, (void*)&pld);
+            }
+
+            static void start(thread_type thr)
+            {
+                hel::fibril_add_ready(thr);
+            }
+
+            static thread_type this_thread()
+            {
+                return hel::fibril_get_id();
+            }
+
+            static void yield()
+            {
+                hel::fibril_yield();
+            }
+
+            /**
+             * Note: join & detach are performed at the C++
+             *       level at the moment, but eventually should
+             *       be moved here once joinable fibrils are in libc.
+             */
+        };
+
+        struct mutex
+        {
+            static void init(mutex_type& mtx)
+            {
+                hel::fibril_mutex_initialize(&mtx);
+            }
+
+            static void lock(mutex_type& mtx)
+            {
+                hel::fibril_mutex_lock(&mtx);
+            }
+
+            static void unlock(mutex_type& mtx)
+            {
+                hel::fibril_mutex_unlock(&mtx);
+            }
+
+            static bool try_lock(mutex_type& mtx)
+            {
+                return hel::fibril_mutex_trylock(&mtx);
+            }
+
+            static bool try_lock_for(mutex_type& mtx, time_unit timeout)
+            {
+                // TODO: we need fibril_mutex_trylock_for() :/
+                return try_lock(mtx);
+            }
+        };
+
+        struct condvar
+        {
+            static void init(condvar_type& cv)
+            {
+                hel::fibril_condvar_initialize(&cv);
+            }
+
+            static void wait(condvar_type& cv, mutex_type& mtx)
+            {
+                hel::fibril_condvar_wait(&cv, &mtx);
+            }
+
+            static int wait_for(condvar_type& cv, mutex_type& mtx, time_unit timeout)
+            {
+                return hel::fibril_condvar_wait_timeout(&cv, &mtx, timeout);
+            }
+
+            static void signal(condvar_type& cv)
+            {
+                hel::fibril_condvar_signal(&cv);
+            }
+
+            static void broadcast(condvar_type& cv)
+            {
+                hel::fibril_condvar_broadcast(&cv);
+            }
+        };
+
+        struct time
+        {
+            template<class Rep, class Period>
+            static time_unit convert(const std::chrono::duration<Rep, Period>& dur)
+            {
+                return std::chrono::duration_cast<std::chrono::duration<Rep, micro>>(dur).count();
+            }
+
+            static void sleep(time_unit time)
+            {
+                hel::fibril_usleep(time);
+            }
+        };
+
+        struct shared_mutex
+        {
+            static void init(shared_mutex_type& mtx)
+            {
+                hel::fibril_rwlock_initialize(&mtx);
+            }
+
+            static void lock(shared_mutex_type& mtx)
+            {
+                hel::fibril_rwlock_write_lock(&mtx);
+            }
+
+            static void unlock(shared_mutex_type& mtx)
+            {
+                hel::fibril_rwlock_write_unlock(&mtx);
+            }
+
+            static void lock_shared(shared_mutex_type& mtx)
+            {
+                hel::fibril_rwlock_read_lock(&mtx);
+            }
+
+            static void unlock_shared(shared_mutex_type& mtx)
+            {
+                hel::fibril_rwlock_read_unlock(&mtx);
+            }
+
+            static bool try_lock(shared_mutex_type& mtx)
+            {
+                // TODO: rwlocks don't have try locking capabilities
+                lock(mtx);
+
+                return true;
+            }
+
+            static bool try_lock_shared(shared_mutex_type& mtx)
+            {
+                lock(mtx);
+
+                return true;
+            }
+
+            static bool try_lock_for(shared_mutex_type& mtx, time_unit timeout)
+            {
+                return try_lock(mtx);
+            }
+
+            static bool try_lock_shared_for(shared_mutex_type& mtx, time_unit timeout)
+            {
+                return try_lock(mtx);
+            }
+        };
+    };
+
+    template<>
+    struct threading_policy<thread_tag>
+    {
+        // TODO:
+    };
+
+    using default_tag = fibril_tag;
+    using threading = threading_policy<default_tag>;
+
+    using thread_t       = typename threading::thread_type;
+    using mutex_t        = typename threading::mutex_type;
+    using condvar_t      = typename threading::condvar_type;
+    using time_unit_t    = typename threading::time_unit;
+    using shared_mutex_t = typename threading::shared_mutex_type;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/trycatch.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/trycatch.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/trycatch.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_TRYCATCH
+#define LIBCPP_BITS_TRYCATCH
+
+// TODO: This header should be included in every libcpp header.
+
+/**
+ * For the time that exception support is not present
+ * in HelenOS, we use mock macros in place of the keywords
+ * try, throw and catch that allow us to atleast partially
+ * mimic exception functionality (that is, without propagation
+ * and stack unwinding).
+ * The value of the macro below determines if the keyword
+ * hiding macros get defined.
+ */
+#define LIBCPP_EXCEPTIONS_SUPPORTED 0
+
+#if LIBCPP_EXCEPTIONS_SUPPORTED == 0
+
+/**
+ * In case the file where our macros get expanded
+ * does not include cstdlib.
+ */
+extern "C" void abort(void) __attribute__((noreturn));
+extern "C" int printf(const char*, ...);
+
+namespace std
+{
+    namespace aux
+    {
+        /**
+         * Monitors the state of the program with
+         * regards to exceptions.
+         */
+        extern bool exception_thrown;
+
+        inline constexpr bool try_blocks_allowed{true};
+    }
+}
+
+/**
+ * These macros allow us to choose how the program
+ * should behave when an exception is thrown
+ * (LIBCPP_EXCEPTION_HANDLE_THROW) or caught
+ * (LIBCPP_EXCEPTION_HANDLE_CATCH).
+ * We also provide three handlers that either
+ * hang the program (allowing us to read the
+ * message), exit the program (allowing us to
+ * redirect the message to some output file and
+ * end) or ignore the throw (in which case the
+ * state of program will be broken, but since
+ * we output messages on both and catch, this option
+ * might allow us to see which catch statement
+ * catches the "thrown exception" (supposing
+ * the program doesn't crash before reaching
+ * that statement.
+ */
+#define LIBCPP_EXCEPTION_HANG         while (true);
+#define LIBCPP_EXCEPTION_ABORT        ::std::abort();
+#define LIBCPP_EXCEPTION_IGNORE       /* IGNORE */
+#define LIBCPP_EXCEPTION_HANDLE_THROW LIBCPP_EXCEPTION_IGNORE
+#define LIBCPP_EXCEPTION_HANDLE_CATCH LIBCPP_EXCEPTION_HANG
+
+#define try if constexpr (::std::aux::try_blocks_allowed)
+
+#define throw \
+    do {\
+        ::std::aux::exception_thrown = true; \
+        printf("[EXCEPTION] Thrown at %s:%d\n", __FILE__, __LINE__); \
+        LIBCPP_EXCEPTION_HANDLE_THROW \
+    } while (false);
+
+#define catch(expr) \
+    if (::std::aux::exception_thrown) \
+    { \
+        printf("[EXCEPTION] Caught < "#expr" > at %s:%d\n", __FILE__, __LINE__); \
+        ::std::aux::exception_thrown = false; \
+        LIBCPP_EXCEPTION_HANDLE_CATCH \
+    } \
+    if constexpr (false)
+
+/**
+ * This macro can be used for testing the library. If
+ * exception handling is not available, it uses the
+ * internal bool variable and if it is, it uses a
+ * universal catch clause in which it sets the passed
+ * checking variable to true.
+ */
+#define LIBCPP_EXCEPTION_THROW_CHECK(variable) \
+    variable = ::std::aux::exception_thrown
+
+#else
+#define LIBCPP_EXCEPTION_THROW_CHECK(variable) \
+    catch (...) \
+    { \
+        variable = true; \
+    }
+#endif
+
+#endif
Index: uspace/lib/cpp/include/__bits/tuple/tuple_cat.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/tuple/tuple_cat.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/tuple/tuple_cat.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_TUPLE_TUPLE_CAT
+#define LIBCPP_BITS_TUPLE_TUPLE_CAT
+
+#include <utility>
+
+namespace std
+{ // forward declarations
+    template<class... Ts>
+    struct tuple;
+
+    template<size_t I, class T>
+    struct tuple_element;
+
+    template<size_t I, class... Ts>
+    constexpr typename tuple_element<I, tuple<Ts...>>::type& get(tuple<Ts...>& tpl) noexcept;
+
+    template<class T, T...>
+    struct integer_sequence;
+
+    template<size_t... Is>
+    using index_sequence = integer_sequence<size_t, Is...>;
+}
+
+namespace std::aux
+{
+    template<class...>
+    struct tuple_append;
+
+    template<class... Ts, class... Us, class... Vs>
+    struct tuple_append<tuple<Ts...>, tuple<Us...>, Vs...>
+        : type_is<tuple<Ts..., Us...>>
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using tuple_append_t = typename tuple_append<Ts...>::type;
+
+    template<class...>
+    struct remove_first_tuple;
+
+    template<class... Ts, class... Tuples>
+    struct remove_first_tuple<tuple<Ts...>, Tuples...>
+        : type_is<Tuples...>
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using remove_first_tuple_t = typename remove_first_tuple<Ts...>::type;
+
+    template<class...>
+    struct get_first_tuple;
+
+    template<class... Ts, class... Tuples>
+    struct get_first_tuple<tuple<Ts...>, Tuples...>
+        : type_is<tuple<Ts...>>
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using get_first_tuple_t = typename get_first_tuple<Ts...>::type;
+
+    template<class...>
+    struct tuple_cat_type_impl;
+
+    template<class... Ts, class... Tuples>
+    struct tuple_cat_type_impl<tuple<Ts...>, Tuples...>
+        : type_is<
+        typename tuple_cat_type_impl<
+            tuple_append_t<tuple<Ts...>, get_first_tuple_t<Tuples...>>,
+            remove_first_tuple_t<Tuples...>
+        >::type
+    >
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using tuple_cat_type_impl_t = typename tuple_cat_type_impl<Ts...>::type;
+
+    template<class...>
+    struct tuple_cat_type;
+
+    template<class... Ts, class... Tuples>
+    struct tuple_cat_type<tuple<Ts...>, Tuples...>
+        : type_is<tuple_cat_type_impl_t<tuple<Ts...>, Tuples...>>
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using tuple_cat_type_t = typename tuple_cat_type<Ts...>::type;
+
+    template<class...>
+    struct concatenate_sequences;
+
+    template<size_t... Is1, size_t... Is2>
+    struct concatenate_sequences<index_sequence<Is1...>, index_sequence<Is2...>>
+        : type_is<index_sequence<Is1..., Is2...>>
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using concatenate_sequences_t = typename concatenate_sequences<Ts...>::type;
+
+    template<class...>
+    struct append_indices;
+
+    template<size_t... Is, class... Ts, class... Tuples>
+    struct append_indices<index_sequence<Is...>, tuple<Ts...>, Tuples...>
+        : append_indices<
+        concatenate_sequences_t<
+            index_sequence<Is...>, make_index_sequence<sizeof...(Ts)>
+        >,
+        Tuples...
+    >
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using append_indices_t = typename append_indices<Ts...>::types;
+
+    template<class...>
+    struct generate_indices;
+
+    template<class... Ts, class... Tuples>
+    struct generate_indices<tuple<Ts...>, Tuples...>
+        : type_is<
+        append_indices_t<
+            make_index_sequence<sizeof...(Ts)>,
+            Tuples...
+        >
+    >
+    { /* DUMMY BODY */ };
+
+    template<class... Ts>
+    using generate_indices_t = typename generate_indices<Ts...>::type;
+
+    template<class... Tuples, size_t... Is1, size_t... Is2>
+    tuple_cat_type_t<Tuples...> tuple_cat(Tuples&&... tpls,
+                                          index_sequence<Is1...>,
+                                          index_sequence<Is2...>)
+    {
+        return tuple_cat_type_t<Tuples...>{
+            get<Is1...>(
+                get<Is2...>(
+                    forward<Tuples>(tpls)
+                )
+            )...
+        };
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/tuple/tuple_ops.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/tuple/tuple_ops.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/tuple/tuple_ops.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_TUPLE_TUPLE_OPS
+#define LIBCPP_BITS_TUPLE_TUPLE_OPS
+
+#include <utility>
+
+namespace std
+{ // forward declarations
+    template<class... Ts>
+    struct tuple;
+
+    template<size_t I, class T>
+    struct tuple_element;
+
+    template<size_t I, class... Ts>
+    constexpr typename tuple_element<I, tuple<Ts...>>::type& get(tuple<Ts...>& tpl) noexcept;
+}
+
+namespace std::aux
+{
+    template<size_t I, size_t N>
+    struct tuple_ops
+    {
+        template<class T, class U>
+        static void assign_copy(T& lhs, const U& rhs)
+        {
+            get<I>(lhs) = get<I>(rhs);
+
+            tuple_ops<I + 1, N>::assign_copy(lhs, rhs);
+        }
+
+        template<class T, class U>
+        static void assign_move(T& lhs, U&& rhs)
+        {
+            get<I>(lhs) = move(get<I>(rhs));
+
+            tuple_ops<I + 1, N>::assign_move(lhs, move(rhs));
+        }
+
+        template<class T, class U>
+        static void swap(T& lhs, U& rhs)
+        {
+            std::swap(get<I>(lhs), get<I>(rhs));
+
+            tuple_ops<I + 1, N>::swap(lhs, rhs);
+        }
+
+        template<class T, class U>
+        static bool eq(const T& lhs, const U& rhs)
+        {
+            return (get<I>(lhs) == get<I>(rhs)) && tuple_ops<I + 1, N>::eq(lhs, rhs);
+        }
+
+        template<class T, class U>
+        static bool lt(const T& lhs, const U& rhs)
+        {
+            return (get<I>(lhs) < get<I>(rhs)) ||
+                (!(get<I>(rhs) < get<I>(lhs)) && tuple_ops<I + 1, N>::lt(lhs, rhs));
+        }
+    };
+
+    template<size_t N>
+    struct tuple_ops<N, N>
+    {
+        template<class T, class U>
+        static void assign_copy(T& lhs, const U& rhs)
+        {
+            get<N>(lhs) = get<N>(rhs);
+        }
+
+        template<class T, class U>
+        static void assign_move(T& lhs, U&& rhs)
+        {
+            get<N>(lhs) = move(get<N>(rhs));
+        }
+
+        template<class T, class U>
+        static void swap(T& lhs, U& rhs)
+        {
+            std::swap(get<N>(lhs), get<N>(rhs));
+        }
+
+        template<class T, class U>
+        static bool eq(const T& lhs, const U& rhs)
+        {
+            return get<N>(lhs) == get<N>(rhs);
+        }
+
+        template<class T, class U>
+        static bool lt(const T& lhs, const U& rhs)
+        {
+            return get<N>(lhs) < get<N>(rhs);
+        }
+    };
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/type_traits/references.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/type_traits/references.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/type_traits/references.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_TYPE_TRAITS_REFERENCES
+#define LIBCPP_BITS_TYPE_TRAITS_REFERENCES
+
+#include <__bits/aux.hpp>
+
+namespace std
+{
+    /**
+     * 20.10.7.2, reference modifications:
+     */
+
+    template<class T>
+    struct remove_reference: aux::type_is<T>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct remove_reference<T&>: aux::type_is<T>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct remove_reference<T&&>: aux::type_is<T>
+    { /* DUMMY BODY */ };
+
+    // TODO: is this good?
+    template<class T>
+    struct add_lvalue_reference: aux::type_is<T&>
+    { /* DUMMY BODY */ };
+
+    // TODO: Special case when T is not referencable!
+    template<class T>
+    struct add_rvalue_reference: aux::type_is<T&&>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct add_rvalue_reference<T&>: aux::type_is<T&>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    using remove_reference_t = typename remove_reference<T>::type;
+
+    template<class T>
+    using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
+
+    template<class T>
+    using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/type_traits/result_of.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/type_traits/result_of.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/type_traits/result_of.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_TYPE_TRAITS_RESULT_OF
+#define LIBCPP_BITS_TYPE_TRAITS_RESULT_OF
+
+#include <__bits/functional/invoke.hpp>
+
+namespace std
+{
+    template<class>
+    struct is_function;
+
+    template<class>
+    struct is_class;
+
+    template<class>
+    struct is_member_pointer;
+
+    template<bool, class>
+    struct enable_if;
+
+    template<class>
+    struct decay;
+
+    template<class>
+    struct remove_pointer;
+
+    template<class>
+    struct result_of
+    { /* DUMMY BODY */ };
+
+    template<class F, class... ArgTypes>
+    struct result_of<F(ArgTypes...)>: aux::type_is<
+        typename enable_if<
+            is_function<typename decay<typename remove_pointer<F>::type>::type>::value ||
+            is_class<typename decay<F>::type>::value ||
+            is_member_pointer<typename decay<F>::type>::value,
+            decltype(aux::invoke(declval<F>(), declval<ArgTypes>()...))
+        >::type
+    >
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    using result_of_t = typename result_of<T>::type;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/type_transformation.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/type_transformation.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/type_transformation.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_TYPE_TRANSFORMATION
+#define LIBCPP_BITS_TYPE_TRANSFORMATION
+
+#include <__bits/aux.hpp>
+#include <type_traits>
+
+namespace std
+{
+    template<class>
+    class reference_wrapper;
+}
+
+namespace std::aux
+{
+    /**
+     * Used by tuple to decay reference wrappers to references
+     * in make_tuple.
+     */
+
+    template<class T>
+    struct remove_reference_wrapper: type_is<T>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    struct remove_reference_wrapper<reference_wrapper<T>>: type_is<T&>
+    { /* DUMMY BODY */ };
+
+    template<class T>
+    using remove_reference_wrapper_t = typename remove_reference_wrapper<T>::type;
+
+    template<class T>
+    using transform_tuple_types_t = remove_reference_wrapper_t<decay_t<T>>;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/utility/declval.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/utility/declval.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/utility/declval.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_UTILITY_DECLVAL
+#define LIBCPP_BITS_UTILITY_DECLVAL
+
+#include <__bits/type_traits/references.hpp>
+
+namespace std
+{
+    /**
+     * 20.2.5, function template declval:
+     * Note: This function only needs declaration, not
+     *       implementation.
+     */
+
+    template<class T>
+    add_rvalue_reference_t<T> declval() noexcept;
+}
+
+#endif
Index: uspace/lib/cpp/include/__bits/utility/forward_move.hpp
===================================================================
--- uspace/lib/cpp/include/__bits/utility/forward_move.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/include/__bits/utility/forward_move.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBCPP_BITS_UTILITY_FORWARD_MOVE
+#define LIBCPP_BITS_UTILITY_FORWARD_MOVE
+
+#include <__bits/type_traits/references.hpp>
+
+namespace std
+{
+    /**
+     * 20.2.4, forward/move helpers:
+     */
+
+    template<class T>
+    constexpr T&& forward(remove_reference_t<T>& t) noexcept
+    {
+        return static_cast<T&&>(t);
+    }
+
+    template<class T>
+    constexpr T&& forward(remove_reference_t<T>&& t) noexcept
+    {
+        return static_cast<T&&>(t);
+    }
+
+    template<class T>
+    constexpr remove_reference_t<T>&& move(T&& t) noexcept
+    {
+        return static_cast<remove_reference_t<T>&&>(t);
+    }
+}
+
+#endif
Index: uspace/lib/cpp/include/cassert
===================================================================
--- uspace/lib/cpp/include/cassert	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cassert	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CASSERT
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cctype
===================================================================
--- uspace/lib/cpp/include/cctype	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cctype	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CCTYPE
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cerrno
===================================================================
--- uspace/lib/cpp/include/cerrno	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cerrno	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CERRNO
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cinttypes
===================================================================
--- uspace/lib/cpp/include/cinttypes	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cinttypes	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CINTTYPES
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/climits
===================================================================
--- uspace/lib/cpp/include/climits	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/climits	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CLIMITS
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/csetjmp
===================================================================
--- uspace/lib/cpp/include/csetjmp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/csetjmp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CSETJMP
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cstdarg
===================================================================
--- uspace/lib/cpp/include/cstdarg	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cstdarg	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CSTDARG
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cstddef
===================================================================
--- uspace/lib/cpp/include/cstddef	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cstddef	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CSTDDEF
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cstdint
===================================================================
--- uspace/lib/cpp/include/cstdint	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cstdint	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CSTDINT
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cstdio
===================================================================
--- uspace/lib/cpp/include/cstdio	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cstdio	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CSTDIO
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
@@ -42,4 +42,7 @@
 {
     using std::hel::FILE;
+    using std::hel::stdin;
+    using std::hel::stdout;
+    using std::hel::stderr;
     /* using std::hel::fpos_t */
     using std::hel::size_t;
Index: uspace/lib/cpp/include/cstdlib
===================================================================
--- uspace/lib/cpp/include/cstdlib	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cstdlib	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CSTDLIB
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cstring
===================================================================
--- uspace/lib/cpp/include/cstring	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cstring	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CSTRING
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/ctime
===================================================================
--- uspace/lib/cpp/include/ctime	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/ctime	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CTIME
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/cwchar
===================================================================
--- uspace/lib/cpp/include/cwchar	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/cwchar	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_WCHAR
 
-#include "internal/common.hpp"
+#include <__bits/common.hpp>
 
 namespace std::hel
Index: uspace/lib/cpp/include/functional
===================================================================
--- uspace/lib/cpp/include/functional	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/functional	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -28,8 +28,8 @@
 
 #include <impl/functional.hpp>
-#include <internal/functional/arithmetic_operations.hpp>
-#include <internal/functional/bind.hpp>
-#include <internal/functional/function.hpp>
-#include <internal/functional/invoke.hpp>
-#include <internal/functional/hash.hpp>
-#include <internal/functional/reference_wrapper.hpp>
+#include <__bits/functional/arithmetic_operations.hpp>
+#include <__bits/functional/bind.hpp>
+#include <__bits/functional/function.hpp>
+#include <__bits/functional/invoke.hpp>
+#include <__bits/functional/hash.hpp>
+#include <__bits/functional/reference_wrapper.hpp>
Index: uspace/lib/cpp/include/impl/condition_variable.hpp
===================================================================
--- uspace/lib/cpp/include/impl/condition_variable.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/condition_variable.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_CONDITION_VARIABLE
 
-#include <internal/thread.hpp>
+#include <__bits/thread.hpp>
 #include <mutex>
 
Index: uspace/lib/cpp/include/impl/deque.hpp
===================================================================
--- uspace/lib/cpp/include/impl/deque.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/deque.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -32,5 +32,5 @@
 #include <algorithm>
 #include <initializer_list>
-#include <internal/insert_iterator.hpp>
+#include <__bits/insert_iterator.hpp>
 #include <iterator>
 #include <memory>
Index: uspace/lib/cpp/include/impl/exception.hpp
===================================================================
--- uspace/lib/cpp/include/impl/exception.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/exception.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_EXCEPTION
 
-#include <internal/trycatch.hpp>
+#include <__bits/trycatch.hpp>
 
 namespace std
Index: uspace/lib/cpp/include/impl/functional.hpp
===================================================================
--- uspace/lib/cpp/include/impl/functional.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/functional.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,6 +30,6 @@
 #define LIBCPP_FUNCTIONAL
 
-#include <internal/functional/conditional_function_typedefs.hpp>
-#include <internal/functional/invoke.hpp>
+#include <__bits/functional/conditional_function_typedefs.hpp>
+#include <__bits/functional/invoke.hpp>
 #include <limits>
 #include <memory>
Index: uspace/lib/cpp/include/impl/iomanip.hpp
===================================================================
--- uspace/lib/cpp/include/impl/iomanip.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/iomanip.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,5 +30,5 @@
 #define LIBCPP_IOMANIP
 
-#include <internal/iomanip.hpp>
+#include <__bits/iomanip.hpp>
 #include <iosfwd>
 
Index: uspace/lib/cpp/include/impl/ios.hpp
===================================================================
--- uspace/lib/cpp/include/impl/ios.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/ios.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,6 +31,6 @@
 
 #include <cstdlib>
-#include <internal/locale.hpp>
-#include <internal/locale/ctype.hpp>
+#include <__bits/locale.hpp>
+#include <__bits/locale/ctype.hpp>
 #include <iosfwd>
 #include <system_error>
Index: uspace/lib/cpp/include/impl/iterator.hpp
===================================================================
--- uspace/lib/cpp/include/impl/iterator.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/iterator.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -32,5 +32,5 @@
 #include <cstdlib>
 #include <initializer_list>
-#include <internal/memory/addressof.hpp>
+#include <__bits/memory/addressof.hpp>
 #include <iosfwd>
 #include <type_traits>
Index: uspace/lib/cpp/include/impl/list.hpp
===================================================================
--- uspace/lib/cpp/include/impl/list.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/list.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,5 +31,5 @@
 
 #include <cstdlib>
-#include <internal/list.hpp>
+#include <__bits/list.hpp>
 #include <iterator>
 #include <memory>
Index: uspace/lib/cpp/include/impl/locale.hpp
===================================================================
--- uspace/lib/cpp/include/impl/locale.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/locale.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -35,9 +35,9 @@
 #include <string>
 
-#include <internal/locale.hpp>
-#include <internal/locale/ctype.hpp>
-#include <internal/locale/num_get.hpp>
-#include <internal/locale/num_put.hpp>
-#include <internal/locale/numpunct.hpp>
+#include <__bits/locale.hpp>
+#include <__bits/locale/ctype.hpp>
+#include <__bits/locale/num_get.hpp>
+#include <__bits/locale/num_put.hpp>
+#include <__bits/locale/numpunct.hpp>
 
 namespace std
Index: uspace/lib/cpp/include/impl/map.hpp
===================================================================
--- uspace/lib/cpp/include/impl/map.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/map.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,5 +31,5 @@
 
 #include <functional>
-#include <internal/rbtree.hpp>
+#include <__bits/rbtree.hpp>
 #include <iterator>
 #include <memory>
Index: uspace/lib/cpp/include/impl/mutex.hpp
===================================================================
--- uspace/lib/cpp/include/impl/mutex.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/mutex.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,6 +31,6 @@
 
 #include <functional>
-#include <internal/common.hpp>
-#include <internal/thread.hpp>
+#include <__bits/common.hpp>
+#include <__bits/thread.hpp>
 #include <thread>
 
Index: uspace/lib/cpp/include/impl/random.hpp
===================================================================
--- uspace/lib/cpp/include/impl/random.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/random.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -34,5 +34,5 @@
 #include <ctime>
 #include <initializer_list>
-#include <internal/builtins.hpp>
+#include <__bits/builtins.hpp>
 #include <limits>
 #include <type_traits>
Index: uspace/lib/cpp/include/impl/set.hpp
===================================================================
--- uspace/lib/cpp/include/impl/set.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/set.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,5 +31,5 @@
 
 #include <functional>
-#include <internal/rbtree.hpp>
+#include <__bits/rbtree.hpp>
 #include <iterator>
 #include <memory>
Index: uspace/lib/cpp/include/impl/stdexcept.hpp
===================================================================
--- uspace/lib/cpp/include/impl/stdexcept.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/stdexcept.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -32,5 +32,5 @@
 #include <exception>
 #include <iosfwd>
-#include <internal/stringfwd.hpp>
+#include <__bits/stringfwd.hpp>
 
 namespace std
Index: uspace/lib/cpp/include/impl/string.hpp
===================================================================
--- uspace/lib/cpp/include/impl/string.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/string.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -38,5 +38,5 @@
 #include <cwchar>
 #include <memory>
-#include <internal/stringfwd.hpp>
+#include <__bits/stringfwd.hpp>
 #include <utility>
 
Index: uspace/lib/cpp/include/impl/system_error.hpp
===================================================================
--- uspace/lib/cpp/include/impl/system_error.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/system_error.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,6 +30,6 @@
 #define LIBCPP_SYSTEM_ERROR
 
-#include <internal/aux.hpp>
-#include <internal/stringfwd.hpp>
+#include <__bits/aux.hpp>
+#include <__bits/stringfwd.hpp>
 #include <stdexcept>
 
Index: uspace/lib/cpp/include/impl/thread.hpp
===================================================================
--- uspace/lib/cpp/include/impl/thread.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/thread.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,6 +31,6 @@
 
 #include <chrono>
-#include <internal/common.hpp>
-#include <internal/thread.hpp>
+#include <__bits/common.hpp>
+#include <__bits/thread.hpp>
 #include <ostream>
 
Index: uspace/lib/cpp/include/impl/tuple.hpp
===================================================================
--- uspace/lib/cpp/include/impl/tuple.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/tuple.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -30,8 +30,8 @@
 #define LIBCPP_TUPLE
 
-#include <internal/aux.hpp>
-#include <internal/tuple/tuple_cat.hpp>
-#include <internal/tuple/tuple_ops.hpp>
-#include <internal/type_transformation.hpp>
+#include <__bits/aux.hpp>
+#include <__bits/tuple/tuple_cat.hpp>
+#include <__bits/tuple/tuple_ops.hpp>
+#include <__bits/type_transformation.hpp>
 #include <functional>
 #include <type_traits>
Index: uspace/lib/cpp/include/impl/type_traits.hpp
===================================================================
--- uspace/lib/cpp/include/impl/type_traits.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/type_traits.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -33,6 +33,6 @@
 #include <cstddef>
 #include <cstdint>
-#include <internal/aux.hpp>
-#include <internal/type_traits/references.hpp>
+#include <__bits/aux.hpp>
+#include <__bits/type_traits/references.hpp>
 
 namespace std
Index: uspace/lib/cpp/include/impl/unordered_map.hpp
===================================================================
--- uspace/lib/cpp/include/impl/unordered_map.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/unordered_map.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,5 +31,5 @@
 
 #include <initializer_list>
-#include <internal/hash_table.hpp>
+#include <__bits/hash_table.hpp>
 #include <functional>
 #include <memory>
Index: uspace/lib/cpp/include/impl/unordered_set.hpp
===================================================================
--- uspace/lib/cpp/include/impl/unordered_set.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/unordered_set.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,5 +31,5 @@
 
 #include <initializer_list>
-#include <internal/hash_table.hpp>
+#include <__bits/hash_table.hpp>
 #include <functional>
 #include <memory>
Index: uspace/lib/cpp/include/impl/utility.hpp
===================================================================
--- uspace/lib/cpp/include/impl/utility.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/impl/utility.hpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,6 +31,6 @@
 
 #include <cstdint>
-#include <internal/type_transformation.hpp>
-#include <internal/utility/forward_move.hpp>
+#include <__bits/type_transformation.hpp>
+#include <__bits/utility/forward_move.hpp>
 #include <type_traits>
 
Index: pace/lib/cpp/include/internal/abi.hpp
===================================================================
--- uspace/lib/cpp/include/internal/abi.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,158 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <cstdint>
-#include <typeinfo>
-
-namespace __cxxabiv1
-{
-    /**
-     * Static constructor/destructor helpers.
-     */
-
-    extern "C" int __cxa_atexit(void (*)(void*), void*, void*);
-
-    extern "C" void __cxa_finalize(void*);
-
-    /**
-     * Itanium C++ ABI type infos.
-     * See section 2.9.4 (RTTI Layout) of the Itanium C++ ABI spec.
-     *
-     * Note: The memory representation of these classes must not
-     *       be modified! (Wel, no modifications at all shall be done.)
-     *
-     * Source: https://itanium-cxx-abi.github.io/cxx-abi/abi.html
-     */
-
-    class __fundamental_type_info: public std::type_info
-    {
-        public:
-            virtual ~__fundamental_type_info();
-    };
-
-    class __array_type_info: public std::type_info
-    {
-        public:
-            virtual ~__array_type_info();
-    };
-
-    class __function_type_info: public std::type_info
-    {
-        public:
-            virtual ~__function_type_info();
-    };
-
-    class __enum_type_info: public std::type_info
-    {
-        public:
-            virtual ~__enum_type_info();
-    };
-
-    class __class_type_info: public std::type_info
-    {
-        public:
-            virtual ~__class_type_info();
-    };
-
-    class __si_class_type_info: public __class_type_info
-    {
-        public:
-            virtual ~__si_class_type_info();
-
-            const __class_type_info* __base_type;
-    };
-
-    struct __base_class_type_info
-    {
-        const __class_type_info* __base_type;
-        long __offset_flags;
-
-        enum __ofset_flags_masks
-        {
-            __virtual_mask = 0x1,
-            __public_mask =  0x2,
-            __offset_shift = 0x8
-        };
-    };
-
-    class __vmi_class_type_info: public __class_type_info
-    {
-        public:
-            virtual ~__vmi_class_type_info();
-
-            std::uint32_t __flags;
-            std::uint32_t __base_count;
-
-            __base_class_type_info __base_info[1];
-
-            enum __flags_mask
-            {
-                __non_diamond_repeat_mask = 0x1,
-                __diamond_shaped_mask     = 0x2
-            };
-    };
-
-    class __pbase_type_info: public std::type_info
-    {
-        public:
-            virtual ~__pbase_type_info();
-
-            std::uint32_t __flags;
-            const std::type_info* __pointee;
-
-            enum __masks
-            {
-                __const_mask            = 0x01,
-                __volatile_mask         = 0x02,
-                __restrict_mask         = 0x04,
-                __incomplete_mask       = 0x08,
-                __incomplete_class_mask = 0x10,
-                __transaction_safe_mask = 0x20,
-                __noexcept_mask         = 0x40
-            };
-    };
-
-    class __pointer_type_info: public __pbase_type_info
-    {
-        public:
-            virtual ~__pointer_type_info();
-    };
-
-    class __pointer_to_member_type_info: public __pbase_type_info
-    {
-        public:
-            virtual ~__pointer_to_member_type_info();
-
-            const __class_type_info* __context;
-    };
-
-    extern "C" void* __dynamic_cast(const void*, const __class_type_info*,
-                                    const __class_type_info*, std::ptrdiff_t);
-}
-
-namespace abi = __cxxabiv1;
Index: pace/lib/cpp/include/internal/aux.hpp
===================================================================
--- uspace/lib/cpp/include/internal/aux.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,91 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_AUX
-#define LIBCPP_AUX
-
-namespace std
-{
-    /**
-     * 20.10.3, helper class:
-     */
-
-    template<class T, T v>
-    struct integral_constant
-    {
-        static constexpr T value = v;
-
-        using value_type = T;
-        using type       = integral_constant<T, v>;
-
-        constexpr operator value_type() const noexcept
-        {
-            return value;
-        }
-
-        constexpr value_type operator()() const noexcept
-        {
-            return value;
-        }
-    };
-
-    using true_type = integral_constant<bool, true>;
-    using false_type = integral_constant<bool, false>;
-}
-
-namespace std::aux
-{
-    /**
-     * Two very handy templates, this allows us
-     * to easily follow the T::type and T::value
-     * convention by simply inheriting from specific
-     * instantiations of these templates.
-     * Examples:
-     *  1) We need a struct with int typedef'd to type:
-     *
-     *      stuct has_type_int: aux::type<int> {};
-     *      typename has_type_int::type x = 1; // x is of type int
-     *
-     *  2) We need a struct with static size_t member called value:
-     *
-     *      struct has_value_size_t: aux::value<size_t, 1u> {};
-     *      std::printf("%u\n", has_value_size_t::value); // prints "1\n"
-     */
-
-    template<class T>
-    struct type_is
-    {
-        using type = T;
-    };
-
-    // For compatibility with integral_constant.
-    template<class T, T v>
-    using value_is = std::integral_constant<T, v>;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/builtins.hpp
===================================================================
--- uspace/lib/cpp/include/internal/builtins.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,87 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_BUILTINS
-#define LIBCPP_INTERNAL_BUILTINS
-
-/**
- * Note: While the primary target of libcpp is the
- *       g++ compiler, using builtin functions that would
- *       unnecessarily limit the library to any specific
- *       compiler is discouraged and as such all the used
- *       builtins should be available atleast in g++ and
- *       clang++.
- * GCC:  https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
- * LLVM: https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/Builtins.def
- *       (If anyone has a better link for LLVM, feel free to update it.)
- */
-
-#include <cstdlib>
-
-namespace std::aux
-{
-    template<class T>
-    constexpr double log2(T val)
-    {
-        return __builtin_log2(static_cast<double>(val));
-    }
-
-    template<class T>
-    constexpr double pow2(T exp)
-    {
-        return __builtin_pow(2.0, static_cast<double>(exp));
-    }
-
-    template<class T>
-    constexpr size_t pow2u(T exp)
-    {
-        return static_cast<size_t>(pow2(exp));
-    }
-
-    template<class T, class U>
-    constexpr T pow(T base, U exp)
-    {
-        return static_cast<T>(
-            __builtin_pow(static_cast<double>(base), static_cast<double>(exp))
-        );
-    }
-
-    template<class T>
-    constexpr size_t ceil(T val)
-    {
-        return static_cast<size_t>(__builtin_ceil(static_cast<double>(val)));
-    }
-
-    template<class T>
-    constexpr size_t floor(T val)
-    {
-        return static_cast<size_t>(__builtin_floor(static_cast<double>(val)));
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/common.hpp
===================================================================
--- uspace/lib/cpp/include/internal/common.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,13 +1,0 @@
-#ifndef LIBCPP_INTERNAL_COMMON
-#define LIBCPP_INTERNAL_COMMON
-
-/**
- * According to section 17.2 of the standard,
- * the restrict qualifier shall be omitted.
- */
-#define restrict
-
-#undef NULL
-#define NULL nullptr
-
-#endif
Index: pace/lib/cpp/include/internal/functional/arithmetic_operations.hpp
===================================================================
--- uspace/lib/cpp/include/internal/functional/arithmetic_operations.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,621 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_FUNCTIONAL_ARITHMETIC_OPERATIONS
-#define LIBCPP_INTERNAL_FUNCTIONAL_ARITHMETIC_OPERATIONS
-
-#include <internal/utility/forward_move.hpp>
-#include <type_traits>
-
-namespace std
-{
-    /**
-     * 20.9.5, arithmetic operations:
-     */
-
-    template<class T = void>
-    struct plus
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs + rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct minus
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs - rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct multiplies
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs * rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct divides
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs / rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct modulus
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs % rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct negate
-    {
-        constexpr T operator()(const T& x) const
-        {
-            return -x;
-        }
-
-        using argument_type = T;
-        using result_type   = T;
-    };
-
-    namespace aux
-    {
-        /**
-         * Used by some functions like std::set::find to determine
-         * whether a functor is transparent.
-         */
-        struct transparent_t;
-
-        template<class T, class = void>
-        struct is_transparent: false_type
-        { /* DUMMY BODY */ };
-
-        template<class T>
-        struct is_transparent<T, void_t<typename T::is_transparent>>
-            : true_type
-        { /* DUMMY BODY */ };
-
-        template<class T>
-        inline constexpr bool is_transparent_v = is_transparent<T>::value;
-    }
-
-    template<>
-    struct plus<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) + forward<U>(rhs))
-        {
-            return forward<T>(lhs) + forward<T>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct minus<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) - forward<U>(rhs))
-        {
-            return forward<T>(lhs) - forward<T>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct multiplies<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) * forward<U>(rhs))
-        {
-            return forward<T>(lhs) * forward<T>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct divides<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) / forward<U>(rhs))
-        {
-            return forward<T>(lhs) / forward<T>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct modulus<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) % forward<U>(rhs))
-        {
-            return forward<T>(lhs) % forward<T>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct negate<void>
-    {
-        template<class T>
-        constexpr auto operator()(T&& x) const
-            -> decltype(-forward<T>(x))
-        {
-            return -forward<T>(x);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    /**
-     * 20.9.6, comparisons:
-     */
-
-    template<class T = void>
-    struct equal_to
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs == rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<class T = void>
-    struct not_equal_to
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs != rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<class T = void>
-    struct greater
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs > rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<class T = void>
-    struct less
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs < rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<class T = void>
-    struct greater_equal
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs >= rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<class T = void>
-    struct less_equal
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs <= rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<>
-    struct equal_to<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) == forward<U>(rhs))
-        {
-            return forward<T>(lhs) == forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct not_equal_to<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) != forward<U>(rhs))
-        {
-            return forward<T>(lhs) != forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct greater<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) > forward<U>(rhs))
-        {
-            return forward<T>(lhs) > forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct less<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) < forward<U>(rhs))
-        {
-            return forward<T>(lhs) < forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct greater_equal<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) >= forward<U>(rhs))
-        {
-            return forward<T>(lhs) >= forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct less_equal<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) <= forward<U>(rhs))
-        {
-            return forward<T>(lhs) <= forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    /**
-     * 20.9.7, logical operations:
-     */
-
-    template<class T = void>
-    struct logical_and
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs && rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<class T = void>
-    struct logical_or
-    {
-        constexpr bool operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs || rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = bool;
-    };
-
-    template<class T = void>
-    struct logical_not
-    {
-        constexpr bool operator()(const T& x) const
-        {
-            return !x;
-        }
-
-        using argument_type = T;
-        using result_type   = bool;
-    };
-
-    template<>
-    struct logical_and<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) && forward<U>(rhs))
-        {
-            return forward<T>(lhs) && forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct logical_or<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) || forward<U>(rhs))
-        {
-            return forward<T>(lhs) || forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct logical_not<void>
-    {
-        template<class T>
-        constexpr auto operator()(T&& x) const
-            -> decltype(!forward<T>(x))
-        {
-            return !forward<T>(x);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    /**
-     * 20.9.8, bitwise operations:
-     */
-
-    template<class T = void>
-    struct bit_and
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs & rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct bit_or
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs | rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct bit_xor
-    {
-        constexpr T operator()(const T& lhs, const T& rhs) const
-        {
-            return lhs ^ rhs;
-        }
-
-        using first_argument_type  = T;
-        using second_argument_type = T;
-        using result_type          = T;
-    };
-
-    template<class T = void>
-    struct bit_not
-    {
-        constexpr bool operator()(const T& x) const
-        {
-            return ~x;
-        }
-
-        using argument_type = T;
-        using result_type   = T;
-    };
-
-    template<>
-    struct bit_and<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) & forward<U>(rhs))
-        {
-            return forward<T>(lhs) & forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct bit_or<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) | forward<U>(rhs))
-        {
-            return forward<T>(lhs) | forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct bit_xor<void>
-    {
-        template<class T, class U>
-        constexpr auto operator()(T&& lhs, U&& rhs) const
-            -> decltype(forward<T>(lhs) ^ forward<U>(rhs))
-        {
-            return forward<T>(lhs) ^ forward<U>(rhs);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    template<>
-    struct bit_not<void>
-    {
-        template<class T>
-        constexpr auto operator()(T&& x) const
-            -> decltype(~forward<T>(x))
-        {
-            return ~forward<T>(x);
-        }
-
-        using is_transparent = aux::transparent_t;
-    };
-
-    /**
-     * 20.9.9, negators:
-     */
-
-    template<class Predicate>
-    class unary_negate
-    {
-        public:
-            using result_type   = bool;
-            using argument_type = typename Predicate::argument_type;
-
-            constexpr explicit unary_negate(const Predicate& pred)
-                : pred_{pred}
-            { /* DUMMY BODY */ }
-
-            constexpr result_type operator()(const argument_type& arg)
-            {
-                return !pred_(arg);
-            }
-
-        private:
-            Predicate pred_;
-    };
-
-    template<class Predicate>
-    constexpr unary_negate<Predicate> not1(const Predicate& pred)
-    {
-        return unary_negate<Predicate>{pred};
-    }
-
-    template<class Predicate>
-    class binary_negate
-    {
-        public:
-            using result_type          = bool;
-            using first_argument_type  = typename Predicate::first_argument_type;
-            using second_argument_type = typename Predicate::second_argument_type;
-
-            constexpr explicit binary_negate(const Predicate& pred)
-                : pred_{pred}
-            { /* DUMMY BODY */ }
-
-            constexpr result_type operator()(const first_argument_type& arg1,
-                                             const second_argument_type& arg2)
-            {
-                return !pred_(arg1, arg2);
-            }
-
-        private:
-            Predicate pred_;
-    };
-
-    template<class Predicate>
-    constexpr binary_negate<Predicate> not2(const Predicate& pred);
-}
-
-#endif
Index: pace/lib/cpp/include/internal/functional/bind.hpp
===================================================================
--- uspace/lib/cpp/include/internal/functional/bind.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,240 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_FUNCTIONAL_BIND
-#define LIBCPP_INTERNAL_FUNCTIONAL_BIND
-
-#include <internal/functional/function.hpp>
-#include <internal/functional/invoke.hpp>
-#include <internal/functional/reference_wrapper.hpp>
-#include <tuple>
-#include <type_traits>
-#include <utility>
-
-namespace std
-{
-    /**
-     * 20.9.10, bind:
-     */
-
-    namespace aux
-    {
-        template<int N>
-        struct placeholder_t
-        {
-            constexpr placeholder_t() = default;
-            constexpr placeholder_t(const placeholder_t&) = default;
-            constexpr placeholder_t(placeholder_t&&) = default;
-        };
-    }
-
-    template<class T>
-    struct is_placeholder: integral_constant<int, 0>
-    { /* DUMMY BODY */ };
-
-    template<int N> // Note: const because they are all constexpr.
-    struct is_placeholder<const aux::placeholder_t<N>>
-        : integral_constant<int, N>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    inline constexpr int is_placeholder_v = is_placeholder<T>::value;
-
-    namespace aux
-    {
-        /**
-         * Note: Our internal bind return type has an extra type
-         *       template parameter and an extra bool template parameter.
-         *       We use this for the special version of bind that has
-         *       the return type to have a result_type typedef
-         *       (i.e. when the bool is true, the extra type parameter
-         *       is typedefed as result_type - see the structure below).
-         *       This is just a simplification of the implementation
-         *       so that we don't need to have two return types for
-         *       the two bind functions, because unlike function or
-         *       mem_fn, we know exactly when to make the typedef.
-         */
-
-        template<class, bool = false>
-        struct bind_conditional_result_type
-        { /* DUMMY BODY */ };
-
-        template<class R>
-        struct bind_conditional_result_type<R, true>
-        {
-            using result_type = R;
-        };
-
-        template<class, bool, class, class...>
-        class bind_t;
-
-        /**
-         * Filter class that uses its overloaded operator[]
-         * to filter our placeholders, reference_wrappers and bind
-         * subexpressions and replace them with the correct
-         * arguments (extracts references, calls the subexpressions etc).
-         */
-        template<class... Args>
-        class bind_arg_filter
-        {
-            public:
-                bind_arg_filter(Args&&... args)
-                    : args_{forward<Args>(args)...}
-                { /* DUMMY BODY */ }
-
-                template<class T>
-                constexpr decltype(auto) operator[](T&& t)
-                {
-                    return forward<T>(t);
-                }
-
-                template<int N>
-                constexpr decltype(auto) operator[](const placeholder_t<N>)
-                { // Since placeholders are constexpr, this is the best match for them.
-                    /**
-                     * Come on, it's int! Why not use -1 as not placeholder
-                     * and start them at 0? -.-
-                     */
-                    return get<N - 1>(args_);
-                }
-
-                template<class T>
-                constexpr T& operator[](reference_wrapper<T> ref)
-                {
-                    return ref.get();
-                }
-
-                template<class R, bool B, class F, class... BindArgs>
-                constexpr decltype(auto) operator[](const bind_t<R, B, F, BindArgs...> b)
-                {
-                    return b; // TODO: bind subexpressions
-                }
-
-
-            private:
-                tuple<Args...> args_;
-        };
-
-        template<class R, bool HasResultType, class F, class... Args>
-        class bind_t: public bind_conditional_result_type<R, HasResultType>
-        {
-            public:
-                template<class G, class... BoundArgs>
-                constexpr bind_t(G&& g, BoundArgs&&... args)
-                    : func_{forward<F>(g)},
-                      bound_args_{forward<Args>(args)...}
-                { /* DUMMY BODY */ }
-
-                constexpr bind_t(const bind_t& other) = default;
-                constexpr bind_t(bind_t&& other) = default;
-
-                template<class... ActualArgs>
-                constexpr decltype(auto) operator()(ActualArgs&&... args)
-                {
-                    return invoke_(
-                        make_index_sequence<sizeof...(Args)>{},
-                        forward<ActualArgs>(args)...
-                    );
-                }
-
-            private:
-                function<decay_t<F>> func_;
-                tuple<decay_t<Args>...> bound_args_;
-
-                template<size_t... Is, class... ActualArgs>
-                constexpr decltype(auto) invoke_(
-                    index_sequence<Is...>, ActualArgs&&... args
-                )
-                {
-                    /**
-                     * The expression filter[bound_args_[bind_arg_index<Is>()]]...
-                     * here expands bind_arg_index to 0, 1, ... sizeof...(ActualArgs) - 1
-                     * and then passes this variadic list of indices to the bound_args_
-                     * tuple which extracts the bound args from it.
-                     * Our filter will then have its operator[] called on each of them
-                     * and filter out the placeholders, reference_wrappers etc and changes
-                     * them to the actual arguments.
-                     */
-                    bind_arg_filter<ActualArgs...> filter{forward<ActualArgs>(args)...};
-
-                    return aux::invoke(
-                        func_,
-                        filter[get<Is>(bound_args_)]...
-                    );
-                }
-        };
-    }
-
-    template<class T>
-    struct is_bind_expression: false_type
-    { /* DUMMY BODY */ };
-
-    template<class R, bool B, class F, class... Args>
-    struct is_bind_expression<aux::bind_t<R, B, F, Args...>>
-        : true_type
-    { /* DUMMY BODY */ };
-
-    template<class F, class... Args>
-    aux::bind_t<void, false, F, Args...> bind(F&& f, Args&&... args)
-    {
-        return aux::bind_t<void, false, F, Args...>{forward<F>(f), forward<Args>(args)...};
-    }
-
-    template<class R, class F, class... Args>
-    aux::bind_t<R, true, F, Args...> bind(F&& f, Args&&... args)
-    {
-        return aux::bind_t<R, true, F, Args...>{forward<F>(f), forward<Args>(args)...};
-    }
-
-    namespace placeholders
-    {
-        /**
-         * Note: The number of placeholders is
-         *       implementation defined, we've chosen
-         *       8 because it is a nice number
-         *       and should be enough for any function
-         *       call.
-         * Note: According to the C++14 standard, these
-         *       are all extern non-const. We decided to use
-         *       the C++17 form of them being inline constexpr
-         *       because it is more convenient, makes sense
-         *       and would eventually need to be upgraded
-         *       anyway.
-         */
-        inline constexpr aux::placeholder_t<1> _1;
-        inline constexpr aux::placeholder_t<2> _2;
-        inline constexpr aux::placeholder_t<3> _3;
-        inline constexpr aux::placeholder_t<4> _4;
-        inline constexpr aux::placeholder_t<5> _5;
-        inline constexpr aux::placeholder_t<6> _6;
-        inline constexpr aux::placeholder_t<7> _7;
-        inline constexpr aux::placeholder_t<8> _8;
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/functional/conditional_function_typedefs.hpp
===================================================================
--- uspace/lib/cpp/include/internal/functional/conditional_function_typedefs.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,77 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_FUNCTION_CONDITIONAL_FUNCTION_TYPEDEFS
-#define LIBCPP_INTERNAL_FUNCTION_CONDITIONAL_FUNCTION_TYPEDEFS
-
-namespace std::aux
-{
-    /**
-     * Note: Some types with possible function-like behavior
-     *       (e.g. function, reference_wrapper, aux::mem_fn_t)
-     *       have to define a type argument type or two types
-     *       first_argument_type and second_argument_type when
-     *       their invocation takes one or two arguments, respectively.
-     *
-     *       The easiest way to conditionally define a type is using
-     *       inheritance and the types below serve exactly for that
-     *       purpose.
-     *
-     *       If we have a type that is specialized as R(Args...)
-     *       for some return type R and argument types Args...,
-     *       we can simply (publicly) inherit from
-     *       conditional_function_typedefs<Args...>. If it is
-     *       templated by some generic type T, we can inherit from
-     *       conditional_function_typedefs<remove_cv_t<remove_reference_t<T>>>
-     *       so that the correct type below gets chosen.
-     */
-
-    template<class... Args>
-    struct conditional_function_typedefs
-    { /* DUMMY BODY */ };
-
-    template<class A>
-    struct conditional_function_typedefs<A>
-    {
-        using argument_type = A;
-    };
-
-    template<class A1, class A2>
-    struct conditional_function_typedefs<A1, A2>
-    {
-        using first_argument_type  = A1;
-        using second_argument_type = A2;
-    };
-
-    template<class R, class... Args>
-    struct conditional_function_typedefs<R(Args...)>
-        : conditional_function_typedefs<Args...>
-    { /* DUMMY BODY */ };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/functional/function.hpp
===================================================================
--- uspace/lib/cpp/include/internal/functional/function.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,377 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_FUNCTIONAL_FUNCTION
-#define LIBCPP_INTERNAL_FUNCTIONAL_FUNCTION
-
-#include <internal/functional/conditional_function_typedefs.hpp>
-#include <internal/functional/reference_wrapper.hpp>
-#include <typeinfo>
-#include <type_traits>
-
-namespace std
-{
-    /**
-     * 20.9.12, polymorphic function adaptors:
-     */
-
-    namespace aux
-    {
-        // TODO: fix this
-        /* template<class, class T, class... Args> */
-        /* struct is_callable_impl: false_type */
-        /* { /1* DUMMY BODY *1/ }; */
-
-        /* template<class, class R, class... Args> */
-        /* struct is_callable_impl< */
-        /*     void_t<decltype(aux::invoke(declval<R(Args...)>(), declval<Args>()..., R))>, */
-        /*     R, Args... */
-        /* > : true_type */
-        /* { /1* DUMMY BODY *1/ }; */
-
-        /* template<class T> */
-        /* struct is_callable: is_callable_impl<void_t<>, T> */
-        /* { /1* DUMMY BODY *1/ }; */
-
-        template<class Callable, class R, class... Args>
-        R invoke_callable(Callable* clbl, Args&&... args)
-        {
-            return (*clbl)(forward<Args>(args)...);
-        }
-
-        template<class Callable>
-        void copy_callable(Callable* to, Callable* from)
-        {
-            new(to) Callable{*from};
-        }
-
-        template<class Callable>
-        void destroy_callable(Callable* clbl)
-        {
-            if (clbl)
-                clbl->~Callable();
-        }
-    }
-
-    // TODO: implement
-    class bad_function_call;
-
-    template<class>
-    class function; // undefined
-
-    /**
-     * Note: Ideally, this implementation wouldn't
-     *       copy the target if it was a pointer to
-     *       a function, but for the simplicity of the
-     *       implementation, we do copy even in that
-     *       case for now. It would be a nice optimization
-     *       if this was changed in the future.
-     */
-    template<class R, class... Args>
-    class function<R(Args...)>
-        : public aux::conditional_function_typedefs<Args...>
-    {
-        public:
-            using result_type = R;
-
-            /**
-             * 20.9.12.2.1, construct/copy/destroy:
-             */
-
-            function() noexcept
-                : callable_{}, callable_size_{}, call_{},
-                  copy_{}, dest_{}
-            { /* DUMMY BODY */ }
-
-            function(nullptr_t) noexcept
-                : function{}
-            { /* DUMMY BODY */ }
-
-            function(const function& other)
-                : callable_{}, callable_size_{other.callable_size_},
-                  call_{other.call_}, copy_{other.copy_}, dest_{other.dest_}
-            {
-                callable_ = new uint8_t[callable_size_];
-                (*copy_)(callable_, other.callable_);
-            }
-
-            function(function&& other)
-                : callable_{other.callable_}, callable_size_{other.callable_size_},
-                  call_{other.call_}, copy_{other.copy_}, dest_{other.dest_}
-            {
-                other.callable_ = nullptr;
-                other.callable_size_ = size_t{};
-                other.call_ = nullptr;
-                other.copy_ = nullptr;
-                other.dest_ = nullptr;
-            }
-
-            // TODO: shall not participate in overloading unless aux::is_callable<F>
-            template<class F>
-            function(F f)
-                : callable_{}, callable_size_{sizeof(F)},
-                  call_{(call_t)aux::invoke_callable<F, R, Args...>},
-                  copy_{(copy_t)aux::copy_callable<F>},
-                  dest_{(dest_t)aux::destroy_callable<F>}
-            {
-                callable_ = new uint8_t[callable_size_];
-                (*copy_)(callable_, (uint8_t*)&f);
-            }
-
-            /**
-             * Note: For the moment we're ignoring the allocator
-             *       for simplicity of the implementation.
-             */
-
-            template<class A>
-            function(allocator_arg_t, const A& a) noexcept
-                : function{}
-            { /* DUMMY BODY */ }
-
-            template<class A>
-            function(allocator_arg_t, const A& a, nullptr_t) noexcept
-                : function{}
-            { /* DUMMY BODY */ }
-
-            template<class A>
-            function(allocator_arg_t, const A& a, const function& other)
-                : function{other}
-            { /* DUMMY BODY */ }
-
-            template<class A>
-            function(allocator_arg_t, const A& a, function&& other)
-                : function{move(other)}
-            { /* DUMMY BODY */ }
-
-            // TODO: shall not participate in overloading unless aux::is_callable<F>
-            template<class F, class A>
-            function(allocator_arg_t, const A& a, F f)
-                : function{f}
-            { /* DUMMY BODY */ }
-
-            function& operator=(const function& rhs)
-            {
-                function{rhs}.swap(*this);
-
-                return *this;
-            }
-
-            /**
-             * Note: We have to copy call_, copy_
-             *       and dest_ because they can be templated
-             *       by a type F we don't know.
-             */
-            function& operator=(function&& rhs)
-            {
-                clear_();
-
-                callable_ = rhs.callable_;
-                callable_size_ = rhs.callable_size_;
-                call_ = rhs.call_;
-                copy_ = rhs.copy_;
-                dest_ = rhs.dest_;
-
-                rhs.callable_ = nullptr;
-                rhs.callable_size_ = size_t{};
-                rhs.call_ = nullptr;
-                rhs.copy_ = nullptr;
-                rhs.dest_ = nullptr;
-
-                return *this;
-            }
-
-            function& operator=(nullptr_t) noexcept
-            {
-                clear_();
-
-                return *this;
-            }
-
-            // TODO: shall not participate in overloading unless aux::is_callable<F>
-            template<class F>
-            function& operator=(F&& f)
-            {
-                callable_size_ = sizeof(F);
-                callable_ = new uint8_t[callable_size_];
-                call_ = aux::invoke_callable<F, R, Args...>;
-                copy_ = aux::copy_callable<F>;
-                dest_ = aux::destroy_callable<F>;
-
-                (*copy_)(callable_, (uint8_t*)&f);
-            }
-
-            template<class F>
-            function& operator=(reference_wrapper<F> ref) noexcept
-            {
-                return (*this) = ref.get();
-            }
-
-            ~function()
-            {
-                if (callable_)
-                {
-                    (*dest_)(callable_);
-                    delete[] callable_;
-                }
-            }
-
-            /**
-             * 20.9.12.2.2, function modifiers:
-             */
-
-            void swap(function& other) noexcept
-            {
-                std::swap(callable_, other.callable_);
-                std::swap(callable_size_, other.callable_size_);
-                std::swap(call_, other.call_);
-                std::swap(copy_, other.copy_);
-                std::swap(dest_, other.dest_);
-            }
-
-            template<class F, class A>
-            void assign(F&& f, const A& a)
-            {
-                function{allocator_arg, a, forward<F>(f)}.swap(*this);
-            }
-
-            /**
-             * 20.9.12.2.3, function capacity:
-             */
-
-            explicit operator bool() const noexcept
-            {
-                return callable_ != nullptr;
-            }
-
-            /**
-             * 20.9.12.2.4, function invocation:
-             */
-
-            result_type operator()(Args... args) const
-            {
-                // TODO: throw bad_function_call if !callable_ || !call_
-                if constexpr (is_same_v<R, void>)
-                    (*call_)(callable_, forward<Args>(args)...);
-                else
-                    return (*call_)(callable_, forward<Args>(args)...);
-            }
-
-            /**
-             * 20.9.12.2.5, function target access:
-             */
-
-            const type_info& target_type() const noexcept
-            {
-                return typeid(*callable_);
-            }
-
-            template<class T>
-            T* target() noexcept
-            {
-                if (target_type() == typeid(T))
-                    return (T*)callable_;
-                else
-                    return nullptr;
-            }
-
-            template<class T>
-            const T* target() const noexcept
-            {
-                if (target_type() == typeid(T))
-                    return (T*)callable_;
-                else
-                    return nullptr;
-            }
-
-        private:
-            using call_t = R(*)(uint8_t*, Args&&...);
-            using copy_t = void (*)(uint8_t*, uint8_t*);
-            using dest_t = void (*)(uint8_t*);
-
-            uint8_t* callable_;
-            size_t callable_size_;
-            call_t call_;
-            copy_t copy_;
-            dest_t dest_;
-
-            void clear_()
-            {
-                if (callable_)
-                {
-                    (*dest_)(callable_);
-                    delete[] callable_;
-                    callable_ = nullptr;
-                }
-            }
-    };
-
-    /**
-     * 20.9.12.2.6, null pointer comparisons:
-     */
-
-    template<class R, class... Args>
-    bool operator==(const function<R(Args...)>& f, nullptr_t) noexcept
-    {
-        return !f;
-    }
-
-    template<class R, class... Args>
-    bool operator==(nullptr_t, const function<R(Args...)>& f) noexcept
-    {
-        return !f;
-    }
-
-    template<class R, class... Args>
-    bool operator!=(const function<R(Args...)>& f, nullptr_t) noexcept
-    {
-        return (bool)f;
-    }
-
-    template<class R, class... Args>
-    bool operator!=(nullptr_t, const function<R(Args...)>& f) noexcept
-    {
-        return (bool)f;
-    }
-
-    /**
-     * 20.9.12.2.7, specialized algorithms:
-     */
-
-    template<class R, class... Args>
-    void swap(function<R(Args...)>& f1, function<R(Args...)>& f2)
-    {
-        f1.swap(f2);
-    }
-
-    template<class R, class... Args, class Alloc>
-    struct uses_allocator<function<R(Args...)>, Alloc>
-        : true_type
-    { /* DUMMY BODY */ };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/functional/hash.hpp
===================================================================
--- uspace/lib/cpp/include/internal/functional/hash.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,318 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_FUNCTIONAL_HASH
-#define LIBCPP_INTERNAL_FUNCTIONAL_HASH
-
-#include <cstdlib>
-#include <cstdint>
-
-namespace std
-{
-    template<class>
-    struct is_arithmetic;
-
-    template<class>
-    struct is_pointer;
-
-    /**
-     * 20.9.13, hash function primary template:
-     */
-
-    namespace aux
-    {
-        template<class T>
-        union converter
-        {
-            T value;
-            uint64_t converted;
-        };
-
-        template<class T>
-        T hash_(uint64_t x) noexcept
-        {
-            /**
-             * Note: std::hash is used for indexing in
-             *       unordered containers, not for cryptography.
-             *       Because of this, we decided to simply convert
-             *       the value to uin64_t, which will help us
-             *       with testing (since in order to create
-             *       a collision in a multiset or multimap
-             *       we simply need 2 values that congruent
-             *       by the size of the table.
-             */
-            return static_cast<T>(x);
-        }
-
-        template<class T>
-        size_t hash(T x) noexcept
-        {
-            static_assert(is_arithmetic<T>::value || is_pointer<T>::value,
-                          "invalid type passed to aux::hash");
-
-            converter<T> conv;
-            conv.value = x;
-
-            return hash_<size_t>(conv.converted);
-        }
-    }
-
-    template<class T>
-    struct hash
-    { /* DUMMY BODY */ };
-
-    template<>
-    struct hash<bool>
-    {
-        size_t operator()(bool x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = bool;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<char>
-    {
-        size_t operator()(char x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = char;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<signed char>
-    {
-        size_t operator()(signed char x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = signed char;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<unsigned char>
-    {
-        size_t operator()(unsigned char x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = unsigned char;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<char16_t>
-    {
-        size_t operator()(char16_t x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = char16_t;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<char32_t>
-    {
-        size_t operator()(char32_t x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = char32_t;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<wchar_t>
-    {
-        size_t operator()(wchar_t x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = wchar_t;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<short>
-    {
-        size_t operator()(short x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = short;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<unsigned short>
-    {
-        size_t operator()(unsigned short x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = unsigned short;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<int>
-    {
-        size_t operator()(int x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = int;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<unsigned int>
-    {
-        size_t operator()(unsigned int x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = unsigned int;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<long>
-    {
-        size_t operator()(long x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = long;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<long long>
-    {
-        size_t operator()(long long x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = long long;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<unsigned long>
-    {
-        size_t operator()(unsigned long x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = unsigned long;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<unsigned long long>
-    {
-        size_t operator()(unsigned long long x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = unsigned long long;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<float>
-    {
-        size_t operator()(float x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = float;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<double>
-    {
-        size_t operator()(double x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = double;
-        using result_type   = size_t;
-    };
-
-    template<>
-    struct hash<long double>
-    {
-        size_t operator()(long double x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = long double;
-        using result_type   = size_t;
-    };
-
-    template<class T>
-    struct hash<T*>
-    {
-        size_t operator()(T* x) const noexcept
-        {
-            return aux::hash(x);
-        }
-
-        using argument_type = T*;
-        using result_type   = size_t;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/functional/invoke.hpp
===================================================================
--- uspace/lib/cpp/include/internal/functional/invoke.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,97 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_FUNCTIONAL_INVOKE
-#define LIBCPP_INTERNAL_FUNCTIONAL_INVOKE
-
-#include <internal/utility/declval.hpp>
-#include <internal/utility/forward_move.hpp>
-
-namespace std
-{
-    template<class>
-    struct is_member_function_pointer;
-
-    template<class, class>
-    struct is_base_of;
-
-    template<class>
-    struct is_member_object_pointer;
-}
-
-namespace std::aux
-{
-    /**
-     * 20.9.2, requirements:
-     */
-
-    template<class R, class T, class T1, class... Ts>
-    decltype(auto) invoke(R T::* f, T1&& t1, Ts&&... args)
-    {
-        if constexpr (is_member_function_pointer<decltype(f)>::value)
-        {
-            if constexpr (is_base_of<T, remove_reference_t<T1>>::value)
-                // (1.1)
-                return (t1.*f)(forward<Ts>(args)...);
-            else
-                // (1.2)
-                return ((*t1).*f)(forward<Ts>(args)...);
-        }
-        else if constexpr (is_member_object_pointer<decltype(f)>::value && sizeof...(args) == 0)
-        {
-            /**
-             * Note: Standard requires to N be equal to 1, but we take t1 directly
-             *       so we need sizeof...(args) to be 0.
-             */
-            if constexpr (is_base_of<T, remove_reference_t<T1>>::value)
-                // (1.3)
-                return t1.*f;
-            else
-                // (1.4)
-                return (*t1).*f;
-        }
-        else
-
-        /**
-         * Note: If this condition holds this will not be reachable,
-         *       but a new addition to the standard (17.7 point (8.1))
-         *       prohibits us from simply using false as the condition here,
-         *       so we use this because we know it is false here.
-         */
-        static_assert(is_member_function_pointer<decltype(f)>::value, "invalid invoke");
-    }
-
-    template<class F, class... Args>
-    decltype(auto) invoke(F&& f, Args&&... args)
-    {
-        // (1.5)
-        return f(forward<Args>(args)...);
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/functional/reference_wrapper.hpp
===================================================================
--- uspace/lib/cpp/include/internal/functional/reference_wrapper.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_FUNCTIONAL_REFERENCE_WRAPPER
-#define LIBCPP_INTERNAL_FUNCTIONAL_REFERENCE_WRAPPER
-
-#include <internal/functional/conditional_function_typedefs.hpp>
-#include <internal/functional/invoke.hpp>
-#include <type_traits>
-
-namespace std
-{
-    /**
-     * 20.9.4, reference_wrapper:
-     */
-
-    template<class T>
-    class reference_wrapper
-        : public aux::conditional_function_typedefs<remove_cv_t<remove_reference_t<T>>>
-    {
-        public:
-            using type = T;
-
-            reference_wrapper(type& val) noexcept
-                : data_{&val}
-            { /* DUMMY BODY */ }
-
-            reference_wrapper(type&&) = delete;
-
-            reference_wrapper(const reference_wrapper& other) noexcept
-                : data_{other.data_}
-            { /* DUMMY BODY */ }
-
-            reference_wrapper& operator=(const reference_wrapper& other) noexcept
-            {
-                data_ = other.data_;
-
-                return *this;
-            }
-
-            operator type&() const noexcept
-            {
-                return *data_;
-            }
-
-            type& get() const noexcept
-            {
-                return *data_;
-            }
-
-            template<class... Args>
-            result_of_t<type&(Args&&...)> operator()(Args&&... args) const
-            {
-                return invoke(*data_, std::forward<Args>(args)...);
-            }
-
-        private:
-            type* data_;
-    };
-
-    template<class T>
-    reference_wrapper<T> ref(T& t) noexcept
-    {
-        return reference_wrapper<T>{t};
-    }
-
-    template<class T>
-    reference_wrapper<const T> cref(const T& t) noexcept
-    {
-        return reference_wrapper<const T>{t};
-    }
-
-    template<class T>
-    void ref(const T&&) = delete;
-
-    template<class T>
-    void cref(const T&&) = delete;
-
-    template<class T>
-    reference_wrapper<T> ref(reference_wrapper<T> t) noexcept
-    {
-        return ref(t.get());
-    }
-
-    template<class T>
-    reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept
-    {
-        return cref(t.get());
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/hash_table.hpp
===================================================================
--- uspace/lib/cpp/include/internal/hash_table.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,595 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_HASH_TABLE
-#define LIBCPP_INTERNAL_HASH_TABLE
-
-#include <cstdlib>
-#include <internal/list.hpp>
-#include <internal/key_extractors.hpp>
-#include <internal/hash_table_iterators.hpp>
-#include <internal/hash_table_policies.hpp>
-#include <iterator>
-#include <limits>
-#include <memory>
-#include <tuple>
-#include <utility>
-
-namespace std::aux
-{
-    /**
-     * To save code, we're going to implement one hash table
-     * for both unordered_map and unordered_set. To do this,
-     * we create one inner hash table that is oblivious to its
-     * held type (and uses a key extractor to get the key from it)
-     * and two proxies that either use plain Key type or a pair
-     * of a key and a value.
-     * Additionally, we will use policies to represent both single
-     * and multi variants of these containers at once.
-     * Note: I am aware the naming is very unimaginative here,
-     *       not my strong side :)
-     */
-
-    template<
-        class Value, class Key, class KeyExtractor,
-        class Hasher, class KeyEq,
-        class Alloc, class Size,
-        class Iterator, class ConstIterator,
-        class LocalIterator, class ConstLocalIterator,
-        class Policy
-    >
-    class hash_table
-    {
-        public:
-            using value_type     = Value;
-            using key_type       = Key;
-            using size_type      = Size;
-            using allocator_type = Alloc;
-            using key_equal      = KeyEq;
-            using hasher         = Hasher;
-            using key_extract    = KeyExtractor;
-
-            using iterator             = Iterator;
-            using const_iterator       = ConstIterator;
-            using local_iterator       = LocalIterator;
-            using const_local_iterator = ConstLocalIterator;
-
-            using node_type = list_node<value_type>;
-
-            using place_type = tuple<
-                hash_table_bucket<value_type, size_type>*,
-                list_node<value_type>*, size_type
-            >;
-
-            hash_table(size_type buckets, float max_load_factor = 1.f)
-                : table_{new hash_table_bucket<value_type, size_type>[buckets]()},
-                  bucket_count_{buckets}, size_{}, hasher_{}, key_eq_{},
-                  key_extractor_{}, max_load_factor_{max_load_factor}
-            { /* DUMMY BODY */ }
-
-            hash_table(size_type buckets, const hasher& hf, const key_equal& eql,
-                       float max_load_factor = 1.f)
-                : table_{new hash_table_bucket<value_type, size_type>[buckets]()},
-                  bucket_count_{buckets}, size_{}, hasher_{hf}, key_eq_{eql},
-                  key_extractor_{}, max_load_factor_{max_load_factor}
-            { /* DUMMY BODY */ }
-
-            hash_table(const hash_table& other)
-                : hash_table{other.bucket_count_, other.hasher_, other.key_eq_,
-                             other.max_load_factor_}
-            {
-                for (const auto& x: other)
-                    insert(x);
-            }
-
-            hash_table(hash_table&& other)
-                : table_{other.table_}, bucket_count_{other.bucket_count_},
-                  size_{other.size_}, hasher_{move(other.hasher_)},
-                  key_eq_{move(other.key_eq_)}, key_extractor_{move(other.key_extractor_)},
-                  max_load_factor_{other.max_load_factor_}
-            {
-                other.table_ = nullptr;
-                other.bucket_count_ = size_type{};
-                other.size_ = size_type{};
-                other.max_load_factor_ = 1.f;
-            }
-
-            hash_table& operator=(const hash_table& other)
-            {
-                hash_table tmp{other};
-                tmp.swap(*this);
-
-                return *this;
-            }
-
-            hash_table& operator=(hash_table&& other)
-            {
-                hash_table tmp{move(other)};
-                tmp.swap(*this);
-
-                return *this;
-            }
-
-            bool empty() const noexcept
-            {
-                return size_ == 0;
-            }
-
-            size_type size() const noexcept
-            {
-                return size_;
-            }
-
-            size_type max_size(allocator_type& alloc)
-            {
-                return allocator_traits<allocator_type>::max_size(alloc);
-            }
-
-            iterator begin() noexcept
-            {
-                auto idx = first_filled_bucket_();
-                return iterator{
-                    table_, idx, bucket_count_,
-                    table_[idx].head
-                };
-            }
-
-            const_iterator begin() const noexcept
-            {
-                return cbegin();
-            }
-
-            iterator end() noexcept
-            {
-                return iterator{};
-            }
-
-            const_iterator end() const noexcept
-            {
-                return cend();
-            }
-
-            const_iterator cbegin() const noexcept
-            {
-                auto idx = first_filled_bucket_();
-                return const_iterator{
-                    table_, idx, bucket_count_,
-                    table_[idx].head
-                };
-            }
-
-            const_iterator cend() const noexcept
-            {
-                return const_iterator{};
-            }
-
-            template<class... Args>
-            auto emplace(Args&&... args)
-            {
-                return Policy::emplace(*this, forward<Args>(args)...);
-            }
-
-            auto insert(const value_type& val)
-            {
-                return Policy::insert(*this, val);
-            }
-
-            auto insert(value_type&& val)
-            {
-                return Policy::insert(*this, forward<value_type>(val));
-            }
-
-            size_type erase(const key_type& key)
-            {
-                return Policy::erase(*this, key);
-            }
-
-            iterator erase(const_iterator it)
-            {
-                auto node = it.node();
-                auto idx = it.idx();
-
-                /**
-                 * Note: This way we will continue on the next bucket
-                 *       if this is the last element in its bucket.
-                 */
-                iterator res{table_, idx, size_, node};
-                ++res;
-
-                if (table_[idx].head == node)
-                {
-                    if (node->next != node)
-                        table_[idx].head = node->next;
-                    else
-                        table_[idx].head = nullptr;
-                }
-                --size_;
-
-                node->unlink();
-                delete node;
-
-                return res;
-            }
-
-            void clear() noexcept
-            {
-                for (size_type i = 0; i < bucket_count_; ++i)
-                    table_[i].clear();
-                size_ = size_type{};
-            }
-
-            void swap(hash_table& other)
-                noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
-                         noexcept(swap(declval<Hasher&>(), declval<Hasher&>())) &&
-                         noexcept(swap(declval<KeyEq&>(), declval<KeyEq&>())))
-            {
-                std::swap(table_, other.table_);
-                std::swap(bucket_count_, other.bucket_count_);
-                std::swap(size_, other.size_);
-                std::swap(hasher_, other.hasher_);
-                std::swap(key_eq_, other.key_eq_);
-                std::swap(max_load_factor_, other.max_load_factor_);
-            }
-
-            hasher hash_function() const
-            {
-                return hasher_;
-            }
-
-            key_equal key_eq() const
-            {
-                return key_eq_;
-            }
-
-            iterator find(const key_type& key)
-            {
-                auto idx = get_bucket_idx_(key);
-                auto head = table_[idx].head;
-
-                if (!head)
-                    return end();
-
-                auto current = head;
-                do
-                {
-                    if (key_eq_(key, key_extractor_(current->value)))
-                        return iterator{table_, idx, size_, current};
-                    current = current->next;
-                }
-                while (current != head);
-
-                return end();
-            }
-
-            const_iterator find(const key_type& key) const
-            {
-                auto idx = get_bucket_idx_(key);
-                auto head = table_[idx].head;
-
-                if (!head)
-                    return end();
-
-                auto current = head;
-                do
-                {
-                    if (key_eq_(key, key_extractor_(current->value)))
-                        return iterator{table_, idx, size_, current};
-                    current = current->next;
-                }
-                while (current != head);
-
-                return end();
-            }
-
-            size_type count(const key_type& key) const
-            {
-                return Policy::count(*this, key);
-            }
-
-            pair<iterator, iterator> equal_range(const key_type& key)
-            {
-                return Policy::equal_range(*this, key);
-            }
-
-            pair<const_iterator, const_iterator> equal_range(const key_type& key) const
-            {
-                return Policy::equal_range_const(*this, key);
-            }
-
-            size_type bucket_count() const noexcept
-            {
-                return bucket_count_;
-            }
-
-            size_type max_bucket_count() const noexcept
-            {
-                return numeric_limits<size_type>::max() /
-                       sizeof(hash_table_bucket<value_type, size_type>);
-            }
-
-            size_type bucket_size(size_type n) const
-            {
-                return table_[n].size();
-            }
-
-            size_type bucket(const key_type& key) const
-            {
-                return get_bucket_idx_(key);
-            }
-
-            local_iterator begin(size_type n)
-            {
-                return local_iterator{table_[n].head, table_[n].head};
-            }
-
-            const_local_iterator begin(size_type n) const
-            {
-                return cbegin(n);
-            }
-
-            local_iterator end(size_type n)
-            {
-                return local_iterator{};
-            }
-
-            const_local_iterator end(size_type n) const
-            {
-                return cend(n);
-            }
-
-            const_local_iterator cbegin(size_type n) const
-            {
-                return const_local_iterator{table_[n].head, table_[n].head};
-            }
-
-            const_local_iterator cend(size_type n) const
-            {
-                return const_local_iterator{};
-            }
-
-            float load_factor() const noexcept
-            {
-                return size_ / static_cast<float>(bucket_count_);
-            }
-
-            float max_load_factor() const noexcept
-            {
-                return max_load_factor_;
-            }
-
-            void max_load_factor(float factor)
-            {
-                if (factor > 0.f)
-                    max_load_factor_ = factor;
-
-                rehash_if_needed();
-            }
-
-            void rehash(size_type count)
-            {
-                if (count < size_ / max_load_factor_)
-                    count = size_ / max_load_factor_;
-
-                /**
-                 * Note: If an exception is thrown, there
-                 *       is no effect. Since this is the only
-                 *       place where an exception (no mem) can
-                 *       be thrown and no changes to this have been
-                 *       made, we're ok.
-                 */
-                hash_table new_table{count, max_load_factor_};
-
-                for (std::size_t i = 0; i < bucket_count_; ++i)
-                {
-                    auto head = table_[i].head;
-                    if (!head)
-                        continue;
-
-                    auto current = head;
-
-                    do
-                    {
-                        auto next = current->next;
-
-                        current->next = current;
-                        current->prev = current;
-
-                        auto where = Policy::find_insertion_spot(
-                            new_table, key_extractor_(current->value)
-                        );
-
-                        /**
-                         * Note: We're rehashing, so we know each
-                         *       key can be inserted.
-                         */
-                        auto new_bucket = get<0>(where);
-                        auto new_successor = get<1>(where);
-
-                        if (new_successor)
-                            new_successor->append(current);
-                        else
-                            new_bucket->append(current);
-
-                        current = next;
-                    } while (current != head);
-
-                    table_[i].head = nullptr;
-                }
-
-                new_table.size_ = size_;
-                swap(new_table);
-
-                delete[] new_table.table_;
-                new_table.table_ = nullptr;
-            }
-
-            void reserve(size_type count)
-            {
-                rehash(count / max_load_factor_ + 1);
-            }
-
-            bool is_eq_to(const hash_table& other) const
-            {
-                if (size() != other.size())
-                    return false;
-
-                auto it = begin();
-                while (it != end())
-                {
-                    /**
-                     * For each key K we will check how many
-                     * instances of K are there in the table.
-                     * Then we will check if the count for K
-                     * is equal to that amount.
-                     */
-
-                    size_type cnt{};
-                    auto tmp = it;
-
-                    while (key_eq_(key_extractor_(*it), key_extractor_(*tmp)))
-                    {
-                        ++cnt;
-                        if (++tmp == end())
-                            break;
-                    }
-
-                    auto other_cnt = other.count(key_extractor_(*it));
-                    if (cnt != other_cnt)
-                        return false;
-
-                    it = tmp; // tmp  is one past *it's key.
-                }
-
-                return true;
-            }
-
-            ~hash_table()
-            {
-                // Lists are deleted in ~hash_table_bucket.
-                if (table_)
-                    delete[] table_;
-            }
-
-            place_type find_insertion_spot(const key_type& key) const
-            {
-                return Policy::find_insertion_spot(*this, key);
-            }
-
-            place_type find_insertion_spot(key_type&& key) const
-            {
-                return Policy::find_insertion_spot(*this, key);
-            }
-
-            const key_type& get_key(const value_type& val) const
-            {
-                return key_extractor_(val);
-            }
-
-            bool keys_equal(const key_type& key, const value_type& val)
-            {
-                return key_eq_(key, key_extractor_(val));
-            }
-
-            bool keys_equal(const key_type& key, const value_type& val) const
-            {
-                return key_eq_(key, key_extractor_(val));
-            }
-
-            hash_table_bucket<value_type, size_type>* table()
-            {
-                return table_;
-            }
-
-            hash_table_bucket<value_type, size_type>* head(size_type idx)
-            {
-                if (idx < bucket_count_)
-                    return table_[idx]->head;
-                else
-                    return nullptr;
-            }
-
-            void rehash_if_needed()
-            {
-                if (size_ > max_load_factor_ * bucket_count_)
-                    rehash(bucket_count_ * bucket_count_growth_factor_);
-            }
-
-            void increment_size()
-            {
-                ++size_;
-
-                rehash_if_needed();
-            }
-
-            void decrement_size()
-            {
-                --size_;
-            }
-
-        private:
-            hash_table_bucket<value_type, size_type>* table_;
-            size_type bucket_count_;
-            size_type size_;
-            hasher hasher_;
-            key_equal key_eq_;
-            key_extract key_extractor_;
-            float max_load_factor_;
-
-            static constexpr float bucket_count_growth_factor_{1.25};
-
-            size_type get_bucket_idx_(const key_type& key) const
-            {
-                return hasher_(key) % bucket_count_;
-            }
-
-            size_type first_filled_bucket_() const
-            {
-                size_type res{};
-                while (res < bucket_count_)
-                {
-                    if (table_[res].head)
-                        return res;
-                    ++res;
-                }
-
-                /**
-                 * Note: This is used for iterators,
-                 *       so we need to return a valid index.
-                 *       But since table_[0].head is nullptr
-                 *       we know that if we return 0 the
-                 *       created iterator will test as equal
-                 *       to end().
-                 */
-                return 0;
-            }
-
-            friend Policy;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/hash_table_bucket.hpp
===================================================================
--- uspace/lib/cpp/include/internal/hash_table_bucket.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_HASH_TABLE_BUCKET
-#define LIBCPP_INTERNAL_HASH_TABLE_BUCKET
-
-#include <internal/list.hpp>
-
-namespace std::aux
-{
-    template<class Value, class Size>
-    struct hash_table_bucket
-    {
-        /**
-         * Note: We use a doubly linked list because
-         *       we need to use hints, which point to the
-         *       element after the hinted spot.
-         */
-
-        list_node<Value>* head;
-
-        hash_table_bucket()
-            : head{}
-        { /* DUMMY BODY */ }
-
-        Size size() const noexcept
-        {
-            auto current = head;
-            Size res{};
-
-            do
-            {
-                ++res;
-                current = current->next;
-            }
-            while (current != head);
-
-            return res;
-        }
-
-        void append(list_node<Value>* node)
-        {
-            if (!head)
-                head = node;
-            else
-                head->append(node);
-        }
-
-        void prepend(list_node<Value>* node)
-        {
-            if (!head)
-                head = node;
-            else
-                head->prepend(node);
-        }
-
-        void clear()
-        {
-            if (!head)
-                return;
-
-            auto current = head;
-            do
-            {
-                auto tmp = current;
-                current = current->next;
-                delete tmp;
-            }
-            while (current != head);
-
-            head = nullptr;
-        }
-
-        ~hash_table_bucket()
-        {
-            clear();
-        }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/hash_table_iterators.hpp
===================================================================
--- uspace/lib/cpp/include/internal/hash_table_iterators.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,485 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_HASH_TABLE_ITERATORS
-#define LIBCPP_INTERNAL_HASH_TABLE_ITERATORS
-
-#include <internal/iterator.hpp>
-#include <internal/list.hpp>
-#include <internal/hash_table_bucket.hpp>
-#include <iterator>
-
-namespace std::aux
-{
-    template<class Value, class Reference, class Pointer, class Size>
-    class hash_table_iterator
-    {
-        public:
-            using value_type      = Value;
-            using size_type       = Size;
-            using reference       = Reference;
-            using pointer         = Pointer;
-            using difference_type = ptrdiff_t;
-
-            using iterator_category = forward_iterator_tag;
-
-            hash_table_iterator(hash_table_bucket<value_type, size_type>* table = nullptr,
-                                size_type idx = size_type{}, size_type max_idx = size_type{},
-                                list_node<value_type>* current = nullptr)
-                : table_{table}, idx_{idx}, max_idx_{max_idx}, current_{current}
-            { /* DUMMY BODY */ }
-
-            hash_table_iterator(const hash_table_iterator&) = default;
-            hash_table_iterator& operator=(const hash_table_iterator&) = default;
-
-            reference operator*()
-            {
-                return current_->value;
-            }
-
-            pointer operator->()
-            {
-                return &current_->value;
-            }
-
-            hash_table_iterator& operator++()
-            {
-                current_ = current_->next;
-                if (current_ == table_[idx_].head)
-                {
-                    if (idx_ < max_idx_)
-                    {
-                        while (!table_[++idx_].head && idx_ < max_idx_)
-                        { /* DUMMY BODY */ }
-
-                        if (idx_ < max_idx_)
-                            current_ = table_[idx_].head;
-                        else
-                            current_ = nullptr;
-                    }
-                    else
-                        current_ = nullptr;
-                }
-
-                return *this;
-            }
-
-            hash_table_iterator operator++(int)
-            {
-                auto tmp = *this;
-                ++(*this);
-
-                return tmp;
-            }
-
-            list_node<value_type>* node()
-            {
-                return current_;
-            }
-
-            const list_node<value_type>* node() const
-            {
-                return current_;
-            }
-
-            size_type idx() const
-            {
-                return idx_;
-            }
-
-        private:
-            hash_table_bucket<value_type, size_type>* table_;
-            size_type idx_;
-            size_type max_idx_;
-            list_node<value_type>* current_;
-
-            template<class V, class CR, class CP, class S>
-            friend class hash_table_const_iterator;
-    };
-
-    template<class Value, class Ref, class Ptr, class Size>
-    bool operator==(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
-                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class Ref, class Ptr, class Size>
-    bool operator!=(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
-                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class ConstReference, class ConstPointer, class Size>
-    class hash_table_const_iterator
-    {
-        using non_const_iterator_type = hash_table_iterator<
-            Value, get_non_const_ref_t<ConstReference>,
-            get_non_const_ptr_t<ConstPointer>, Size
-        >;
-
-        public:
-            using value_type      = Value;
-            using size_type       = Size;
-            using const_reference = ConstReference;
-            using const_pointer   = ConstPointer;
-            using difference_type = ptrdiff_t;
-
-            using iterator_category = forward_iterator_tag;
-
-            hash_table_const_iterator(const hash_table_bucket<value_type, size_type>* table = nullptr,
-                                      size_type idx = size_type{}, size_type max_idx = size_type{},
-                                      const list_node<value_type>* current = nullptr)
-                : table_{table}, idx_{idx}, max_idx_{max_idx}, current_{current}
-            { /* DUMMY BODY */ }
-
-            hash_table_const_iterator(const hash_table_const_iterator&) = default;
-            hash_table_const_iterator& operator=(const hash_table_const_iterator&) = default;
-
-            hash_table_const_iterator(const non_const_iterator_type& other)
-                : table_{other.table_}, idx_{other.idx_}, max_idx_{other.max_idx_},
-                  current_{other.current_}
-            { /* DUMMY BODY */ }
-
-            hash_table_const_iterator& operator=(const non_const_iterator_type& other)
-            {
-                table_ = other.table_;
-                idx_ = other.idx_;
-                max_idx_ = other.max_idx_;
-                current_ = other.current_;
-
-                return *this;
-            }
-
-            const_reference operator*() const
-            {
-                return current_->value;
-            }
-
-            const_pointer operator->() const
-            {
-                return &current_->value;
-            }
-
-            hash_table_const_iterator& operator++()
-            {
-                current_ = current_->next;
-                if (current_ == table_[idx_].head)
-                {
-                    if (idx_ < max_idx_)
-                    {
-                        while (!table_[++idx_].head && idx_ < max_idx_)
-                        { /* DUMMY BODY */ }
-
-                        if (idx_ < max_idx_)
-                            current_ = table_[idx_].head;
-                        else
-                            current_ = nullptr;
-                    }
-                    else
-                        current_ = nullptr;
-                }
-
-                return *this;
-            }
-
-            hash_table_const_iterator operator++(int)
-            {
-                auto tmp = *this;
-                ++(*this);
-
-                return tmp;
-            }
-
-            list_node<value_type>* node()
-            {
-                return const_cast<list_node<value_type>*>(current_);
-            }
-
-            const list_node<value_type>* node() const
-            {
-                return current_;
-            }
-
-            size_type idx() const
-            {
-                return idx_;
-            }
-
-        private:
-            const hash_table_bucket<value_type, size_type>* table_;
-            size_type idx_;
-            size_type max_idx_;
-            const list_node<value_type>* current_;
-    };
-
-    template<class Value, class CRef, class CPtr, class Size>
-    bool operator==(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
-                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class CRef, class CPtr, class Size>
-    bool operator!=(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
-                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class Ref, class Ptr, class CRef, class CPtr, class Size>
-    bool operator==(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
-                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class Ref, class Ptr, class CRef, class CPtr, class Size>
-    bool operator!=(const hash_table_iterator<Value, Ref, Ptr, Size>& lhs,
-                    const hash_table_const_iterator<Value, CRef, CPtr, Size>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class CRef, class CPtr, class Ref, class Ptr, class Size>
-    bool operator==(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
-                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class CRef, class CPtr, class Ref, class Ptr, class Size>
-    bool operator!=(const hash_table_const_iterator<Value, CRef, CPtr, Size>& lhs,
-                    const hash_table_iterator<Value, Ref, Ptr, Size>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class Reference, class Pointer>
-    class hash_table_local_iterator
-    {
-        public:
-            using value_type      = Value;
-            using reference       = Reference;
-            using pointer         = Pointer;
-            using difference_type = ptrdiff_t;
-
-            using iterator_category = forward_iterator_tag;
-
-            hash_table_local_iterator(list_node<value_type>* head = nullptr,
-                                      list_node<value_type>* current = nullptr)
-                : head_{head}, current_{current}
-            { /* DUMMY BODY */ }
-
-            hash_table_local_iterator(const hash_table_local_iterator&) = default;
-            hash_table_local_iterator& operator=(const hash_table_local_iterator&) = default;
-
-            reference operator*()
-            {
-                return current_->value;
-            }
-
-            pointer operator->()
-            {
-                return &current_->value;
-            }
-
-            hash_table_local_iterator& operator++()
-            {
-                current_ = current_->next;
-                if (current_ == head_)
-                    current_ = nullptr;
-
-                return *this;
-            }
-
-            hash_table_local_iterator operator++(int)
-            {
-                auto tmp = *this;
-                ++(*this);
-
-                return tmp;
-            }
-
-            list_node<value_type>* node()
-            {
-                return current_;
-            }
-
-            const list_node<value_type>* node() const
-            {
-                return current_;
-            }
-
-        private:
-            list_node<value_type>* head_;
-            list_node<value_type>* current_;
-
-            template<class V, class CR, class CP>
-            friend class hash_table_const_local_iterator;
-    };
-
-    template<class Value, class Ref, class Ptr>
-    bool operator==(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
-                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class Ref, class Ptr>
-    bool operator!=(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
-                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class ConstReference, class ConstPointer>
-    class hash_table_const_local_iterator
-    {
-        using non_const_iterator_type = hash_table_local_iterator<
-            Value, get_non_const_ref_t<ConstReference>,
-            get_non_const_ptr_t<ConstPointer>
-        >;
-
-        public:
-            using value_type      = Value;
-            using const_reference = ConstReference;
-            using const_pointer   = ConstPointer;
-            using difference_type = ptrdiff_t;
-
-            using iterator_category = forward_iterator_tag;
-
-            // TODO: requirement for forward iterator is default constructibility, fix others!
-            hash_table_const_local_iterator(const list_node<value_type>* head = nullptr,
-                                            const list_node<value_type>* current = nullptr)
-                : head_{head}, current_{current}
-            { /* DUMMY BODY */ }
-
-            hash_table_const_local_iterator(const hash_table_const_local_iterator&) = default;
-            hash_table_const_local_iterator& operator=(const hash_table_const_local_iterator&) = default;
-
-            hash_table_const_local_iterator(const non_const_iterator_type& other)
-                : head_{other.head_}, current_{other.current_}
-            { /* DUMMY BODY */ }
-
-            hash_table_const_local_iterator& operator=(const non_const_iterator_type& other)
-            {
-                head_ = other.head_;
-                current_ = other.current_;
-
-                return *this;
-            }
-
-            const_reference operator*() const
-            {
-                return current_->value;
-            }
-
-            const_pointer operator->() const
-            {
-                return &current_->value;
-            }
-
-            hash_table_const_local_iterator& operator++()
-            {
-                current_ = current_->next;
-                if (current_ == head_)
-                    current_ = nullptr;
-
-                return *this;
-            }
-
-            hash_table_const_local_iterator operator++(int)
-            {
-                auto tmp = *this;
-                ++(*this);
-
-                return tmp;
-            }
-
-
-            list_node<value_type>* node()
-            {
-                return const_cast<list_node<value_type>*>(current_);
-            }
-
-            const list_node<value_type>* node() const
-            {
-                return current_;
-            }
-
-        private:
-            const list_node<value_type>* head_;
-            const list_node<value_type>* current_;
-    };
-
-    template<class Value, class CRef, class CPtr>
-    bool operator==(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
-                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class CRef, class CPtr>
-    bool operator!=(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
-                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class Ref, class Ptr, class CRef, class CPtr>
-    bool operator==(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
-                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class Ref, class Ptr, class CRef, class CPtr>
-    bool operator!=(const hash_table_local_iterator<Value, Ref, Ptr>& lhs,
-                    const hash_table_const_local_iterator<Value, CRef, CPtr>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class CRef, class CPtr, class Ref, class Ptr>
-    bool operator==(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
-                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
-    {
-        return lhs.node() == rhs.node();
-    }
-
-    template<class Value, class CRef, class CPtr, class Ref, class Ptr>
-    bool operator!=(const hash_table_const_local_iterator<Value, CRef, CPtr>& lhs,
-                    const hash_table_local_iterator<Value, Ref, Ptr>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/hash_table_policies.hpp
===================================================================
--- uspace/lib/cpp/include/internal/hash_table_policies.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,435 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_HASH_TABLE_POLICIES
-#define LIBCPP_INTERNAL_HASH_TABLE_POLICIES
-
-#include <tuple>
-#include <utility>
-
-namespace std::aux
-{
-    struct hash_single_policy
-    {
-        template<class Table, class Key>
-        static typename Table::size_type count(const Table& table, const Key& key)
-        {
-            return table.find(key) == table.end() ? 0 : 1;
-        }
-
-        template<class Table, class Key>
-        static typename Table::place_type find_insertion_spot(const Table& table, const Key& key)
-        {
-            auto idx = table.get_bucket_idx_(key);
-            return make_tuple(
-                &table.table_[idx],
-                table.table_[idx].head,
-                idx
-            );
-        }
-
-        template<class Table, class Key>
-        static typename Table::size_type erase(Table& table, const Key& key)
-        {
-            auto idx = table.get_bucket_idx_(key);
-            auto head = table.table_[idx].head;
-            auto current = head;
-
-            if (!current)
-                return 0;
-
-            do
-            {
-                if (table.keys_equal(key, current->value))
-                {
-                    --table.size_;
-
-                    if (current == head)
-                    {
-                        if (current->next != head)
-                            table.table_[idx].head = current->next;
-                        else
-                            table.table_[idx].head = nullptr;
-                    }
-
-                    current->unlink();
-                    delete current;
-
-                    return 1;
-                }
-                else
-                    current = current->next;
-            }
-            while (current != head);
-
-            return 0;
-        }
-
-        template<class Table, class Key>
-        static pair<
-            typename Table::iterator,
-            typename Table::iterator
-        > equal_range(Table& table, const Key& key)
-        {
-            auto it = table.find(key);
-            return make_pair(it, ++it);
-        }
-
-        template<class Table, class Key>
-        static pair<
-            typename Table::const_iterator,
-            typename Table::const_iterator
-        > equal_range_const(const Table& table, const Key& key)
-        { // Note: We cannot overload by return type, so we use a different name.
-            auto it = table.find(key);
-            return make_pair(it, ++it);
-        }
-
-        /**
-         * Note: We have to duplicate code for emplace, insert(const&)
-         *       and insert(&&) here, because the node (which makes distinction
-         *       between the arguments) is only created if the value isn't
-         *       in the table already.
-         */
-
-        template<class Table, class... Args>
-        static pair<
-            typename Table::iterator, bool
-        > emplace(Table& table, Args&&... args)
-        {
-            using value_type = typename Table::value_type;
-            using node_type  = typename Table::node_type;
-            using iterator   = typename Table::iterator;
-
-            table.increment_size();
-
-            auto val = value_type{forward<Args>(args)...};
-            const auto& key = table.get_key(val);
-            auto [bucket, target, idx] = table.find_insertion_spot(key);
-
-            if (!bucket)
-                return make_pair(table.end(), false);
-
-            if (target && table.keys_equal(key, target->value))
-            {
-                table.decrement_size();
-
-                return make_pair(
-                    iterator{
-                        table.table(), idx, table.bucket_count(),
-                        target
-                    },
-                    false
-                );
-            }
-            else
-            {
-                auto node = new node_type{move(val)};
-                bucket->prepend(node);
-
-                return make_pair(iterator{
-                    table.table(), idx,
-                    table.bucket_count(),
-                    node
-                }, true);
-            }
-        }
-
-        template<class Table, class Value>
-        static pair<
-            typename Table::iterator, bool
-        > insert(Table& table, const Value& val)
-        {
-            using node_type  = typename Table::node_type;
-            using iterator   = typename Table::iterator;
-
-            table.increment_size();
-
-            const auto& key = table.get_key(val);
-            auto [bucket, target, idx] = table.find_insertion_spot(key);
-
-            if (!bucket)
-                return make_pair(table.end(), false);
-
-            if (target && table.keys_equal(key, target->value))
-            {
-                table.decrement_size();
-
-                return make_pair(
-                    iterator{
-                        table.table(), idx, table.bucket_count(),
-                        target
-                    },
-                    false
-                );
-            }
-            else
-            {
-                auto node = new node_type{val};
-                bucket->prepend(node);
-
-                return make_pair(iterator{
-                    table.table(), idx,
-                    table.bucket_count(),
-                    node
-                }, true);
-            }
-        }
-
-        template<class Table, class Value>
-        static pair<
-            typename Table::iterator, bool
-        > insert(Table& table, Value&& val)
-        {
-            using value_type = typename Table::value_type;
-            using node_type  = typename Table::node_type;
-            using iterator   = typename Table::iterator;
-
-            table.increment_size();
-
-            const auto& key = table.get_key(val);
-            auto [bucket, target, idx] = table.find_insertion_spot(key);
-
-            if (!bucket)
-                return make_pair(table.end(), false);
-
-            if (target && table.keys_equal(key, target->value))
-            {
-                table.decrement_size();
-
-                return make_pair(
-                    iterator{
-                        table.table(), idx, table.bucket_count(),
-                        target
-                    },
-                    false
-                );
-            }
-            else
-            {
-                auto node = new node_type{forward<value_type>(val)};
-                bucket->prepend(node);
-
-                return make_pair(iterator{
-                    table.table(), idx,
-                    table.bucket_count(),
-                    node
-                }, true);
-            }
-        }
-    };
-
-    struct hash_multi_policy
-    {
-        template<class Table, class Key>
-        static typename Table::size_type count(const Table& table, const Key& key)
-        {
-            auto head = table.table_[table.get_bucket_idx_(key)].head;
-            if (!head)
-                return 0;
-
-            auto current = head;
-            typename Table::size_type res = 0;
-            do
-            {
-                if (table.keys_equal(key, current->value))
-                    ++res;
-
-                current = current->next;
-            }
-            while (current != head);
-
-            return res;
-        }
-
-        template<class Table, class Key>
-        static typename Table::place_type find_insertion_spot(const Table& table, const Key& key)
-        {
-            auto idx = table.get_bucket_idx_(key);
-            auto head = table.table_[idx].head;
-
-            if (head)
-            {
-                auto current = head;
-                do
-                {
-                    if (table.keys_equal(key, current->value))
-                    {
-                        return make_tuple(
-                            &table.table_[idx],
-                            current,
-                            idx
-                        );
-                    }
-
-                    current = current->next;
-                } while (current != head);
-            }
-
-            return make_tuple(
-                &table.table_[idx],
-                table.table_[idx].head,
-                idx
-            );
-        }
-
-        template<class Table, class Key>
-        static typename Table::size_type erase(Table& table, const Key& key)
-        {
-            auto idx = table.get_bucket_idx_(key);
-            auto head = table.table_[idx].head;
-            auto current = head;
-            table.table_[idx].head = nullptr;
-
-            if (!current)
-                return 0;
-
-            /**
-             * We traverse the list and delete if the keys
-             * equal, if they don't we append the nodes back
-             * to the bucket.
-             */
-            typename Table::size_type res{};
-
-            do
-            {
-                auto tmp = current;
-                current = current->next;
-
-                if (!table.keys_equal(key, tmp->value))
-                    table.table_[idx].append(tmp);
-                else
-                {
-                    ++res;
-                    --table.size_;
-
-                    delete tmp;
-                }
-            }
-            while (current != head);
-
-            return res;
-        }
-
-        template<class Table, class Key>
-        static pair<
-            typename Table::iterator,
-            typename Table::iterator
-        > equal_range(Table& table, const Key& key)
-        {
-            auto first = table.find(key);
-            if (first == table.end())
-                return make_pair(table.end(), table.end());
-
-            auto last = first;
-            do
-            {
-                ++last;
-            } while (table.keys_equal(key, *last));
-
-            return make_pair(first, last);
-        }
-
-        template<class Table, class Key>
-        static pair<
-            typename Table::const_iterator,
-            typename Table::const_iterator
-        > equal_range_const(const Table& table, const Key& key)
-        {
-            auto first = table.find(key);
-            if (first == table.end())
-                return make_pair(table.end(), table.end());
-
-            auto last = first;
-            do
-            {
-                ++last;
-            } while (table.keys_equal(key, *last));
-
-            return make_pair(first, last);
-        }
-
-        template<class Table, class... Args>
-        static typename Table::iterator emplace(Table& table, Args&&... args)
-        {
-            using node_type  = typename Table::node_type;
-
-            auto node = new node_type{forward<Args>(args)...};
-
-            return insert(table, node);
-        }
-
-        template<class Table, class Value>
-        static typename Table::iterator insert(Table& table, const Value& val)
-        {
-            using node_type  = typename Table::node_type;
-
-            auto node = new node_type{val};
-
-            return insert(table, node);
-        }
-
-        template<class Table, class Value>
-        static typename Table::iterator insert(Table& table, Value&& val)
-        {
-            using value_type = typename Table::value_type;
-            using node_type  = typename Table::node_type;
-
-            auto node = new node_type{forward<value_type>(val)};
-
-            return insert(table, node);
-        }
-
-        template<class Table>
-        static typename Table::iterator insert(Table& table, typename Table::node_type* node)
-        {
-            using iterator   = typename Table::iterator;
-
-            table.increment_size();
-
-            const auto& key = table.get_key(node->value);
-            auto [bucket, target, idx] = table.find_insertion_spot(key);
-
-            if (!bucket)
-                table.end();
-
-            if (target && table.keys_equal(key, target->value))
-                target->append(node);
-            else
-                bucket->prepend(node);
-
-            return iterator{
-                table.table(), idx,
-                table.bucket_count(),
-                node
-            };
-        }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/insert_iterator.hpp
===================================================================
--- uspace/lib/cpp/include/internal/insert_iterator.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,118 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_INSERT_ITERATOR
-#define LIBCPP_INTERNAL_INSERT_ITERATOR
-
-namespace std
-{
-    struct forward_iterator_tag;
-}
-
-namespace std::aux
-{
-    /**
-     * Note: Commonly the data structures in this library
-     *       contain a set of insert member functions. These
-     *       are often both iterator based and copy based.
-     *       This iterator can change the copy version into
-     *       an iterator version by creating a count based copy
-     *       iterator.
-     * Usage:
-     *      first == insert_iterator{value}
-     *      last  == insert_iterator{count}
-     *
-     *      So the following code:
-     *          while (first != last)
-     *              *data_++ = *first++;
-     *
-     *      Will insert a copy of value into the data_
-     *      iterator exactly count times.
-     * TODO: Apply this to existing containers?
-     */
-    template<class T>
-    class insert_iterator
-    {
-        public:
-            using difference_type   = unsigned long long;
-            using value_type        = T;
-            using iterator_category = input_iterator_tag;
-            using reference         = value_type&;
-            using pointer           = value_type*;
-
-            explicit insert_iterator(difference_type count, const value_type& val = value_type{})
-                : value_{val}, count_{count}
-            { /* DUMMY BODY */ }
-
-            insert_iterator(const insert_iterator&) = default;
-            insert_iterator& operator=(const insert_iterator&) = default;
-
-            insert_iterator(insert_iterator&&) = default;
-            insert_iterator& operator=(insert_iterator&&) = default;
-
-            const value_type& operator*() const
-            {
-                return value_;
-            }
-
-            const value_type* operator->() const
-            {
-                return &value_;
-            }
-
-            insert_iterator& operator++()
-            {
-                ++count_;
-
-                return *this;
-            }
-
-            insert_iterator operator++(int)
-            {
-                ++count_;
-
-                return insert_iterator{count_ - 1, value_};
-            }
-
-            bool operator==(const insert_iterator& other)
-            {
-                return count_ == other.count_;
-            }
-
-            bool operator!=(const insert_iterator& other)
-            {
-                return count_ != other.count_;
-            }
-
-        private:
-            value_type value_;
-            difference_type count_;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/iomanip.hpp
===================================================================
--- uspace/lib/cpp/include/internal/iomanip.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,156 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_IOMANIP
-#define LIBCPP_INTERNAL_IOMANIP
-
-#include <ios>
-#include <utility>
-
-namespace std::aux
-{
-    /**
-     * Note: This allows us to lower the amount
-     *       of code duplication in this module
-     *       as we can avoid operator<</>> overloading
-     *       for the manipulators.
-     */
-    template<class Manipulator>
-    struct manip_wrapper
-    {
-        template<class... Args>
-        manip_wrapper(Args&&... args)
-            : manipulator{forward<Args>(args)...}
-        { /* DUMMY BODY */ }
-
-        void operator()(ios_base& str)
-        {
-            manipulator(str);
-        }
-
-        Manipulator manipulator;
-    };
-    template<class Char, class Traits, class Manipulator>
-    basic_ostream<Char, Traits>& operator<<(
-        basic_ostream<Char, Traits>& os, manip_wrapper<Manipulator> manip
-    )
-    {
-        manip(os);
-
-        return os;
-    }
-
-    template<class Char, class Traits, class Manipulator>
-    basic_istream<Char, Traits>& operator>>(
-        basic_istream<Char, Traits>& is, manip_wrapper<Manipulator> manip
-    )
-    {
-        manip(is);
-
-        return is;
-    }
-
-    struct resetiosflags_t
-    {
-        resetiosflags_t(ios_base::fmtflags m);
-
-        void operator()(ios_base& str) const;
-
-        ios_base::fmtflags mask;
-    };
-
-    struct setiosflags_t
-    {
-        setiosflags_t(ios_base::fmtflags m);
-
-        void operator()(ios_base& str) const;
-
-        ios_base::fmtflags mask;
-    };
-
-    struct setbase_t
-    {
-        setbase_t(int b);
-
-        void operator()(ios_base& str) const;
-
-        int base;
-    };
-
-    /**
-     * Note: setfill is only for basic_ostream so
-     *       this is the only case where we overload
-     *       the appropriate operator again.
-     */
-    template<class Char>
-    struct setfill_t
-    {
-        setfill_t(Char c)
-            : fill{c}
-        { /* DUMMY BODY */ }
-
-        template<class Traits>
-        void operator()(basic_ios<Char, Traits>& str) const
-        {
-            str.fill(fill);
-        }
-
-        Char fill;
-    };
-
-    template<class Char, class Traits>
-    basic_ostream<Char, Traits>& operator<<(
-        basic_ostream<Char, Traits>& is,
-        setfill_t<Char> manip
-    )
-    {
-        manip(is);
-
-        return is;
-    }
-
-    struct setprecision_t
-    {
-        setprecision_t(int);
-
-        void operator()(ios_base&) const;
-
-        int prec;
-    };
-
-    struct setw_t
-    {
-        setw_t(int);
-
-        void operator()(ios_base&) const;
-
-        int width;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/iterator.hpp
===================================================================
--- uspace/lib/cpp/include/internal/iterator.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,69 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_ITERATOR
-#define LIBCPP_INTERNAL_ITERATOR
-
-#include <internal/aux.hpp>
-
-namespace std::aux
-{
-    /**
-     * Used for our custom iterators where we know
-     * that their references/const_references and
-     * pointers/const_pointers differ only in constness.
-     */
-
-    template<class T>
-    struct get_non_const_ref
-        : type_is<T>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct get_non_const_ref<const T&>
-        : type_is<T&>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    using get_non_const_ref_t = typename get_non_const_ref<T>::type;
-
-    template<class T>
-    struct get_non_const_ptr
-        : type_is<T>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct get_non_const_ptr<const T*>
-        : type_is<T*>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    using get_non_const_ptr_t = typename get_non_const_ptr<T>::type;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/key_extractors.hpp
===================================================================
--- uspace/lib/cpp/include/internal/key_extractors.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_KEY_EXTRACTORS
-#define LIBCPP_INTERNAL_KEY_EXTRACTORS
-
-#include <utility>
-
-namespace std::aux
-{
-    template<class Key, class Value>
-    struct key_value_key_extractor
-    {
-        const Key& operator()(const pair<const Key, Value>& p) const noexcept
-        {
-            return p.first;
-        }
-    };
-
-    template<class Key>
-    struct key_no_value_key_extractor
-    {
-        Key& operator()(Key& k) const noexcept
-        {
-            return k;
-        }
-
-        const Key& operator()(const Key& k) const noexcept
-        {
-            return k;
-        }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/list.hpp
===================================================================
--- uspace/lib/cpp/include/internal/list.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_LIST
-#define LIBCPP_INTERNAL_LIST
-
-namespace std::aux
-{
-    template<class T>
-    struct list_node
-    {
-        T value;
-        list_node* next;
-        list_node* prev;
-
-        template<class... Args>
-        list_node(Args&&... args)
-            : value{forward<Args>(args)...},
-              next{}, prev{}
-        {
-            next = this;
-            prev = this;
-        }
-
-        list_node(const T& val)
-            : value{val}, next{}, prev{}
-        {
-            next = this;
-            prev = this;
-        }
-
-        list_node(T&& val)
-            : value{forward<T>(val)}, next{}, prev{}
-        {
-            next = this;
-            prev = this;
-        }
-
-        void append(list_node* node)
-        {
-            node->next = next;
-            node->prev = this;
-            next->prev = node;
-            next = node;
-        }
-
-        void prepend(list_node* node)
-        {
-            node->next = this;
-            node->prev = prev;
-            prev->next = node;
-            prev = node;
-        }
-
-        void unlink()
-        {
-            prev->next = next;
-            next->prev = prev;
-            next = this;
-            prev = this;
-        }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/locale.hpp
===================================================================
--- uspace/lib/cpp/include/internal/locale.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,173 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_LOCALE
-#define LIBCPP_INTERNAL_LOCALE
-
-#include <impl/string.hpp>
-
-namespace std
-{
-    class locale;
-
-    /**
-     * 22.3.1, class locale:
-     */
-
-    class locale
-    {
-        public:
-            class facet
-            {
-                protected:
-                    explicit facet(size_t refs = 0);
-
-                    virtual ~facet();
-
-                    facet(const facet&) = delete;
-                    void operator=(const facet&) = delete;
-            };
-
-            class id
-            {
-                public:
-                    id() = default;
-
-                    id(const id&) = delete;
-                    void operator=(const id&) = delete;
-            };
-
-            using category = int;
-
-            static const category none     = 0b000'0001;
-            static const category collate  = 0b000'0010;
-            static const category ctype    = 0b000'0100;
-            static const category monetary = 0b000'1000;
-            static const category numeric  = 0b001'0000;
-            static const category time     = 0b010'0000;
-            static const category messages = 0b100'0000;
-            static const category all      = collate | ctype | monetary |
-                                             numeric | time | messages;
-
-            locale() noexcept;
-
-            locale(const locale& other) noexcept;
-
-            explicit locale(const char* name);
-
-            explicit locale(const string& name);
-
-            locale(const locale& other, const char* name, category);
-
-            locale(const locale& other, const string& name, category);
-
-            template<class Facet>
-            locale(const locale& other, Facet* f)
-                : name_{other.name_}
-            { /* DUMMY BODY */ }
-
-            locale(const locale& other, const locale& one, category);
-
-            ~locale() = default;
-
-            const locale& operator=(const locale& other) noexcept;
-
-            template<class Facet>
-            locale combine(const locale& other) const
-            {
-                return other;
-            }
-
-            string name() const;
-
-            bool operator==(const locale& other) const;
-            bool operator!=(const locale& other) const;
-
-            template<class Char, class Traits, class Allocator>
-            bool operator()(const basic_string<Char, Traits, Allocator>& s1,
-                            const basic_string<Char, Traits, Allocator>& s2) const
-            {
-                // TODO: define outside locale
-                /* return use_facet<collate<Char>>(*this).compare( */
-                /*     s1.begin(), s1.end(), s2.begin(), s2.end() */
-                /* ) < 0; */
-                return false;
-            }
-
-            static locale global(const locale&)
-            {
-                return *the_locale_;
-            }
-
-            static const locale& classic()
-            {
-                return *the_locale_;
-            }
-
-        private:
-            string name_;
-
-            // TODO: implement the_locale_
-            static constexpr locale* the_locale_{nullptr};
-
-            template<class Facet>
-            friend bool has_facet(const locale&);
-
-            template<class Facet>
-            bool has_()
-            { // Our single locale atm has all facets.
-                return true;
-            }
-
-            template<class Facet>
-            /* friend const Facet& use_facet(const locale&); */
-            friend Facet use_facet(const locale&);
-
-            template<class Facet>
-            /* const Facet& get_() const */
-            Facet get_() const
-            {
-                return Facet{0U};
-            }
-    };
-
-    template<class Facet>
-    /* const Facet& use_facet(const locale& loc) */
-    Facet use_facet(const locale& loc)
-    {
-        return loc.get_<Facet>();
-    }
-
-    template<class Facet>
-    bool has_facet(const locale& loc)
-    {
-        return loc.has_<Facet>();
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/locale/codecvt.hpp
===================================================================
--- uspace/lib/cpp/include/internal/locale/codecvt.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,178 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_LOCALE_CODECVT
-#define LIBCPP_INTERNAL_LOCALE_CODECVT
-
-#include <intetnal/locale.hpp>
-#include <string>
-
-namespace std
-{
-    /**
-     * 22.4.1.4, class template codecvt:
-     */
-
-    class codecvt_base
-    {
-        public:
-            enum result
-            {
-                ok, partial, error, noconv
-            };
-    };
-
-    template<class Intern, class Extern, class State>
-    class codecvt: public codecvt_base
-    {
-        public:
-            using intern_type = Intern;
-            using extern_type = Extern;
-            using state_type  = State;
-
-            explicit codecvt(size_t = 0)
-            { /* DUMMY BODY */ }
-
-            result out(state_type& state, const intern_type* from, const intern_type* from_end,
-                       const intern_type*& from_next, extern_type* to, extern_type* to_end,
-                       extern_type*& to_next) const
-            {
-                return do_out(state, from, from_end, from_next, to, to_end, to_next);
-            }
-
-            result unshift(state_type& state, extern_type* to, extern_type* to_end,
-                           extern_type*& to_next) const
-            {
-                return do_unshift(state, to, to_end, to_next);
-            }
-
-            result in(state_type& state, const extern_type* from, const extern_type* from_end,
-                      const extern_type*& from_next, intern_type* to, intern_type* to_end,
-                      intern_type*& to_next) const
-            {
-                return do_in(state, from, from_end, from_next, to, to_end, to_next);
-            }
-
-            int encoding() const noexcept
-            {
-                return do_encoding();
-            }
-
-            bool always_noconv() const noexcept
-            {
-                return do_always_noconv();
-            }
-
-            int length(state_type& state, const extern_type* from, const extern_type* end,
-                       size_t max) const
-            {
-                return do_length(state, from, end, max);
-            }
-
-            int max_length() const noexcept
-            {
-                return do_max_length();
-            }
-
-            static locale::id id;
-
-            ~codecvt() = default;
-
-        protected:
-            virtual result do_out(state_type& state, const intern_type* from, const intern_type* from_end,
-                                  const intern_type*& from_next, extern_type* to, extern_type* to_end,
-                                  extern_type*& to_next) const
-            {
-                // TODO: implement
-                return error;
-            }
-
-            virtual result do_unshift(state_type& state, extern_type* to, extern_type* to_end,
-                                      extern_type*& to_next) const
-            {
-                // TODO: implement
-                return error;
-            }
-
-            virtual result do_in(state_type& state, const extern_type* from, const extern_type* from_end,
-                                 const extern_type*& from_next, intern_type* to, intern_type* to_end,
-                                 intern_type*& to_next) const
-            {
-                // TODO: implement
-                return error;
-            }
-
-            virtual int do_encoding() const noexcept
-            {
-                // TODO: implement
-                return 0;
-            }
-
-            virtual bool do_always_noconv() const noexcept
-            {
-                // TODO: implement
-                return false;
-            }
-
-            virtual int do_length(state_type& state, const extern_type* from, const extern_type* end,
-                                  size_t max) const
-            {
-                // TODO: implement
-                return 0;
-            }
-
-            virtual int do_max_length() const noexcept
-            {
-                // TODO: implement
-                return 0;
-            }
-    };
-
-    template<class Intern, class Extern, class State>
-    locale::id codecvt<Intern, Extern, State>::id{};
-
-    /**
-     * 22.4.1.5, class template codecvt_byname:
-     * Note: Dummy, TODO: implement.
-     */
-
-    template<class Intern, class Extern, class State>
-    class codecvt_byname: public codecvt<Intern, Extern, State>
-    {
-        public:
-            explicit codecvt_byname(const char*, size_t = 0)
-            { /* DUMMY BODY */ }
-
-            explicit codecvt_byname(const string&, size_t = 0)
-            { /* DUMMY BODY */ }
-
-            ~codecvt_byname() = default;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/locale/ctype.hpp
===================================================================
--- uspace/lib/cpp/include/internal/locale/ctype.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,611 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_LOCALE_CTYPE
-#define LIBCPP_INTERNAL_LOCALE_CTYPE
-
-#include <cctype>
-#include <internal/locale.hpp>
-#include <impl/string.hpp>
-
-namespace std
-{
-    /**
-     * 22.4.1, the type category:
-     */
-
-    class ctype_base
-    {
-        public:
-            using mask = uint16_t;
-
-            static constexpr mask space  = 0b00'0000'0001;
-            static constexpr mask print  = 0b00'0000'0010;
-            static constexpr mask cntrl  = 0b00'0000'0100;
-            static constexpr mask upper  = 0b00'0000'1000;
-            static constexpr mask lower  = 0b00'0001'0000;
-            static constexpr mask alpha  = 0b00'0010'0000;
-            static constexpr mask digit  = 0b00'0100'0000;
-            static constexpr mask punct  = 0b00'1000'0000;
-            static constexpr mask xdigit = 0b01'0000'0000;
-            static constexpr mask blank  = 0b10'0000'0000;
-            static constexpr mask alnum  = alpha | digit;
-            static constexpr mask graph  = alnum | punct;
-    };
-
-    /**
-     * 22.4.1.1, class template ctype:
-     */
-
-    template<class Char>
-    class ctype: public locale::facet, public ctype_base
-    {
-        public:
-            using char_type = Char;
-
-            explicit ctype(size_t)
-            { /* DUMMY BODY */ }
-
-            bool is(mask m, char_type c) const
-            {
-                return do_is(m, c);
-            }
-
-            const char_type* is(const char_type* low, const char_type* high,
-                                mask* vec) const
-            {
-                return do_is(low, high, vec);
-            }
-
-            const char_type* scan_is(mask m, const char_type* low,
-                                     const char_type* high) const
-            {
-                return do_scan_is(m, low, high);
-            }
-
-            const char_type* scan_not(mask m, const char_type* low,
-                                      const char_type* high) const
-            {
-                return do_scan_not(m, low, high);
-            }
-
-            char_type toupper(char_type c) const
-            {
-                return do_toupper(c);
-            }
-
-            const char_type* toupper(char_type* low, const char_type* high) const
-            {
-                return do_toupper(low, high);
-            }
-
-            char_type tolower(char_type c) const
-            {
-                return do_tolower(c);
-            }
-
-            const char_type* tolower(char_type* low, const char_type* high) const
-            {
-                return do_tolower(low, high);
-            }
-
-            char_type widen(char c) const
-            {
-                return do_widen(c);
-            }
-
-            const char_type* widen(const char* low, const char* high, char_type* to) const
-            {
-                return do_widen(low, high, to);
-            }
-
-            char narrow(char_type c, char def) const
-            {
-                return do_narrow(c, def);
-            }
-
-            const char_type* narrow(const char_type* low, const char_type* high,
-                                    char def, char* to) const
-            {
-                return do_narrow(low, high, def, to);
-            }
-
-            static locale::id id;
-
-            /**
-             * Note: This is a deviation from the standard, because in the
-             *       ISO C++ Standard this function is protected (because
-             *       the instances are reference counted, but in our design
-             *       they are not and as such we did this change).
-             *       (This applies to all constructors of all facets.)
-             */
-            ~ctype() = default;
-
-        protected:
-            virtual bool do_is(mask m, char_type c) const
-            {
-                // TODO: implement
-                return false;
-            }
-
-            virtual const char_type* do_is(const char_type* low, const char_type high,
-                                           mask m) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual const char_type* do_scan_is(mask m, const char_type* low,
-                                                const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual const char_type* do_scan_not(mask m, const char_type* low,
-                                                 const char_type* high) const
-            {
-                // TODO: implement
-                return low;
-            }
-
-            virtual char_type do_toupper(char_type c) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_toupper(char_type* low, const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual char_type do_tolower(char_type c) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_tolower(char_type* low, const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual char_type do_widen(char c) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_widen(const char* low, const char* high,
-                                              char_type* dest) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual char do_narrow(char_type c, char def) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_narrow(const char_type* low, const char_type* high,
-                                               char def, char* dest) const
-            {
-                // TODO: implement
-                return high;
-            }
-    };
-
-    template<class Char>
-    locale::id ctype<Char>::id{};
-
-    /**
-     * 22.4.1.2, class template ctype_byname:
-     * Note: Dummy, TODO: implement.
-     */
-
-    template<class Char>
-    class ctype_byname: public ctype<Char>
-    {
-        public:
-            using mask = typename ctype<Char>::mask;
-
-            explicit ctype_byname(const char* name, size_t = 0)
-            { /* DUMMY BODY */ }
-
-            explicit ctype_byname(const string& name, size_t = 0)
-            { /* DUMMY BODY */ }
-
-        protected:
-            ~ctype_byname() = default;
-    };
-
-    /**
-     * 22.4.1.3, ctype specialziations:
-     */
-
-    template<>
-    class ctype<char>: public locale::facet, public ctype_base
-    {
-        public:
-            using char_type = char;
-
-            explicit ctype(const mask* tab = nullptr, bool del = false, size_t = 0)
-            { /* DUMMY BODY */ }
-
-            bool is(mask m, char_type c) const
-            {
-                return do_is(m, c);
-            }
-
-            const char_type* is(const char_type* low, const char_type* high,
-                                mask* vec) const
-            {
-                return do_is(low, high, vec);
-            }
-
-            const char_type* scan_is(mask m, const char_type* low,
-                                     const char_type* high) const
-            {
-                return do_scan_is(m, low, high);
-            }
-
-            const char_type* scan_not(mask m, const char_type* low,
-                                      const char_type* high) const
-            {
-                return do_scan_not(m, low, high);
-            }
-
-            char_type toupper(char_type c) const
-            {
-                return do_toupper(c);
-            }
-
-            const char_type* toupper(char_type* low, const char_type* high) const
-            {
-                return do_toupper(low, high);
-            }
-
-            char_type tolower(char_type c) const
-            {
-                return do_tolower(c);
-            }
-
-            const char_type* tolower(char_type* low, const char_type* high) const
-            {
-                return do_tolower(low, high);
-            }
-
-            char_type widen(char c) const
-            {
-                return do_widen(c);
-            }
-
-            const char_type* widen(const char* low, const char* high, char_type* to) const
-            {
-                return do_widen(low, high, to);
-            }
-
-            char narrow(char_type c, char def) const
-            {
-                return do_narrow(c, def);
-            }
-
-            const char_type* narrow(const char_type* low, const char_type* high,
-                                    char def, char* to) const
-            {
-                return do_narrow(low, high, def, to);
-            }
-
-            static locale::id id;
-            static const size_t table_size{0};
-
-            const mask* table() const noexcept
-            {
-                return classic_table();
-            }
-
-            static const mask* classic_table() noexcept
-            {
-                return classic_table_;
-            }
-
-            ~ctype() = default;
-
-        protected:
-            virtual bool do_is(mask m, char_type c) const
-            {
-                // TODO: implement, this is a dummy
-                if ((m & space) != 0 && std::isspace(c))
-                    return true;
-                else if ((m & alpha) != 0 && std::isalpha(c))
-                    return true;
-                else if ((m & upper) != 0 && std::isupper(c))
-                    return true;
-                else if ((m & lower) != 0 && std::islower(c))
-                    return true;
-                else if ((m & digit) != 0 && std::isdigit(c))
-                    return true;
-                return false;
-            }
-
-            virtual const char_type* do_is(const char_type* low, const char_type* high,
-                                           mask* m) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual const char_type* do_scan_is(mask m, const char_type* low,
-                                                const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual const char_type* do_scan_not(mask m, const char_type* low,
-                                                 const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual char_type do_toupper(char_type c) const
-            {
-                return std::toupper(c);
-            }
-
-            virtual const char_type* do_toupper(char_type* low, const char_type* high) const
-            {
-                while (low != high)
-                    *low = std::toupper(*low);
-
-                return high;
-            }
-
-            virtual char_type do_tolower(char_type c) const
-            {
-                return std::tolower(c);
-            }
-
-            virtual const char_type* do_tolower(char_type* low, const char_type* high) const
-            {
-                while (low != high)
-                    *low = std::tolower(*low);
-
-                return high;
-            }
-
-            virtual char_type do_widen(char c) const
-            {
-                return c;
-            }
-
-            virtual const char_type* do_widen(const char* low, const char* high,
-                                              char_type* dest) const
-            {
-                while (low != high)
-                    *dest++ = *low++;
-
-                return high;
-            }
-
-            virtual char do_narrow(char_type c, char def) const
-            {
-                return c;
-            }
-
-            virtual const char_type* do_narrow(const char_type* low, const char_type* high,
-                                               char def, char* dest) const
-            {
-                while (low != high)
-                    *dest++ = *low++;
-
-                return high;
-            }
-
-        private:
-            static constexpr mask* classic_table_{nullptr};
-    };
-
-    template<>
-    class ctype<wchar_t>: public locale::facet, public ctype_base
-    {
-        public:
-            using char_type = wchar_t;
-
-            explicit ctype(const mask* tab = nullptr, bool del = false, size_t = 0)
-            { /* DUMMY BODY */ }
-
-            bool is(mask m, char_type c) const
-            {
-                return do_is(m, c);
-            }
-
-            const char_type* is(const char_type* low, const char_type* high,
-                                mask* vec) const
-            {
-                return do_is(low, high, vec);
-            }
-
-            const char_type* scan_is(mask m, const char_type* low,
-                                     const char_type* high) const
-            {
-                return do_scan_is(m, low, high);
-            }
-
-            const char_type* scan_not(mask m, const char_type* low,
-                                      const char_type* high) const
-            {
-                return do_scan_not(m, low, high);
-            }
-
-            char_type toupper(char_type c) const
-            {
-                return do_toupper(c);
-            }
-
-            const char_type* toupper(char_type* low, const char_type* high) const
-            {
-                return do_toupper(low, high);
-            }
-
-            char_type tolower(char_type c) const
-            {
-                return do_tolower(c);
-            }
-
-            const char_type* tolower(char_type* low, const char_type* high) const
-            {
-                return do_tolower(low, high);
-            }
-
-            char_type widen(char c) const
-            {
-                return do_widen(c);
-            }
-
-            const char_type* widen(const char* low, const char* high, char_type* to) const
-            {
-                return do_widen(low, high, to);
-            }
-
-            char narrow(char_type c, char def) const
-            {
-                return do_narrow(c, def);
-            }
-
-            const char_type* narrow(const char_type* low, const char_type* high,
-                                    char def, char* to) const
-            {
-                return do_narrow(low, high, def, to);
-            }
-
-            static locale::id id;
-            static const size_t table_size{0};
-
-            const mask* table() const noexcept
-            {
-                return classic_table();
-            }
-
-            static const mask* classic_table() noexcept
-            {
-                return classic_table_;
-            }
-
-            ~ctype() = default;
-
-        protected:
-            virtual bool do_is(mask m, char_type c) const
-            {
-                // TODO: implement
-                return false;
-            }
-
-            virtual const char_type* do_is(const char_type* low, const char_type* high,
-                                           mask* m) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual const char_type* do_scan_is(mask m, const char_type* low,
-                                                const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual const char_type* do_scan_not(mask m, const char_type* low,
-                                                 const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual char_type do_toupper(char_type c) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_toupper(char_type* low, const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual char_type do_tolower(char_type c) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_tolower(char_type* low, const char_type* high) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-            virtual char_type do_widen(char c) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_widen(const char* low, const char* high,
-                                              char_type* dest) const
-            {
-                // TODO: implement
-                return dest;
-            }
-
-            virtual char do_narrow(char_type c, char def) const
-            {
-                // TODO: implement
-                return c;
-            }
-
-            virtual const char_type* do_narrow(const char_type* low, const char_type* high,
-                                               char def, char* dest) const
-            {
-                // TODO: implement
-                return high;
-            }
-
-        private:
-            static constexpr mask* classic_table_{nullptr};
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/locale/num_get.hpp
===================================================================
--- uspace/lib/cpp/include/internal/locale/num_get.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,369 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_LOCALE_NUM_GET
-#define LIBCPP_INTERNAL_LOCALE_NUM_GET
-
-#include <cerrno>
-#include <cstring>
-#include <internal/locale.hpp>
-#include <internal/locale/numpunct.hpp>
-#include <ios>
-#include <iterator>
-#include <limits>
-
-namespace std
-{
-    /**
-     * 22.4.2.1, class template num_get:
-     */
-
-    template<class Char, class InputIterator = istreambuf_iterator<Char>>
-    class num_get: public locale::facet
-    {
-        public:
-            using char_type = Char;
-            using iter_type = InputIterator;
-
-            explicit num_get(size_t refs = 0)
-            { /* DUMMY BODY */ }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, bool& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, long& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, long long& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, unsigned short& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, unsigned int& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, unsigned long& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, unsigned long long& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, float& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, double& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, long double& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            iter_type get(iter_type in, iter_type end, ios_base& base,
-                          ios_base::iostate& err, void*& v) const
-            {
-                return do_get(in, end, base, err, v);
-            }
-
-            static locale::id id;
-
-            ~num_get()
-            { /* DUMMY BODY */ }
-
-        protected:
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, bool& v) const
-            {
-                if (in == end)
-                {
-                    err = ios_base::eofbit;
-                    return in;
-                }
-
-                if ((base.flags() & ios_base::boolalpha) == 0)
-                {
-                    int8_t tmp{};
-                    in = get_integral_<int64_t>(in, end, base, err, tmp);
-
-                    if (tmp == 0)
-                        v = false;
-                    else if (tmp == 1)
-                        v = true;
-                    else
-                    {
-                        v = true;
-                        err = ios_base::failbit;
-                    }
-                }
-                else
-                {
-                    /**
-                     * We track both truename() and falsename()
-                     * at the same time, once either is matched
-                     * or the input is too big without a match
-                     * or the input ends the conversion ends
-                     * and the result is deduced.
-                     */
-
-                    auto loc = base.getloc();
-                    const auto& nt = use_facet<numpunct<char_type>>(loc);
-
-                    auto true_target = nt.truename();
-                    auto false_target = nt.falsename();
-
-                    if (true_target == "" || false_target == "")
-                    {
-                        v = (err == ios_base::failbit);
-                        return in;
-                    }
-
-                    auto true_str = true_target;
-                    auto false_str = false_target;
-
-                    size_t i{};
-                    while (true)
-                    {
-                        if (true_str.size() <= i && false_str.size() <= i)
-                            break;
-                        auto c = *in++;
-
-                        if (i < true_str.size())
-                            true_str[i] = c;
-                        if (i < false_str.size())
-                            false_str[i] = c;
-                        ++i;
-
-                        if (in == end || *in == '\n')
-                        {
-                            err = ios_base::eofbit;
-                            break;
-                        }
-                    }
-
-                    if (i == true_str.size() && true_str == true_target)
-                    {
-                        v = true;
-
-                        if (++in == end)
-                            err = ios_base::eofbit;
-                        else
-                            err = ios_base::goodbit;
-                    }
-                    else if (i == false_str.size() && false_str == false_target)
-                    {
-                        v = false;
-
-                        if (in == end)
-                            err = (ios_base::failbit | ios_base::eofbit);
-                        else
-                            err = ios_base::failbit;
-                    }
-                    else
-                        err = ios_base::failbit;
-                }
-
-                return in;
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, long& v) const
-            {
-                return get_integral_<int64_t>(in, end, base, err, v);
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, long long& v) const
-            {
-                return get_integral_<int64_t>(in, end, base, err, v);
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, unsigned short& v) const
-            {
-                return get_integral_<uint64_t>(in, end, base, err, v);
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, unsigned int& v) const
-            {
-                return get_integral_<uint64_t>(in, end, base, err, v);
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, unsigned long& v) const
-            {
-                return get_integral_<uint64_t>(in, end, base, err, v);
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, unsigned long long& v) const
-            {
-                return get_integral_<uint64_t>(in, end, base, err, v);
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, float& v) const
-            {
-                // TODO: implement
-                return in;
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, double& v) const
-            {
-                // TODO: implement
-                return in;
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, long double& v) const
-            {
-                // TODO: implement
-                return in;
-            }
-
-            iter_type do_get(iter_type in, iter_type end, ios_base& base,
-                             ios_base::iostate& err, void*& v) const
-            {
-                // TODO: implement
-                return in;
-            }
-
-        private:
-            template<class BaseType, class T>
-            iter_type get_integral_(iter_type in, iter_type end, ios_base& base,
-                                    ios_base::iostate& err, T& v) const
-            {
-                BaseType res{};
-                unsigned int num_base{10};
-
-                auto basefield = (base.flags() & ios_base::basefield);
-                if (basefield == ios_base::oct)
-                    num_base = 8;
-                else if (basefield == ios_base::hex)
-                    num_base = 16;
-
-                auto size = fill_buffer_integral_(in, end, base);
-                if (size > 0)
-                {
-                    int ret{};
-                    if constexpr (is_signed<BaseType>::value)
-                        ret = std::hel::str_int64_t(base.buffer_, nullptr, num_base, false, &res);
-                    else
-                        ret = std::hel::str_uint64_t(base.buffer_, nullptr, num_base, false, &res);
-
-                    if (ret != EOK)
-                    {
-                        err |= ios_base::failbit;
-                        v = 0;
-                    }
-                    else if (res > static_cast<BaseType>(numeric_limits<T>::max()))
-                    {
-                        err |= ios_base::failbit;
-                        v = numeric_limits<T>::max();
-                    }
-                    else if (res < static_cast<BaseType>(numeric_limits<T>::min()))
-                    {
-                        err |= ios_base::failbit;
-                        v = numeric_limits<T>::min();
-                    }
-                    else
-                        v = static_cast<T>(res);
-                }
-                else
-                {
-                    err |= ios_base::failbit;
-                    v = 0;
-                }
-
-                return in;
-            }
-
-            size_t fill_buffer_integral_(iter_type& in, iter_type end, ios_base& base) const
-            {
-                if (in == end)
-                    return 0;
-
-                auto loc = base.getloc();
-                const auto& ct = use_facet<ctype<char_type>>(loc);
-                auto hex = ((base.flags() & ios_base::hex) != 0);
-
-                size_t i{};
-                if (*in == '+' || *in == '-')
-                    base.buffer_[i++] = *in++;
-
-                while (in != end && i < ios_base::buffer_size_ - 1)
-                {
-                    auto c = *in;
-                    if (ct.is(ctype_base::digit, c) || (hex &&
-                       ((c >= ct.widen('A') && c <= ct.widen('F')) ||
-                        (c >= ct.widen('a') && c <= ct.widen('f')))))
-                    {
-                        ++in;
-                        base.buffer_[i++] = c;
-                    }
-                    else
-                        break;
-                }
-                base.buffer_[i] = char_type{};
-
-                return i;
-            }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/locale/num_put.hpp
===================================================================
--- uspace/lib/cpp/include/internal/locale/num_put.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,313 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_LOCALE_NUM_PUT
-#define LIBCPP_INTERNAL_LOCALE_NUM_PUT
-
-#include <internal/locale.hpp>
-#include <internal/locale/numpunct.hpp>
-#include <ios>
-#include <iterator>
-
-namespace std
-{
-    /**
-     * 22.4.2.2, class template num_put:
-     */
-
-    template<class Char, class OutputIterator = ostreambuf_iterator<Char>>
-    class num_put: public locale::facet
-    {
-        public:
-            using char_type = Char;
-            using iter_type = OutputIterator;
-
-            explicit num_put(size_t refs = 0)
-            { /* DUMMY BODY */ }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, bool v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, long v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, long long v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, unsigned long v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, unsigned long long v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, double v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, long double v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            iter_type put(iter_type it, ios_base& base, char_type fill, const void* v) const
-            {
-                return do_put(it, base, fill, v);
-            }
-
-            ~num_put()
-            { /* DUMMY BODY */ }
-
-        protected:
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, bool v) const
-            {
-                auto loc = base.getloc();
-
-                if ((base.flags() & ios_base::boolalpha) == 0)
-                    return do_put(it, base, fill, (long)v);
-                else
-                {
-                    auto s = v ? use_facet<numpunct<char_type>>(loc).truename()
-                               : use_facet<numpunct<char_type>>(loc).falsename();
-                    for (auto c: s)
-                        *it++ = c;
-                }
-
-                return it;
-            }
-
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, long v) const
-            {
-                auto basefield = (base.flags() & ios_base::basefield);
-                auto uppercase = (base.flags() & ios_base::uppercase);
-
-                int ret{};
-                if (basefield == ios_base::oct)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lo", v);
-                else if ((basefield == ios_base::hex) && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lx", v);
-                else if (basefield == ios_base::hex)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lX", v);
-                else
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%ld", v);
-
-                return put_adjusted_buffer_(it, base, fill, ret);
-            }
-
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, long long v) const
-            {
-                auto basefield = (base.flags() & ios_base::basefield);
-                auto uppercase = (base.flags() & ios_base::uppercase);
-
-                int ret{};
-                if (basefield == ios_base::oct)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llo", v);
-                else if ((basefield == ios_base::hex) && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llx", v);
-                else if (basefield == ios_base::hex)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llX", v);
-                else
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lld", v);
-
-                return put_adjusted_buffer_(it, base, fill, ret);
-            }
-
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, unsigned long v) const
-            {
-                auto basefield = (base.flags() & ios_base::basefield);
-                auto uppercase = (base.flags() & ios_base::uppercase);
-
-                int ret{};
-                if (basefield == ios_base::oct)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lo", v);
-                else if ((basefield == ios_base::hex) && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lx", v);
-                else if (basefield == ios_base::hex)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lX", v);
-                else
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%lu", v);
-
-                return put_adjusted_buffer_(it, base, fill, ret);
-            }
-
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, unsigned long long v) const
-            {
-                auto basefield = (base.flags() & ios_base::basefield);
-                auto uppercase = (base.flags() & ios_base::uppercase);
-
-                // TODO: showbase
-                int ret{};
-                if (basefield == ios_base::oct)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llo", v);
-                else if ((basefield == ios_base::hex) && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llx", v);
-                else if (basefield == ios_base::hex)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llX", v);
-                else
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%llu", v);
-
-                return put_adjusted_buffer_(it, base, fill, ret);
-            }
-
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, double v) const
-            {
-                auto floatfield = (base.flags() & ios_base::floatfield);
-                auto uppercase = (base.flags() & ios_base::uppercase);
-
-                // TODO: showbase
-                // TODO: precision
-                int ret{};
-                if (floatfield == ios_base::fixed)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%f", v);
-                else if (floatfield == ios_base::scientific && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%e", v);
-                else if (floatfield == ios_base::scientific)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%E", v);
-                else if (floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%a", v);
-                else if (floatfield == (ios_base::fixed | ios_base::scientific))
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%A", v);
-                else if (!uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%g", v);
-                else
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%G", v);
-
-                return put_adjusted_buffer_(it, base, fill, ret);
-            }
-
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, long double v) const
-            {
-                /**
-                 * Note: Long double is not support at the moment in snprintf.
-                 */
-                auto floatfield = (base.flags() & ios_base::floatfield);
-                auto uppercase = (base.flags() & ios_base::uppercase);
-
-                // TODO: showbase
-                // TODO: precision
-                int ret{};
-                if (floatfield == ios_base::fixed)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%Lf", v);
-                else if (floatfield == ios_base::scientific && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%Le", v);
-                else if (floatfield == ios_base::scientific)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%LE", v);
-                else if (floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%La", v);
-                else if (floatfield == (ios_base::fixed | ios_base::scientific))
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%LA", v);
-                else if (!uppercase)
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%Lg", v);
-                else
-                    ret = snprintf(base.buffer_, ios_base::buffer_size_, "%LG", v);
-
-                return put_adjusted_buffer_(it, base, fill, ret);
-            }
-
-            iter_type do_put(iter_type it, ios_base& base, char_type fill, const void* v) const
-            {
-                int ret = snprintf(base.buffer_, ios_base::buffer_size_, "%p", v);
-
-                return put_adjusted_buffer_(it, base, fill, ret);
-            }
-
-        private:
-            iter_type put_adjusted_buffer_(iter_type it, ios_base& base, char_type fill, size_t size) const
-            {
-                auto adjustfield = (base.flags() & ios_base::adjustfield);
-
-                size_t to_fill{};
-                size_t width = static_cast<size_t>(base.width());
-
-                if (base.width() > 0 && size < width)
-                    to_fill = width - size;
-
-                if (to_fill > 0)
-                {
-                    if (adjustfield == ios_base::left)
-                    {
-                        it = put_buffer_(it, base, fill, 0, size);
-                        for (size_t i = 0; i < to_fill; ++i)
-                            *it++ = fill;
-                    }
-                    else if (adjustfield == ios_base::right)
-                    {
-                        for (size_t i = 0; i < to_fill; ++i)
-                            *it++ = fill;
-                        it = put_buffer_(it, base, fill, 0, size);
-                    }
-                    else if (adjustfield == ios_base::internal)
-                    {
-                        // TODO: pad after - or 0x/0X
-                    }
-                    else
-                    {
-                        for (size_t i = 0; i < to_fill; ++i)
-                            *it++ = fill;
-                        it = put_buffer_(it, base, fill, 0, size);
-                    }
-                }
-                else
-                    it = put_buffer_(it, base, fill, 0, size);
-                base.width(0);
-
-                return it;
-            }
-
-            iter_type put_buffer_(iter_type it, ios_base& base, char_type fill, size_t start, size_t size) const
-            {
-                const auto& loc = base.getloc();
-                const auto& ct = use_facet<ctype<char_type>>(loc);
-                const auto& punct = use_facet<numpunct<char_type>>(loc);
-
-                for (size_t i = start; i < size; ++i)
-                {
-                    if (base.buffer_[i] == '.')
-                        *it++ = punct.decimal_point();
-                    else
-                        *it++ = ct.widen(base.buffer_[i]);
-                    // TODO: Should do grouping & thousands_sep, but that's a low
-                    //       priority for now.
-                }
-
-                return it;
-            }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/locale/numpunct.hpp
===================================================================
--- uspace/lib/cpp/include/internal/locale/numpunct.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,214 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_LOCALE_NUMPUNCT
-#define LIBCPP_INTERNAL_LOCALE_NUMPUNCT
-
-#include <internal/locale.hpp>
-#include <string>
-
-namespace std
-{
-    /**
-     * 22.4.3.1, class template numpunct:
-     */
-
-    template<class Char>
-    class numpunct: public locale::facet
-    {
-        public:
-            using char_type   = Char;
-            using string_type = basic_string<Char>;
-
-            explicit numpunct(size_t refs = 0);
-
-            char_type decimal_point() const
-            {
-                return do_decimal_point();
-            }
-
-            char_type thousands_sep() const
-            {
-                return do_thousands_sep();
-            }
-
-            string_type grouping() const
-            {
-                return do_grouping();
-            }
-
-            string_type truename() const
-            {
-                return do_truename();
-            }
-
-            string_type falsename() const
-            {
-                return do_falsename();
-            }
-
-            ~numpunct();
-
-        protected:
-            char_type do_decimal_point() const;
-            char_type do_thousands_sep() const;
-            string_type do_grouping() const;
-            string_type do_truename() const;
-            string_type do_falsename() const;
-    };
-
-    template<>
-    class numpunct<char>: public locale::facet
-    {
-        public:
-            using char_type   = char;
-            using string_type = basic_string<char>;
-
-            explicit numpunct(size_t refs = 0)
-            { /* DUMMY BODY */ }
-
-            char_type decimal_point() const
-            {
-                return do_decimal_point();
-            }
-
-            char_type thousands_sep() const
-            {
-                return do_thousands_sep();
-            }
-
-            string_type grouping() const
-            {
-                return do_grouping();
-            }
-
-            string_type truename() const
-            {
-                return do_truename();
-            }
-
-            string_type falsename() const
-            {
-                return do_falsename();
-            }
-
-            ~numpunct()
-            { /* DUMMY BODY */ }
-
-        protected:
-            char_type do_decimal_point() const
-            {
-                return '.';
-            }
-
-            char_type do_thousands_sep() const
-            {
-                return ',';
-            }
-
-            string_type do_grouping() const
-            {
-                return "";
-            }
-
-            string_type do_truename() const
-            {
-                return "true";
-            }
-
-            string_type do_falsename() const
-            {
-                return "false";
-            }
-    };
-
-    template<>
-    class numpunct<wchar_t>: public locale::facet
-    {
-        public:
-            using char_type   = wchar_t;
-            using string_type = basic_string<wchar_t>;
-
-            explicit numpunct(size_t refs = 0);
-
-            char_type decimal_point() const
-            {
-                return do_decimal_point();
-            }
-
-            char_type thousands_sep() const
-            {
-                return do_thousands_sep();
-            }
-
-            string_type grouping() const
-            {
-                return do_grouping();
-            }
-
-            string_type truename() const
-            {
-                return do_truename();
-            }
-
-            string_type falsename() const
-            {
-                return do_falsename();
-            }
-
-            ~numpunct();
-
-        protected:
-            char_type do_decimal_point() const
-            {
-                return L'.';
-            }
-
-            char_type do_thousands_sep() const
-            {
-                return L',';
-            }
-
-            string_type do_grouping() const
-            {
-                return L"";
-            }
-
-            string_type do_truename() const
-            {
-                return L"true";
-            }
-
-            string_type do_falsename() const
-            {
-                return L"false";
-            }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/addressof.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/addressof.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_ADDRESSOF
-#define LIBCPP_INTERNAL_MEMORY_ADDRESSOF
-
-namespace std
-{
-    /**
-     * 20.7.12, specialized algorithms:
-     */
-
-    template<class T>
-    T* addressof(T& x) noexcept
-    {
-        return reinterpret_cast<T*>(
-            &const_cast<char&>(
-                reinterpret_cast<const volatile char&>(x)
-        ));
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/allocator_arg.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/allocator_arg.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_ALLOCATOR_ARG
-#define LIBCPP_INTERNAL_MEMORY_ALLOCATOR_ARG
-
-namespace std
-{
-    /**
-     * 20.7.6, allocator argument tag:
-     */
-
-    struct allocator_arg_t
-    { /* DUMMY BODY */ };
-
-    constexpr allocator_arg_t allocator_arg{};
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/allocator_traits.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/allocator_traits.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,255 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_ALLOCATOR_TRAITS
-#define LIBCPP_INTERNAL_MEMORY_ALLOCATOR_TRAITS
-
-#include <cstddef>
-#include <internal/aux.hpp>
-#include <internal/memory/addressof.hpp>
-#include <internal/memory/pointer_traits.hpp>
-#include <internal/memory/type_getters.hpp>
-#include <limits>
-#include <type_traits>
-
-namespace std
-{
-    /**
-     * 20.7.7, uses_allocator:
-     */
-
-    namespace aux
-    {
-        template<class T, class = void>
-        struct has_allocator_type: false_type
-        { /* DUMMY BODY */ };
-
-        template<class T>
-        struct has_allocator_type<T, void_t<typename T::allocator_type>>
-            : true_type
-        { /* DUMMY BODY */ };
-    }
-
-    template<class T, class Alloc>
-    struct uses_allocator
-        : aux::value_is<
-        bool, aux::has_allocator_type<T>::value && is_convertible_v<
-            Alloc, typename T::allocator_type
-        >
-    >
-    { /* DUMMY BODY */ };
-
-    /**
-     * 20.7.8, allocator traits:
-     */
-
-    template<class Alloc>
-    struct allocator_traits
-    {
-        using allocator_type = Alloc;
-
-        using value_type         = typename Alloc::value_type;
-        using pointer            = typename aux::alloc_get_pointer<Alloc>::type;
-        using const_pointer      = typename aux::alloc_get_const_pointer<Alloc, pointer>::type;
-        using void_pointer       = typename aux::alloc_get_void_pointer<Alloc, pointer>::type;
-        using const_void_pointer = typename aux::alloc_get_const_void_pointer<Alloc, pointer>::type;
-        using difference_type    = typename aux::alloc_get_difference_type<Alloc, pointer>::type;
-        using size_type          = typename aux::alloc_get_size_type<Alloc, difference_type>::type;
-
-        using propagate_on_container_copy_assignment = typename aux::alloc_get_copy_propagate<Alloc>::type;
-        using propagate_on_container_move_assignment = typename aux::alloc_get_move_propagate<Alloc>::type;
-        using propagate_on_container_swap            = typename aux::alloc_get_swap_propagate<Alloc>::type;
-        using is_always_equal                        = typename aux::alloc_get_always_equal<Alloc>::type;
-
-        template<class T>
-        using rebind_alloc = typename aux::alloc_get_rebind_alloc<Alloc, T>;
-
-        template<class T>
-        using rebind_traits = allocator_traits<rebind_alloc<T>>;
-
-        static pointer allocate(Alloc& alloc, size_type n)
-        {
-            return alloc.allocate(n);
-        }
-
-        static pointer allocate(Alloc& alloc, size_type n, const_void_pointer hint)
-        {
-            if constexpr (aux::alloc_has_hint_allocate<Alloc, size_type, const_void_pointer>::value)
-                return alloc.allocate(n, hint);
-            else
-                return alloc.allocate(n);
-        }
-
-        static void deallocate(Alloc& alloc, pointer ptr, size_type n)
-        {
-            alloc.deallocate(ptr, n);
-        }
-
-        template<class T, class... Args>
-        static void construct(Alloc& alloc, T* ptr, Args&&... args)
-        {
-            if constexpr (aux::alloc_has_construct<Alloc, T, Args...>::value)
-                alloc.construct(ptr, forward<Args>(args)...);
-            else
-                ::new(static_cast<void*>(ptr)) T(forward<Args>(args)...);
-        }
-
-        template<class T>
-        static void destroy(Alloc& alloc, T* ptr)
-        {
-            if constexpr (aux::alloc_has_destroy<Alloc, T>::value)
-                alloc.destroy(ptr);
-            else
-                ptr->~T();
-        }
-
-        static size_type max_size(const Alloc& alloc) noexcept
-        {
-            if constexpr (aux::alloc_has_max_size<Alloc>::value)
-                return alloc.max_size();
-            else
-                return numeric_limits<size_type>::max();
-        }
-
-        static Alloc select_on_container_copy_construction(const Alloc& alloc)
-        {
-            if constexpr (aux::alloc_has_select<Alloc>::value)
-                return alloc.select_on_container_copy_construction();
-            else
-                return alloc;
-        }
-    };
-
-    /**
-     * 20.7.9, the default allocator
-     */
-
-    template<class T>
-    class allocator;
-
-    template<>
-    class allocator<void>
-    {
-        public:
-            using pointer       = void*;
-            using const_pointer = const void*;
-            using value_type    = void;
-
-            template<class U>
-            struct rebind
-            {
-                using other = allocator<U>;
-            };
-    };
-
-    template<class T>
-    T* addressof(T& x) noexcept;
-
-    template<class T>
-    class allocator
-    {
-        public:
-            using size_type       = size_t;
-            using difference_type = ptrdiff_t;
-            using pointer         = T*;
-            using const_pointer   = const T*;
-            using reference       = T&;
-            using const_reference = const T&;
-            using value_type      = T;
-
-            template<class U>
-            struct rebind
-            {
-                using other = allocator<U>;
-            };
-
-            using propagate_on_container_move_assignment = true_type;
-            using is_always_equal                        = true_type;
-
-            allocator() noexcept = default;
-
-            allocator(const allocator&) noexcept = default;
-
-            template<class U>
-            allocator(const allocator<U>&) noexcept
-            { /* DUMMY BODY */ }
-
-            ~allocator() = default;
-
-            pointer address(reference x) const noexcept
-            {
-                return addressof(x);
-            }
-
-            const_pointer address(const_reference x) const noexcept
-            {
-                return addressof(x);
-            }
-
-            pointer allocate(size_type n, allocator<void>::const_pointer = 0)
-            {
-                return static_cast<pointer>(::operator new(n * sizeof(value_type)));
-            }
-
-            void deallocate(pointer ptr, size_type n)
-            {
-                ::operator delete(ptr, n);
-            }
-
-            size_type max_size() const noexcept
-            {
-                return numeric_limits<size_type>::max();
-            }
-
-            template<class U, class... Args>
-            void construct(U* ptr, Args&&... args)
-            {
-                ::new((void*)ptr) U(forward<Args>(args)...);
-            }
-
-            template<class U>
-            void destroy(U* ptr)
-            {
-                ptr->~U();
-            }
-    };
-
-    template<class T1, class T2>
-    bool operator==(const allocator<T1>&, const allocator<T2>&) noexcept
-    {
-        return true;
-    }
-
-    template<class T1, class T2>
-    bool operator!=(const allocator<T1>&, const allocator<T2>&) noexcept
-    {
-        return false;
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/misc.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/misc.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,158 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_MISC
-#define LIBCPP_INTERNAL_MEMORY_MISC
-
-#include <cstdlib>
-#include <iterator>
-#include <new>
-#include <utility>
-
-namespace std
-{
-    /**
-     * 20.7.10, raw storage iterator:
-     */
-
-    template<class OutputIterator, class T>
-    class raw_storage_iterator: public iterator<output_iterator_tag, void, void, void, void>
-    {
-        public:
-            explicit raw_storage_iterator(OutputIterator it)
-                : it_{it}
-            { /* DUMMY BODY */ }
-
-            raw_storage_iterator& operator*()
-            {
-                return *this;
-            }
-
-            raw_storage_iterator& operator=(const T& element)
-            {
-                new(it_) T{element};
-
-                return *this;
-            }
-
-            raw_storage_iterator& operator++()
-            {
-                ++it_;
-
-                return *this;
-            }
-
-            raw_storage_iterator operator++(int)
-            {
-                return raw_storage_iterator{it_++};
-            }
-
-        private:
-            OutputIterator it_;
-    };
-
-    /**
-     * 20.7.11, temporary buffers:
-     */
-
-    template<class T>
-    pair<T*, ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept
-    {
-        T* res{};
-
-        while (n > 0)
-        {
-            res = (T*)malloc(n * sizeof(T));
-
-            if (res)
-                return make_pair(res, n);
-
-            --n;
-        }
-
-        return make_pair(nullptr, ptrdiff_t{});
-    }
-
-    template<class T>
-    void return_temporary_buffer(T* ptr)
-    {
-        free(ptr);
-    }
-
-    /**
-     * 20.7.12, specialized algorithms:
-     */
-
-    template<class Iterator>
-    struct iterator_traits;
-
-    template<class InputIterator, class ForwardIterator>
-    ForwardIterator unitialized_copy(
-        InputIterator first, InputIterator last,
-        ForwardIterator result
-    )
-    {
-        for (; first != last; ++first, ++result)
-            ::new (static_cast<void*>(&*result)) typename iterator_traits<ForwardIterator>::value_type(*first);
-
-        return result;
-    }
-
-    template<class InputIterator, class Size, class ForwardIterator>
-    ForwardIterator unitialized_copy_n(
-        InputIterator first, Size n, ForwardIterator result
-    )
-    {
-        for (; n > 0; ++first, --n, ++result)
-            ::new (static_cast<void*>(&*result)) typename iterator_traits<ForwardIterator>::value_type(*first);
-
-        return result;
-    }
-
-    template<class ForwardIterator, class T>
-    void unitialized_fill(
-        ForwardIterator first, ForwardIterator last, const T& x
-    )
-    {
-        for (; first != last; ++first)
-            ::new (static_cast<void*>(&*first)) typename iterator_traits<ForwardIterator>::value_type(x);
-    }
-
-    template<class ForwardIterator, class Size, class T>
-    ForwardIterator unitialized_fill_n(
-        ForwardIterator first, Size n, const T& x
-    )
-    {
-        for (; n > 0; ++first, --n)
-            ::new (static_cast<void*>(&*first)) typename iterator_traits<ForwardIterator>::value_type(x);
-
-        return first;
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/owner_less.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/owner_less.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,91 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_OWNER_LESS
-#define LIBCPP_INTERNAL_MEMORY_OWNER_LESS
-
-#include <internal/memory/shared_ptr.hpp>
-#include <internal/memory/weak_ptr.hpp>
-
-namespace std
-{
-    /**
-     * 20.8.2.4, class template owner_less:
-     */
-
-    template<class>
-    struct owner_less;
-
-    template<class T>
-    struct owner_less<shared_ptr<T>>
-    {
-        using retult_type          = bool;
-        using first_argument_type  = shared_ptr<T>;
-        using second_argument_type = shared_ptr<T>;
-
-        bool operator()(const shared_ptr<T>& lhs, const shared_ptr<T>& rhs) const
-        {
-            return lhs.owner_before(rhs);
-        }
-
-        bool operator()(const shared_ptr<T>& lhs, const weak_ptr<T>& rhs) const
-        {
-            return lhs.owner_before(rhs);
-        }
-
-        bool operator()(const weak_ptr<T>& lhs, const shared_ptr<T>& rhs) const
-        {
-            return lhs.owner_before(rhs);
-        }
-    };
-
-    template<class T>
-    struct owner_less<weak_ptr<T>>
-    {
-        using retult_type          = bool;
-        using first_argument_type  = weak_ptr<T>;
-        using second_argument_type = weak_ptr<T>;
-
-        bool operator()(const weak_ptr<T>& lhs, const weak_ptr<T>& rhs) const
-        {
-            return lhs.owner_before(rhs);
-        }
-
-        bool operator()(const shared_ptr<T>& lhs, const weak_ptr<T>& rhs) const
-        {
-            return lhs.owner_before(rhs);
-        }
-
-        bool operator()(const weak_ptr<T>& lhs, const shared_ptr<T>& rhs) const
-        {
-            return lhs.owner_before(rhs);
-        }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/pointer_traits.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/pointer_traits.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_POINTER_TRAITS
-#define LIBCPP_INTERNAL_MEMORY_POINTER_TRAITS
-
-#include <cstddef>
-#include <internal/memory/addressof.hpp>
-#include <internal/memory/type_getters.hpp>
-#include <type_traits>
-
-namespace std
-{
-    /**
-     * 20.7.3, pointer traits:
-     */
-
-    template<class Ptr>
-    struct pointer_traits
-    {
-        using pointer         = Ptr;
-        using element_type    = typename aux::ptr_get_element_type<Ptr>::type;
-        using difference_type = typename aux::ptr_get_difference_type<Ptr>::type;
-
-        template<class U>
-        using rebind = typename aux::ptr_get_rebind<Ptr, U>::type;
-
-        static pointer pointer_to( // If is_void_t<element_type>, this type is unspecified.
-            conditional_t<is_void_v<element_type>, char, element_type&> x
-        )
-        {
-            return Ptr::pointer_to(x);
-        }
-    };
-
-    template<class T>
-    struct pointer_traits<T*>
-    {
-        using pointer         = T*;
-        using element_type    = T;
-        using difference_type = ptrdiff_t;
-
-        template<class U>
-        using rebind = U*;
-
-        static pointer pointer_to(
-            conditional_t<is_void_v<element_type>, char, element_type&> x
-        )
-        {
-            return std::addressof(x);
-        }
-    };
-
-    /**
-     * 20.7.4, pointer safety:
-     */
-
-    // TODO: implement
-
-    /**
-     * 20.7.5, align:
-     */
-
-    // TODO: implement
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/shared_payload.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/shared_payload.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,223 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_SHARED_PAYLOAD
-#define LIBCPP_INTERNAL_MEMORY_SHARED_PAYLOAD
-
-#include <cinttypes>
-#include <utility>
-
-namespace std
-{
-    template<class>
-    struct default_delete;
-
-    struct allocator_arg_t;
-}
-
-namespace std::aux
-{
-    /**
-     * At the moment we do not have atomics, change this
-     * to std::atomic<long> once we do.
-     */
-    using refcount_t = long;
-
-    /**
-     * This allows us to construct shared_ptr from
-     * a payload pointer in make_shared etc.
-     */
-    struct payload_tag_t
-    { /* DUMMY BODY */ };
-
-    inline constexpr payload_tag_t payload_tag{};
-
-    template<class D, class T>
-    void use_payload_deleter(D* deleter, T* data)
-    {
-        if (deleter)
-            (*deleter)(data);
-    }
-
-    template<class T>
-    class shared_payload_base
-    {
-        public:
-            virtual void destroy() = 0;
-            virtual T* get() const noexcept = 0;
-
-            virtual uint8_t* deleter() const noexcept = 0;
-
-            virtual void increment() noexcept = 0;
-            virtual void increment_weak() noexcept = 0;
-            virtual bool decrement() noexcept = 0;
-            virtual bool decrement_weak() noexcept = 0;
-            virtual refcount_t refs() const noexcept = 0;
-            virtual refcount_t weak_refs() const noexcept = 0;
-            virtual bool expired() const noexcept = 0;
-            virtual shared_payload_base* lock() noexcept = 0;
-
-            virtual ~shared_payload_base() = default;
-    };
-
-    template<class T, class D = default_delete<T>>
-    class shared_payload: public shared_payload_base<T>
-    {
-        public:
-            shared_payload(T* ptr, D deleter = D{})
-                : data_{ptr}, deleter_{deleter},
-                  refcount_{1}, weak_refcount_{1}
-            { /* DUMMY BODY */ }
-
-            template<class... Args>
-            shared_payload(Args&&... args)
-                : data_{new T{forward<Args>(args)...}},
-                  deleter_{}, refcount_{1}, weak_refcount_{1}
-            { /* DUMMY BODY */ }
-
-            template<class Alloc, class... Args>
-            shared_payload(allocator_arg_t, Alloc alloc, Args&&... args)
-                : data_{alloc.allocate(1)},
-                  deleter_{}, refcount_{1}, weak_refcount_{1}
-            {
-                alloc.construct(data_, forward<Args>(args)...);
-            }
-
-            template<class Alloc, class... Args>
-            shared_payload(D deleter, Alloc alloc, Args&&... args)
-                : data_{alloc.allocate(1)},
-                  deleter_{deleter}, refcount_{1}, weak_refcount_{1}
-            {
-                alloc.construct(data_, forward<Args>(args)...);
-            }
-
-            void destroy() override
-            {
-                if (refs() == 0)
-                {
-                    if (data_)
-                    {
-                        deleter_(data_);
-                        data_ = nullptr;
-                    }
-
-                    if (weak_refs() == 0)
-                        delete this;
-                }
-            }
-
-            T* get() const noexcept override
-            {
-                return data_;
-            }
-
-            uint8_t* deleter() const noexcept override
-            {
-                return (uint8_t*)&deleter_;
-            }
-
-            void increment() noexcept override
-            {
-                __atomic_add_fetch(&refcount_, 1, __ATOMIC_ACQ_REL);
-            }
-
-            void increment_weak() noexcept override
-            {
-                __atomic_add_fetch(&weak_refcount_, 1, __ATOMIC_ACQ_REL);
-            }
-
-            bool decrement() noexcept override
-            {
-                if (__atomic_sub_fetch(&refcount_, 1, __ATOMIC_ACQ_REL) == 0)
-                {
-                    /**
-                     * First call to destroy() will delete the held object,
-                     * so it doesn't matter what the weak_refcount_ is,
-                     * but we added one and we need to remove it now.
-                     */
-                    decrement_weak();
-
-                    return true;
-                }
-                else
-                    return false;
-            }
-
-            bool decrement_weak() noexcept override
-            {
-                return __atomic_sub_fetch(&weak_refcount_, 1, __ATOMIC_ACQ_REL) == 0 && refs() == 0;
-            }
-
-            refcount_t refs() const noexcept override
-            {
-                return __atomic_load_n(&refcount_, __ATOMIC_RELAXED);
-            }
-
-            refcount_t weak_refs() const noexcept override
-            {
-                return __atomic_load_n(&weak_refcount_, __ATOMIC_RELAXED);
-            }
-
-            bool expired() const noexcept override
-            {
-                return refs() == 0;
-            }
-
-            shared_payload_base<T>* lock() noexcept override
-            {
-                refcount_t rfs = refs();
-                while (rfs != 0L)
-                {
-                    if (__atomic_compare_exchange_n(&refcount_, &rfs, rfs + 1,
-                                                    true, __ATOMIC_RELAXED,
-                                                    __ATOMIC_RELAXED))
-                    {
-                        return this;
-                    }
-                }
-
-                return nullptr;
-            }
-
-        private:
-            T* data_;
-            D deleter_;
-
-            /**
-             * We're using a trick where refcount_ > 0
-             * means weak_refcount_ has 1 added to it,
-             * this makes it easier for weak_ptrs that
-             * can't decrement the weak_refcount_ to
-             * zero with shared_ptrs using this object.
-             */
-            refcount_t refcount_;
-            refcount_t weak_refcount_;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/shared_ptr.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/shared_ptr.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,646 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_SHARED_PTR
-#define LIBCPP_INTERNAL_MEMORY_SHARED_PTR
-
-#include <exception>
-#include <internal/functional/arithmetic_operations.hpp>
-#include <internal/functional/hash.hpp>
-#include <internal/memory/allocator_arg.hpp>
-#include <internal/memory/shared_payload.hpp>
-#include <internal/memory/unique_ptr.hpp>
-#include <internal/trycatch.hpp>
-#include <type_traits>
-
-namespace std
-{
-    template<class T>
-    class weak_ptr;
-
-    /**
-     * 20.8.2.1, class bad_weak_ptr:
-     */
-
-    class bad_weak_ptr: public exception
-    {
-        public:
-            bad_weak_ptr() noexcept = default;
-
-            const char* what() const noexcept override
-            {
-                return "std::bad_weak_ptr";
-            }
-    };
-
-    /**
-     * 20.8.2.2, class template shared_ptr:
-     */
-
-    template<class T>
-    class shared_ptr
-    {
-        public:
-            using element_type = T;
-
-            /**
-             * 20.8.2.2.1, constructors:
-             */
-
-            constexpr shared_ptr() noexcept
-                : payload_{}, data_{}
-            { /* DUMMY BODY */ }
-
-            template<class U>
-            explicit shared_ptr(
-                U* ptr,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            )
-                : payload_{}, data_{ptr}
-            {
-                try
-                {
-                    payload_ = new aux::shared_payload<T>{ptr};
-                }
-                catch (const bad_alloc&)
-                {
-                    delete ptr;
-
-                    throw;
-                }
-            }
-
-            template<class U, class D>
-            shared_ptr(
-                U* ptr, D deleter,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            )
-                : shared_ptr{}
-            {
-                try
-                {
-                    payload_ = new aux::shared_payload<T, D>{ptr, deleter};
-                }
-                catch (const bad_alloc&)
-                {
-                    deleter(ptr);
-
-                    throw;
-                }
-            }
-
-            template<class U, class D, class A>
-            shared_ptr(
-                U* ptr, D deleter, A,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            )
-                : shared_ptr{}
-            {
-                try
-                {
-                    payload_ = new aux::shared_payload<T, D>{ptr, deleter};
-                }
-                catch (const bad_alloc&)
-                {
-                    deleter(ptr);
-
-                    throw;
-                }
-            }
-
-            template<class D>
-            shared_ptr(nullptr_t ptr, D deleter)
-                : shared_ptr{}
-            { /* DUMMY BODY */ }
-
-            template<class D, class A>
-            shared_ptr(nullptr_t, D deleter, A)
-                : shared_ptr{}
-            { /* DUMMY BODY */ }
-
-            template<class U>
-            shared_ptr(
-                const shared_ptr<U>& other, element_type* ptr,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            )
-                : payload_{other.payload_}, data_{ptr}
-            {
-                if (payload_)
-                    payload_->increment();
-            }
-
-            shared_ptr(const shared_ptr& other)
-                : payload_{other.payload_}, data_{other.data_}
-            {
-                if (payload_)
-                    payload_->increment();
-            }
-
-            template<class U>
-            shared_ptr(
-                const shared_ptr<U>& other,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            )
-                : payload_{other.payload_}, data_{other.data_}
-            {
-                if (payload_)
-                    payload_->increment();
-            }
-
-            shared_ptr(shared_ptr&& other)
-                : payload_{move(other.payload_)}, data_{move(other.data_)}
-            {
-                other.payload_ = nullptr;
-                other.data_ = nullptr;
-            }
-
-            template<class U>
-            shared_ptr(
-                shared_ptr<U>&& other,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            )
-                : payload_{move(other.payload_)}, data_{move(other.data_)}
-            {
-                other.payload_ = nullptr;
-                other.data_ = nullptr;
-            }
-
-            template<class U>
-            explicit shared_ptr(
-                const weak_ptr<U>& other,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            )
-                : payload_{}, data_{}
-            {
-                if (other.expired())
-                    throw bad_weak_ptr{};
-
-                if (other.payload_)
-                {
-                    payload_ = other.payload_->lock();
-                    data_ = payload_->get();
-                }
-            }
-
-            template<class U, class D>
-            shared_ptr(
-                unique_ptr<U, D>&& other,
-                enable_if_t<
-                    is_convertible_v<
-                        typename unique_ptr<U, D>::pointer,
-                        element_type*
-                    >
-                >* = nullptr
-            ) // TODO: if D is a reference type, it should be ref(other.get_deleter())
-                : shared_ptr{other.release(), other.get_deleter()}
-            { /* DUMMY BODY */ }
-
-            constexpr shared_ptr(nullptr_t) noexcept
-                : shared_ptr{}
-            { /* DUMMY BODY */ }
-
-            /**
-             * 20.8.2.2.2, destructor:
-             */
-
-            ~shared_ptr()
-            {
-                remove_payload_();
-            }
-
-            /**
-             * 20.8.2.2.3, assignment:
-             */
-
-            shared_ptr& operator=(const shared_ptr& rhs) noexcept
-            {
-                if (rhs.payload_)
-                    rhs.payload_->increment();
-
-                remove_payload_();
-
-                payload_ = rhs.payload_;
-                data_ = rhs.data_;
-
-                return *this;
-            }
-
-            template<class U>
-            enable_if_t<is_convertible_v<U*, element_type*>, shared_ptr>&
-            operator=(const shared_ptr<U>& rhs) noexcept
-            {
-                if (rhs.payload_)
-                    rhs.payload_->increment();
-
-                remove_payload_();
-
-                payload_ = rhs.payload_;
-                data_ = rhs.data_;
-
-                return *this;
-            }
-
-            shared_ptr& operator=(shared_ptr&& rhs) noexcept
-            {
-                shared_ptr{move(rhs)}.swap(*this);
-
-                return *this;
-            }
-
-            template<class U>
-            shared_ptr& operator=(shared_ptr<U>&& rhs) noexcept
-            {
-                shared_ptr{move(rhs)}.swap(*this);
-
-                return *this;
-            }
-
-            template<class U, class D>
-            shared_ptr& operator=(unique_ptr<U, D>&& rhs)
-            {
-                shared_ptr{move(rhs)}.swap(*this);
-
-                return *this;
-            }
-
-            /**
-             * 20.8.2.2.4, modifiers:
-             */
-
-            void swap(shared_ptr& other) noexcept
-            {
-                std::swap(payload_, other.payload_);
-                std::swap(data_, other.data_);
-            }
-
-            void reset() noexcept
-            {
-                shared_ptr{}.swap(*this);
-            }
-
-            template<class U>
-            void reset(U* ptr)
-            {
-                shared_ptr{ptr}.swap(*this);
-            }
-
-            template<class U, class D>
-            void reset(U* ptr, D deleter)
-            {
-                shared_ptr{ptr, deleter}.swap(*this);
-            }
-
-            template<class U, class D, class A>
-            void reset(U* ptr, D deleter, A alloc)
-            {
-                shared_ptr{ptr, deleter, alloc}.swap(*this);
-            }
-
-            /**
-             * 20.8.2.2.5, observers:
-             */
-
-            element_type* get() const noexcept
-            {
-                return data_;
-            }
-
-            enable_if_t<!is_void_v<T>, T&> operator*() const noexcept
-            {
-                return *data_;
-            }
-
-            T* operator->() const noexcept
-            {
-                return get();
-            }
-
-            long use_count() const noexcept
-            {
-                if (payload_)
-                    return payload_->refs();
-                else
-                    return 0L;
-            }
-
-            bool unique() const noexcept
-            {
-                return use_count() == 1L;
-            }
-
-            explicit operator bool() const noexcept
-            {
-                return get() != nullptr;
-            }
-
-            template<class U>
-            bool owner_before(const shared_ptr<U>& ptr) const
-            {
-                return payload_ < ptr.payload_;
-            }
-
-            template<class U>
-            bool owner_before(const weak_ptr<U>& ptr) const
-            {
-                return payload_ < ptr.payload_;
-            }
-
-        private:
-            aux::shared_payload_base<element_type>* payload_;
-            element_type* data_;
-
-            shared_ptr(aux::payload_tag_t, aux::shared_payload_base<element_type>* payload)
-                : payload_{payload}, data_{payload->get()}
-            { /* DUMMY BODY */ }
-
-            void remove_payload_()
-            {
-                if (payload_)
-                {
-                    auto res = payload_->decrement();
-                    if (res)
-                        payload_->destroy();
-
-                    payload_ = nullptr;
-                }
-
-                if (data_)
-                    data_ = nullptr;
-            }
-
-            template<class U, class... Args>
-            friend shared_ptr<U> make_shared(Args&&...);
-
-            template<class U, class A, class... Args>
-            friend shared_ptr<U> allocate_shared(const A&, Args&&...);
-
-            template<class D, class U>
-            D* get_deleter(const shared_ptr<U>&) noexcept;
-
-            template<class U>
-            friend class weak_ptr;
-    };
-
-    /**
-     * 20.8.2.2.6, shared_ptr creation:
-     * Note: According to the standard, these two functions
-     *       should perform at most one memory allocation
-     *       (should, don't have to :P). It might be better
-     *       to create payloads that embed the type T to
-     *       perform this optimization.
-     */
-
-    template<class T, class... Args>
-    shared_ptr<T> make_shared(Args&&... args)
-    {
-        return shared_ptr<T>{
-            aux::payload_tag,
-            new aux::shared_payload<T>{forward<Args>(args)...}
-        };
-    }
-
-    template<class T, class A, class... Args>
-    shared_ptr<T> allocate_shared(const A& alloc, Args&&... args)
-    {
-        return shared_ptr<T>{
-            aux::payload_tag,
-            new aux::shared_payload<T>{allocator_arg, A{alloc}, forward<Args>(args)...}
-        };
-    }
-
-    /**
-     * 20.8.2.2.7, shared_ptr comparisons:
-     */
-
-    template<class T, class U>
-    bool operator==(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
-    {
-        return lhs.get() == rhs.get();
-    }
-
-    template<class T, class U>
-    bool operator!=(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class T, class U>
-    bool operator<(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
-    {
-        return less<common_type_t<T*, U*>>{}(lhs.get(), rhs.get());
-    }
-
-    template<class T, class U>
-    bool operator>(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
-    {
-        return rhs < lhs;
-    }
-
-    template<class T, class U>
-    bool operator<=(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
-    {
-        return !(rhs < lhs);
-    }
-
-    template<class T, class U>
-    bool operator>=(const shared_ptr<T>& lhs, const shared_ptr<U>& rhs) noexcept
-    {
-        return !(lhs < rhs);
-    }
-
-    template<class T>
-    bool operator==(const shared_ptr<T>& lhs, nullptr_t) noexcept
-    {
-        return !lhs;
-    }
-
-    template<class T>
-    bool operator==(nullptr_t, const shared_ptr<T>& rhs) noexcept
-    {
-        return !rhs;
-    }
-
-    template<class T>
-    bool operator!=(const shared_ptr<T>& lhs, nullptr_t) noexcept
-    {
-        return (bool)lhs;
-    }
-
-    template<class T>
-    bool operator!=(nullptr_t, const shared_ptr<T>& rhs) noexcept
-    {
-        return (bool)rhs;
-    }
-
-    template<class T>
-    bool operator<(const shared_ptr<T>& lhs, nullptr_t) noexcept
-    {
-        return less<T*>{}(lhs.get(), nullptr);
-    }
-
-    template<class T>
-    bool operator<(nullptr_t, const shared_ptr<T>& rhs) noexcept
-    {
-        return less<T*>{}(nullptr, rhs.get());
-    }
-
-    template<class T>
-    bool operator>(const shared_ptr<T>& lhs, nullptr_t) noexcept
-    {
-        return nullptr < lhs;
-    }
-
-    template<class T>
-    bool operator>(nullptr_t, const shared_ptr<T>& rhs) noexcept
-    {
-        return rhs < nullptr;
-    }
-
-    template<class T>
-    bool operator<=(const shared_ptr<T>& lhs, nullptr_t) noexcept
-    {
-        return !(nullptr < lhs);
-    }
-
-    template<class T>
-    bool operator<=(nullptr_t, const shared_ptr<T>& rhs) noexcept
-    {
-        return !(rhs < nullptr);
-    }
-
-    template<class T>
-    bool operator>=(const shared_ptr<T>& lhs, nullptr_t) noexcept
-    {
-        return !(lhs < nullptr);
-    }
-
-    template<class T>
-    bool operator>=(nullptr_t, const shared_ptr<T>& rhs) noexcept
-    {
-        return !(nullptr < rhs);
-    }
-
-    /**
-     * 20.8.2.2.8, shared_ptr specialized algorithms:
-     */
-
-    template<class T>
-    void swap(shared_ptr<T>& lhs, shared_ptr<T>& rhs) noexcept
-    {
-        lhs.swap(rhs);
-    }
-
-    /**
-     * 20.8.2.2.9, shared_ptr casts:
-     */
-
-    template<class T, class U>
-    shared_ptr<T> static_pointer_cast(const shared_ptr<U>& ptr) noexcept
-    {
-        if (!ptr)
-            return shared_ptr<T>{};
-
-        return shared_ptr<T>{
-            ptr, static_cast<T*>(ptr.get())
-        };
-    }
-
-    template<class T, class U>
-    shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& ptr) noexcept
-    {
-        if (auto res = dynamic_cast<T*>(ptr.get()))
-            return shared_ptr<T>{ptr, res};
-        else
-            return shared_ptr<T>{};
-    }
-
-    template<class T, class U>
-    shared_ptr<T> const_pointer_cast(const shared_ptr<U>& ptr) noexcept
-    {
-        if (!ptr)
-            return shared_ptr<T>{};
-
-        return shared_ptr<T>{
-            ptr, const_cast<T*>(ptr.get())
-        };
-    }
-
-    /**
-     * 20.8.2.2.10, shared_ptr get_deleter:
-     */
-
-    template<class D, class T>
-    D* get_deleter(const shared_ptr<T>& ptr) noexcept
-    {
-        if (ptr.payload_)
-            return static_cast<D*>(ptr.payload_->deleter());
-        else
-            return nullptr;
-    }
-
-    /**
-     * 20.8.2.2.11, shared_ptr I/O:
-     */
-
-    template<class Char, class Traits, class T>
-    basic_ostream<Char, Traits>& operator<<(basic_ostream<Char, Traits>& os,
-                                            const shared_ptr<T>& ptr)
-    {
-        return os << ptr.get();
-    }
-
-    /**
-     * 20.8.2.5, class template enable_shared_from_this:
-     */
-
-    // TODO: implement
-
-    /**
-     * 20.8.2.6, shared_ptr atomic access
-     */
-
-    // TODO: implement
-
-    /**
-     * 20.8.2.7, smart pointer hash support:
-     */
-
-    template<class T>
-    struct hash<shared_ptr<T>>
-    {
-        size_t operator()(const shared_ptr<T>& ptr) const noexcept
-        {
-            return hash<T*>{}(ptr.get());
-        }
-
-        using argument_type = shared_ptr<T>;
-        using result_type   = size_t;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/type_getters.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/type_getters.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,271 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_TYPE_GETTERS
-#define LIBCPP_INTERNAL_MEMORY_TYPE_GETTERS
-
-/**
- * Allocator and pointer traits require us to provide
- * conditional typedefs based on whether the wrapped
- * allocator contains them or not. To avoid unnecessary
- * code clutter in <memory>, we moved them to their
- * separate header (though note that these metafunctions
- * have no use outside of <memory>).
- */
-
-#include <cstddef>
-#include <internal/aux.hpp>
-#include <type_traits>
-
-namespace std
-{
-    template<class T>
-    struct pointer_traits;
-}
-
-namespace std::aux
-{
-    /**
-     * Pointer traits:
-     */
-
-    template<class Ptr, class = void>
-    struct ptr_get_element_type
-    { /* DUMMY BODY */ };
-
-    template<class Ptr>
-    struct ptr_get_element_type<Ptr, void_t<typename Ptr::element_type>>
-        : aux::type_is<typename Ptr::element_type>
-    { /* DUMMY BODY */ };
-
-    template<template <class, class...> class Ptr, class T, class... Args>
-    struct ptr_get_element_type<
-        Ptr<T, Args...>, void_t<typename Ptr<T, Args...>::element_type>
-    >: aux::type_is<typename Ptr<T, Args...>::element_type>
-    { /* DUMMY BODY */ };
-
-    template<class Ptr, class = void>
-    struct ptr_get_difference_type: aux::type_is<ptrdiff_t>
-    { /* DUMMY BODY */ };
-
-    template<class Ptr>
-    struct ptr_get_difference_type<Ptr, void_t<typename Ptr::difference_type>>
-        : aux::type_is<typename Ptr::difference_type>
-    { /* DUMMY BODY */ };
-
-    template<class Ptr, class U, class = void>
-    struct ptr_get_rebind
-    { /* DUMMY BODY */ };
-
-    template<class Ptr, class U>
-    struct ptr_get_rebind<Ptr, U, void_t<typename Ptr::template rebind<U>>>
-        : aux::type_is<typename Ptr::template rebind<U>>
-    { /* DUMMY BODY */ };
-
-    template<template <class, class...> class Ptr, class T, class... Args, class U>
-    struct ptr_get_rebind<Ptr<T, Args...>, U>
-        : aux::type_is<Ptr<U, Args...>>
-    { /* DUMMY BODY */ };
-
-    /**
-     * Allocator traits:
-     */
-
-    template<class T, class = void>
-    struct alloc_get_pointer: aux::type_is<typename T::value_type*>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct alloc_get_pointer<T, void_t<typename T::pointer>>
-        : aux::type_is<typename T::pointer>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr, class = void>
-    struct alloc_get_const_pointer
-        : aux::type_is<typename pointer_traits<Ptr>::template rebind<const typename T::value_type>>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr>
-    struct alloc_get_const_pointer<T, Ptr, void_t<typename T::const_pointer>>
-        : aux::type_is<typename T::const_pointer>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr, class = void>
-    struct alloc_get_void_pointer
-        : aux::type_is<typename pointer_traits<Ptr>::template rebind<void>>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr>
-    struct alloc_get_void_pointer<T, Ptr, void_t<typename T::void_pointer>>
-        : aux::type_is<typename T::void_pointer>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr, class = void>
-    struct alloc_get_const_void_pointer
-        : aux::type_is<typename pointer_traits<Ptr>::template rebind<const void>>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr>
-    struct alloc_get_const_void_pointer<T, Ptr, void_t<typename T::const_void_pointer>>
-        : aux::type_is<typename T::const_void_pointer>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr, class = void>
-    struct alloc_get_difference_type
-        : aux::type_is<typename pointer_traits<Ptr>::difference_type>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Ptr>
-    struct alloc_get_difference_type<T, Ptr, void_t<typename T::difference_type>>
-        : aux::type_is<typename T::difference_type>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Difference, class = void>
-    struct alloc_get_size_type: aux::type_is<make_unsigned_t<Difference>>
-    { /* DUMMY BODY */ };
-
-    template<class T, class Difference>
-    struct alloc_get_size_type<T, Difference, void_t<typename T::size_type>>
-        : aux::type_is<typename T::size_type>
-    { /* DUMMY BODY */ };
-
-    template<class T, class = void>
-    struct alloc_get_copy_propagate: aux::type_is<false_type>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct alloc_get_copy_propagate<T, void_t<typename T::propagate_on_container_copy_assignment>>
-        : aux::type_is<typename T::propagate_on_container_copy_assignment>
-    { /* DUMMY BODY */ };
-
-    template<class T, class = void>
-    struct alloc_get_move_propagate: aux::type_is<false_type>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct alloc_get_move_propagate<T, void_t<typename T::propagate_on_container_move_assignment>>
-        : aux::type_is<typename T::propagate_on_container_move_assignment>
-    { /* DUMMY BODY */ };
-
-    template<class T, class = void>
-    struct alloc_get_swap_propagate: aux::type_is<false_type>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct alloc_get_swap_propagate<T, void_t<typename T::propagate_on_container_swap>>
-        : aux::type_is<typename T::propagate_on_container_swap>
-    { /* DUMMY BODY */ };
-
-    template<class T, class = void>
-    struct alloc_get_always_equal: aux::type_is<typename is_empty<T>::type>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct alloc_get_always_equal<T, void_t<typename T::is_always_equal>>
-        : aux::type_is<typename T::is_always_equal>
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class T, class = void>
-    struct alloc_get_rebind_alloc
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class T>
-    struct alloc_get_rebind_alloc<Alloc, T, void_t<typename Alloc::template rebind<T>::other>>
-        : aux::type_is<typename Alloc::template rebind<T>::other>
-    { /* DUMMY BODY */ };
-
-    template<template <class, class...> class Alloc, class U, class... Args, class T>
-    struct alloc_get_rebind_alloc<Alloc<U, Args...>, T>
-        : aux::type_is<Alloc<T, Args...>>
-    { /* DUMMY BODY */ };
-
-    /**
-     * These metafunctions are used to check whether an expression
-     * is well-formed for the static functions of allocator_traits:
-     */
-
-    template<class Alloc, class Size, class ConstVoidPointer, class = void>
-    struct alloc_has_hint_allocate: false_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class Size, class ConstVoidPointer>
-    struct alloc_has_hint_allocate<
-        Alloc, Size, ConstVoidPointer, void_t<
-            decltype(declval<Alloc>().alloc(declval<Size>(), declval<ConstVoidPointer>()))
-        >
-    >: true_type
-    { /* DUMMY BODY */ };
-
-    template<class, class Alloc, class T, class... Args>
-    struct alloc_has_construct_impl: false_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class T, class... Args>
-    struct alloc_has_construct_impl<
-        void_t<decltype(declval<Alloc>().construct(declval<T*>(), forward<Args>(declval<Args>())...))>,
-        Alloc, T, Args...
-    >: true_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class T, class = void>
-    struct alloc_has_destroy: false_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class T>
-    struct alloc_has_destroy<Alloc, T, void_t<decltype(declval<Alloc>().destroy(declval<T>()))>>
-        : true_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class T, class... Args>
-    struct alloc_has_construct
-        : alloc_has_construct_impl<void_t<>, Alloc, T, Args...>
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class = void>
-    struct alloc_has_max_size: false_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc>
-    struct alloc_has_max_size<Alloc, void_t<decltype(declval<Alloc>().max_size())>>
-        : true_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc, class = void>
-    struct alloc_has_select: false_type
-    { /* DUMMY BODY */ };
-
-    template<class Alloc>
-    struct alloc_has_select<
-        Alloc, void_t<
-            decltype(declval<Alloc>().select_on_container_copy_construction())
-        >
-    >: true_type
-    { /* DUMMY BODY */ };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/unique_ptr.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/unique_ptr.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,649 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_UNIQUE_PTR
-#define LIBCPP_INTERNAL_MEMORY_UNIQUE_PTR
-
-#include <internal/aux.hpp>
-#include <internal/functional/hash.hpp>
-#include <type_traits>
-#include <utility>
-
-namespace std
-{
-    /**
-     * 20.8, smart pointers:
-     */
-
-    template<class T>
-    struct default_delete
-    {
-        default_delete() noexcept = default;
-
-        template<class U, class = enable_if_t<is_convertible_v<U*, T*>, void>>
-        default_delete(const default_delete<U>&) noexcept
-        { /* DUMMY BODY */ }
-
-        template<class U>
-        void operator()(U* ptr)
-        {
-            delete ptr;
-        }
-    };
-
-    template<class T>
-    struct default_delete<T[]>
-    {
-        default_delete() noexcept = default;
-
-        template<class U, class = enable_if_t<is_convertible_v<U(*)[], T(*)[]>, void>>
-        default_delete(const default_delete<U[]>&) noexcept
-        { /* DUMMY BODY */ }
-
-        template<class U, class = enable_if_t<is_convertible_v<U(*)[], T(*)[]>, void>>
-        void operator()(U* ptr)
-        {
-            delete[] ptr;
-        }
-    };
-
-    template<class T, class D = default_delete<T>>
-    class unique_ptr;
-
-    namespace aux
-    {
-        template<class P, class D, class = void>
-        struct get_unique_pointer: type_is<typename P::element_type*>
-        { /* DUMMY BODY */ };
-
-        template<class P, class D>
-        struct get_unique_pointer<P, D, void_t<typename remove_reference_t<D>::pointer>>
-            : type_is<typename remove_reference_t<D>::pointer>
-        { /* DUMMY BODY */ };
-    }
-
-    template<class T, class D>
-    class unique_ptr
-    {
-        public:
-            using element_type = T;
-            using deleter_type = D;
-            using pointer      = typename aux::get_unique_pointer<unique_ptr<T, D>, D>::type;
-
-            /**
-             * 20.8.1.2.1, constructors:
-             */
-
-            constexpr unique_ptr() noexcept
-                : ptr_{}, deleter_{}
-            { /* DUMMY BODY */ }
-
-            explicit unique_ptr(pointer ptr) noexcept
-                : ptr_{ptr}, deleter_{}
-            { /* DUMMY BODY */ }
-
-            unique_ptr(pointer ptr, /* TODO */ int d) noexcept;
-
-            unique_ptr(pointer ptr, /* TODO */ char d) noexcept;
-
-            unique_ptr(unique_ptr&& other)
-                : ptr_{move(other.ptr_)}, deleter_{forward<deleter_type>(other.deleter_)}
-            {
-                other.ptr_ = nullptr;
-            }
-
-            constexpr unique_ptr(nullptr_t)
-                : unique_ptr{}
-            { /* DUMMY BODY */ }
-
-            template<
-                class U, class E,
-                class = enable_if_t<
-                    is_convertible_v<
-                        typename unique_ptr<U, E>::pointer,
-                        pointer
-                    >, void
-                >
-            >
-            unique_ptr(unique_ptr<U, E>&& other) noexcept
-                : ptr_{move(other.ptr_)}, deleter_{forward<D>(other.deleter_)}
-            {
-                other.ptr_ = nullptr;
-            }
-
-            /**
-             * 20.8.1.2.2, destructor:
-             */
-
-            ~unique_ptr()
-            {
-                if (ptr_)
-                    deleter_(ptr_);
-            }
-
-            /**
-             * 20.8.1.2.3, assignment:
-             */
-
-            unique_ptr& operator=(unique_ptr&& rhs) noexcept
-            {
-                reset(rhs.release());
-                deleter_ = forward<deleter_type>(rhs.get_deleter());
-
-                return *this;
-            }
-
-            template<
-                class U, class E,
-                class = enable_if_t<
-                    is_convertible_v<
-                        typename unique_ptr<U, E>::pointer,
-                        pointer
-                    > && !is_array_v<U>, void
-                >
-            >
-            unique_ptr& operator=(unique_ptr<U, E>&& rhs) noexcept
-            {
-                reset(rhs.release());
-                deleter_ = forward<E>(rhs.get_deleter());
-
-                return *this;
-            }
-
-            unique_ptr& operator=(nullptr_t) noexcept
-            {
-                reset();
-
-                return *this;
-            }
-
-            /**
-             * 20.8.1.2.4, observers:
-             */
-
-            add_lvalue_reference_t<element_type> operator*() const
-            {
-                return *ptr_;
-            }
-
-            pointer operator->() const noexcept
-            {
-                return ptr_;
-            }
-
-            pointer get() const noexcept
-            {
-                return ptr_;
-            }
-
-            deleter_type& get_deleter() noexcept
-            {
-                return deleter_;
-            }
-
-            const deleter_type& get_deleter() const noexcept
-            {
-                return deleter_;
-            }
-
-            explicit operator bool() const noexcept
-            {
-                return ptr_ != nullptr;
-            }
-
-            /**
-             * 20.8.1.2.5, modifiers:
-             */
-
-            pointer release() noexcept
-            {
-                auto ret = ptr_;
-                ptr_ = nullptr;
-
-                return ret;
-            }
-
-            void reset(pointer ptr = pointer{}) noexcept
-            {
-                /**
-                 * Note: Order is significant, deleter may delete
-                 *       *this.
-                 */
-                auto old = ptr_;
-                ptr_ = ptr;
-
-                if (old)
-                    deleter_(old);
-            }
-
-            void swap(unique_ptr& other) noexcept
-            {
-                std::swap(ptr_, other.ptr_);
-                std::swap(deleter_, other.deleter_);
-            }
-
-            unique_ptr(const unique_ptr&) = delete;
-            unique_ptr& operator=(const unique_ptr&) = delete;
-
-        private:
-            pointer ptr_;
-            deleter_type deleter_;
-    };
-
-    namespace aux
-    {
-        template<class From, class To>
-        struct is_convertible_array: is_convertible<From(*)[], To(*)[]>
-        { /* DUMMY BODY */ };
-
-        template<class From, class To>
-        inline constexpr bool is_convertible_array_v = is_convertible_array<From, To>::value;
-
-        template<class T, class D, class U, class E>
-        struct compatible_ptrs: integral_constant<
-              bool,
-              is_array_v<U> && is_same_v<
-                typename unique_ptr<T, D>::pointer,
-                typename unique_ptr<T, D>::element_type*
-              > && is_same_v<
-                typename unique_ptr<U, E>::pointer,
-                typename unique_ptr<U, E>::element_type*
-              > && is_convertible_array_v<
-                typename unique_ptr<T, D>::element_type,
-                typename unique_ptr<U, E>::element_type
-              > && ((is_reference_v<D> && is_same_v<D, E>) ||
-                   (!is_reference_v<D> && is_convertible_v<E, D>))
-        >
-        { /* DUMMY BODY */ };
-
-        template<class T, class D, class U, class E>
-        inline constexpr bool compatible_ptrs_v = compatible_ptrs<T, D, U, E>::value;
-    }
-
-    template<class T, class D>
-    class unique_ptr<T[], D>
-    {
-        public:
-            using element_type = T;
-            using deleter_type = D;
-            using pointer      = typename aux::get_unique_pointer<unique_ptr<T[], D>, D>::type;
-
-            /**
-             * 20.8.1.3.1, constructors:
-             */
-
-            constexpr unique_ptr() noexcept
-                : ptr_{}, deleter_{}
-            { /* DUMMY BODY */ }
-
-            template<
-                class U,
-                class = enable_if_t<
-                    is_same_v<U, T> || aux::is_convertible_array_v<U, T>, void
-                >
-            >
-            explicit unique_ptr(U ptr) noexcept
-                : ptr_{ptr}, deleter_{}
-            { /* DUMMY BODY */ }
-
-            template<
-                class U, class E,
-                class = enable_if_t<aux::compatible_ptrs_v<T, D, U, E>, void>
-            >
-            unique_ptr(U ptr, /* TODO */ int d) noexcept;
-
-            template<
-                class U, class E,
-                class = enable_if_t<aux::compatible_ptrs_v<T, D, U, E>, void>
-            >
-            unique_ptr(U ptr, /* TODO */ char d) noexcept;
-
-            unique_ptr(unique_ptr&& other) noexcept
-                : ptr_{move(other.ptr_)}, deleter_{forward<deleter_type>(other.deleter_)}
-            {
-                other.ptr_ = nullptr;
-            }
-
-            template<
-                class U, class E,
-                class = enable_if_t<
-                    is_same_v<U, pointer> ||
-                    (is_same_v<pointer, element_type*> && is_pointer_v<U> &&
-                     aux::is_convertible_array_v<remove_pointer_t<U>, element_type>),
-                    void
-                >
-            >
-            unique_ptr(unique_ptr<U, E>&& other) noexcept
-                : ptr_{move(other.ptr_)}, deleter_{forward<D>(other.deleter_)}
-            {
-                other.ptr_ = nullptr;
-            }
-
-            constexpr unique_ptr(nullptr_t) noexcept
-                : unique_ptr{}
-            { /* DUMMY BODY */ }
-
-            ~unique_ptr()
-            {
-                if (ptr_)
-                    deleter_(ptr_);
-            }
-
-            /**
-             * 20.8.1.3.2, assignment:
-             */
-
-            unique_ptr& operator=(unique_ptr&& rhs) noexcept
-            {
-                reset(rhs.release());
-                deleter_ = forward<deleter_type>(rhs.get_deleter());
-
-                return *this;
-            }
-
-            template<
-                class U, class E,
-                class = enable_if_t<aux::compatible_ptrs_v<T, D, U, E>, void>
-            >
-            unique_ptr& operator=(unique_ptr<U, E>&& rhs) noexcept
-            {
-                reset(rhs.release());
-                deleter_ = forward<E>(rhs.get_deleter());
-
-                return *this;
-            }
-
-            unique_ptr& operator=(nullptr_t) noexcept
-            {
-                reset();
-
-                return *this;
-            }
-
-            /**
-             * 20.8.1.3.3, observers:
-             */
-
-            element_type& operator[](size_t idx) const
-            {
-                return ptr_[idx];
-            }
-
-            pointer get() const noexcept
-            {
-                return ptr_;
-            }
-
-            deleter_type& get_deleter() noexcept
-            {
-                return deleter_;
-            }
-
-            const deleter_type& get_deleter() const noexcept
-            {
-                return deleter_;
-            }
-
-            explicit operator bool() const noexcept
-            {
-                return ptr_ != nullptr;
-            }
-
-            /**
-             * 20.8.1.3.4, modifiers:
-             */
-
-            pointer release() noexcept
-            {
-                auto ret = ptr_;
-                ptr_ = nullptr;
-
-                return ret;
-            }
-
-            template<
-                class U,
-                class = enable_if_t<
-                    is_same_v<U, pointer> ||
-                    (is_same_v<pointer, element_type*> && is_pointer_v<U> &&
-                     aux::is_convertible_array_v<remove_pointer_t<U>, element_type>),
-                    void
-                >
-            >
-            void reset(U ptr) noexcept
-            {
-                /**
-                 * Note: Order is significant, deleter may delete
-                 *       *this.
-                 */
-                auto old = ptr_;
-                ptr_ = ptr;
-
-                if (old)
-                    deleter_(old);
-            }
-
-            void reset(nullptr_t = nullptr) noexcept
-            {
-                reset(pointer{});
-            }
-
-            void swap(unique_ptr& other) noexcept
-            {
-                std::swap(ptr_, other.ptr_);
-                std::swap(deleter_, other.deleter_);
-            }
-
-            unique_ptr(const unique_ptr&) = delete;
-            unique_ptr& operator=(const unique_ptr&) = delete;
-
-        private:
-            pointer ptr_;
-            deleter_type deleter_;
-    };
-
-    namespace aux
-    {
-        template<class T>
-        struct is_unbound_array: false_type
-        { /* DUMMY BODY */ };
-
-        template<class T>
-        struct is_unbound_array<T[]>: true_type
-        { /* DUMMY BODY */ };
-
-        template<class T>
-        struct is_bound_array: false_type
-        { /* DUMMY BODY */ };
-
-        template<class T, size_t N>
-        struct is_bound_array<T[N]>: true_type
-        { /* DUMMY BODY */ };
-    }
-
-    template<
-        class T, class... Args,
-        class = enable_if_t<!is_array_v<T>, void>
-    >
-    unique_ptr<T> make_unique(Args&&... args)
-    {
-        return unique_ptr<T>(new T(forward<Args>(args)...));
-    }
-
-    template<
-        class T, class = enable_if_t<aux::is_unbound_array<T>::value, void>
-    >
-    unique_ptr<T> make_unique(size_t n)
-    {
-        return unique_ptr<T>(new remove_extent_t<T>[n]());
-    }
-
-    template<
-        class T, class... Args,
-        class = enable_if_t<aux::is_bound_array<T>::value, void>
-    >
-    void make_unique(Args&&...) = delete;
-
-    template<class T, class D>
-    void swap(unique_ptr<T, D>& lhs, unique_ptr<T, D>& rhs) noexcept
-    {
-        lhs.swap(rhs);
-    }
-
-    template<class T1, class D1, class T2, class D2>
-    bool operator==(const unique_ptr<T1, D1>& lhs,
-                    const unique_ptr<T2, D2>& rhs)
-    {
-        return lhs.get() == rhs.get();
-    }
-
-    template<class T1, class D1, class T2, class D2>
-    bool operator!=(const unique_ptr<T1, D1>& lhs,
-                    const unique_ptr<T2, D2>& rhs)
-    {
-        return lhs.get() != rhs.get();
-    }
-
-    template<class T1, class D1, class T2, class D2>
-    bool operator<(const unique_ptr<T1, D1>& lhs,
-                   const unique_ptr<T2, D2>& rhs)
-    {
-        return lhs.get() < rhs.get();
-    }
-
-    template<class T1, class D1, class T2, class D2>
-    bool operator<=(const unique_ptr<T1, D1>& lhs,
-                    const unique_ptr<T2, D2>& rhs)
-    {
-        return !(rhs < lhs);
-    }
-
-    template<class T1, class D1, class T2, class D2>
-    bool operator>(const unique_ptr<T1, D1>& lhs,
-                   const unique_ptr<T2, D2>& rhs)
-    {
-        return rhs < lhs;
-    }
-
-    template<class T1, class D1, class T2, class D2>
-    bool operator>=(const unique_ptr<T1, D1>& lhs,
-                    const unique_ptr<T2, D2>& rhs)
-    {
-        return !(lhs < rhs);
-    }
-
-    template<class T, class D>
-    bool operator==(const unique_ptr<T, D>& ptr, nullptr_t) noexcept
-    {
-        return !ptr;
-    }
-
-    template<class T, class D>
-    bool operator==(nullptr_t, const unique_ptr<T, D>& ptr) noexcept
-    {
-        return !ptr;
-    }
-
-    template<class T, class D>
-    bool operator!=(const unique_ptr<T, D>& ptr, nullptr_t) noexcept
-    {
-        return static_cast<bool>(ptr);
-    }
-
-    template<class T, class D>
-    bool operator!=(nullptr_t, const unique_ptr<T, D>& ptr) noexcept
-    {
-        return static_cast<bool>(ptr);
-    }
-
-    template<class T, class D>
-    bool operator<(const unique_ptr<T, D>& ptr, nullptr_t)
-    {
-        return ptr.get() < nullptr;
-    }
-
-    template<class T, class D>
-    bool operator<(nullptr_t, const unique_ptr<T, D>& ptr)
-    {
-        return nullptr < ptr.get();
-    }
-
-    template<class T, class D>
-    bool operator<=(const unique_ptr<T, D>& ptr, nullptr_t)
-    {
-        return !(nullptr < ptr);
-    }
-
-    template<class T, class D>
-    bool operator<=(nullptr_t, const unique_ptr<T, D>& ptr)
-    {
-        return !(ptr < nullptr);
-    }
-
-    template<class T, class D>
-    bool operator>(const unique_ptr<T, D>& ptr, nullptr_t)
-    {
-        return nullptr < ptr;
-    }
-
-    template<class T, class D>
-    bool operator>(nullptr_t, const unique_ptr<T, D>& ptr)
-    {
-        return ptr < nullptr;
-    }
-
-    template<class T, class D>
-    bool operator>=(const unique_ptr<T, D>& ptr, nullptr_t)
-    {
-        return !(ptr < nullptr);
-    }
-
-    template<class T, class D>
-    bool operator>=(nullptr_t, const unique_ptr<T, D>& ptr)
-    {
-        return !(nullptr < ptr);
-    }
-
-    /**
-     * 20.8.2.7, smart pointer hash support:
-     */
-
-    template<class T, class D>
-    struct hash<unique_ptr<T, D>>
-    {
-        size_t operator()(const unique_ptr<T, D>& ptr) const noexcept
-        {
-            return hash<typename unique_ptr<T, D>::pointer>{}(ptr.get());
-        }
-
-        using argument_type = unique_ptr<T, D>;
-        using result_type   = size_t;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/memory/weak_ptr.hpp
===================================================================
--- uspace/lib/cpp/include/internal/memory/weak_ptr.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,234 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_MEMORY_WEAK_PTR
-#define LIBCPP_INTERNAL_MEMORY_WEAK_PTR
-
-#include <internal/memory/shared_payload.hpp>
-#include <type_traits>
-#include <utility>
-
-namespace std
-{
-    template<class T>
-    class shared_ptr;
-
-    /**
-     * 20.8.2.3, class template weak_ptr:
-     */
-
-    template<class T>
-    class weak_ptr
-    {
-        public:
-            using element_type = T;
-
-            /**
-             * 20.8.2.3.1, constructors:
-             */
-
-            constexpr weak_ptr() noexcept
-                : payload_{}
-            { /* DUMMY BODY */ }
-
-            template<class U>
-            weak_ptr(
-                const shared_ptr<U>& other,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            ) noexcept
-                : payload_{other.payload_}
-            {
-                if (payload_)
-                    payload_->increment_weak();
-            }
-
-            weak_ptr(const weak_ptr& other) noexcept
-                : payload_{other.payload_}
-            {
-                if (payload_)
-                    payload_->increment_weak();
-            }
-
-            template<class U>
-            weak_ptr(
-                const weak_ptr<U>& other,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            ) noexcept
-                : payload_{other.payload_}
-            {
-                if (payload_)
-                    payload_->increment_weak();
-            }
-
-            weak_ptr(weak_ptr&& other) noexcept
-                : payload_{other.payload_}
-            {
-                other.payload_ = nullptr;
-            }
-
-            template<class U>
-            weak_ptr(
-                weak_ptr<U>&& other,
-                enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
-            ) noexcept
-                : payload_{other.payload_}
-            {
-                other.payload_ = nullptr;
-            }
-
-            /**
-             * 20.8.2.3.2, destructor:
-             */
-
-            ~weak_ptr()
-            {
-                remove_payload_();
-            }
-
-            /**
-             * 20.8.2.3.3, assignment:
-             */
-
-            weak_ptr& operator=(const weak_ptr& rhs) noexcept
-            {
-                remove_payload_();
-
-                payload_ = rhs.payload_;
-                if (payload_)
-                    payload_->increment_weak();
-
-                return *this;
-            }
-
-            template<class U>
-            weak_ptr& operator=(const weak_ptr<U>& rhs) noexcept
-            {
-                weak_ptr{rhs}.swap(*this);
-
-                return *this;
-            }
-
-            template<class U>
-            weak_ptr& operator=(const shared_ptr<U>& rhs) noexcept
-            {
-                weak_ptr{rhs}.swap(*this);
-
-                return *this;
-            }
-
-            weak_ptr& operator=(weak_ptr&& rhs) noexcept
-            {
-                weak_ptr{move(rhs)}.swap(*this);
-
-                return *this;
-            }
-
-            template<class U>
-            weak_ptr& operator=(
-                weak_ptr<U>&& rhs
-            ) noexcept
-            {
-                weak_ptr{move(rhs)}.swap(*this);
-
-                return *this;
-            }
-
-            /**
-             * 20.8.2.3.4, modifiers:
-             */
-
-            void swap(weak_ptr& other) noexcept
-            {
-                std::swap(payload_, other.payload_);
-            }
-
-            void reset() noexcept
-            {
-                weak_ptr{}.swap(*this);
-            }
-
-            /**
-             * 20.8.2.3.5, observers:
-             */
-
-            long use_count() const noexcept
-            {
-                if (payload_)
-                    return payload_->refs();
-                else
-                    return 0L;
-            }
-
-            bool expired() const noexcept
-            {
-                return use_count() == 0L;
-            }
-
-            shared_ptr<T> lock() const noexcept
-            {
-                return shared_ptr{aux::payload_tag, payload_->lock()};
-            }
-
-            template<class U>
-            bool owner_before(const shared_ptr<U>& other) const
-            {
-                return payload_ < other.payload_;
-            }
-
-            template<class U>
-            bool owner_before(const weak_ptr<U>& other) const
-            {
-                return payload_ < other.payload_;
-            }
-
-        private:
-            aux::shared_payload_base<T>* payload_;
-
-            void remove_payload_()
-            {
-                if (payload_ && payload_->decrement_weak())
-                    payload_->destroy();
-                payload_ = nullptr;
-            }
-
-            template<class U>
-            friend class shared_ptr;
-    };
-
-    /**
-     * 20.8.2.3.6, specialized algorithms:
-     */
-
-    template<class T>
-    void swap(weak_ptr<T>& lhs, weak_ptr<T>& rhs) noexcept
-    {
-        lhs.swap(rhs);
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/rbtree.hpp
===================================================================
--- uspace/lib/cpp/include/internal/rbtree.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,491 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_RBTREE
-#define LIBCPP_INTERNAL_RBTREE
-
-#include <internal/key_extractors.hpp>
-#include <internal/rbtree_iterators.hpp>
-#include <internal/rbtree_node.hpp>
-#include <internal/rbtree_policies.hpp>
-
-namespace std::aux
-{
-    template<
-        class Value, class Key, class KeyExtractor,
-        class KeyComp, class Alloc, class Size,
-        class Iterator, class ConstIterator,
-        class Policy, class Node
-    >
-    class rbtree
-    {
-        public:
-            using value_type     = Value;
-            using key_type       = Key;
-            using size_type      = Size;
-            using allocator_type = Alloc;
-            using key_compare    = KeyComp;
-            using key_extract    = KeyExtractor;
-
-            using iterator       = Iterator;
-            using const_iterator = ConstIterator;
-
-            using reverse_iterator       = std::reverse_iterator<iterator>;
-            using const_reverse_iterator = std::reverse_iterator<const_iterator>;
-
-            using node_type = Node;
-
-            rbtree(const key_compare& kcmp = key_compare{})
-                : root_{nullptr}, size_{}, key_compare_{},
-                  key_extractor_{}
-            { /* DUMMY BODY */ }
-
-            rbtree(const rbtree& other)
-                : rbtree{other.key_compare_}
-            {
-                for (const auto& x: other)
-                    insert(x);
-            }
-
-            rbtree(rbtree&& other)
-                : root_{other.root_}, size_{other.size_},
-                  key_compare_{move(other.key_compare_)},
-                  key_extractor_{move(other.key_extractor_)}
-            {
-                other.root_ = nullptr;
-                other.size_ = size_type{};
-            }
-
-            rbtree& operator=(const rbtree& other)
-            {
-                auto tmp{other};
-                tmp.swap(*this);
-
-                return *this;
-            }
-
-            rbtree& operator=(rbtree&& other)
-            {
-                rbtree tmp{move(other)};
-                tmp.swap(*this);
-
-                return *this;
-            }
-
-            bool empty() const noexcept
-            {
-                return size_ == 0U;
-            }
-
-            size_type size() const noexcept
-            {
-                return size_;
-            }
-
-            size_type max_size(allocator_type& alloc)
-            {
-                return allocator_traits<allocator_type>::max_size(alloc);
-            }
-
-            iterator begin()
-            {
-                return iterator{find_smallest_(), false};
-            }
-
-            const_iterator begin() const
-            {
-                return cbegin();
-            }
-
-            iterator end()
-            {
-                /**
-                 * In case we have lists of nodes
-                 * we need to get the actual end
-                 * from the largest node.
-                 */
-                auto res = find_largest_();
-                if (res)
-                    return iterator{res->get_end(), true};
-                else
-                    return iterator{res, true};
-            }
-
-            const_iterator end() const
-            {
-                return cend();
-            }
-
-            reverse_iterator rbegin()
-            {
-                return make_reverse_iterator(end());
-            }
-
-            const_reverse_iterator rbegin() const
-            {
-                return make_reverse_iterator(cend());
-            }
-
-            reverse_iterator rend()
-            {
-                return make_reverse_iterator(begin());
-            }
-
-            const_reverse_iterator rend() const
-            {
-                return make_reverse_iterator(cbegin());
-            }
-
-            const_iterator cbegin() const
-            {
-                return const_iterator{find_smallest_(), false};
-            }
-
-            const_iterator cend() const
-            {
-                auto res = find_largest_();
-                if (res)
-                    return const_iterator{res->get_end(), true};
-                else
-                    return const_iterator{res, true};
-            }
-
-            const_reverse_iterator crbegin() const
-            {
-                return make_reverse_iterator(cend());
-            }
-
-            const_reverse_iterator crend() const
-            {
-                return make_reverse_iterator(cbegin());
-            }
-
-            template<class... Args>
-            auto emplace(Args&&... args)
-            {
-                return Policy::emplace(*this, forward<Args>(args)...);
-            }
-
-            auto insert(const value_type& val)
-            {
-                return Policy::insert(*this, val);
-            }
-
-            auto insert(value_type&& val)
-            {
-                return Policy::insert(*this, forward<value_type>(val));
-            }
-
-            size_type erase(const key_type& key)
-            {
-                return Policy::erase(*this, key);
-            }
-
-            iterator erase(const_iterator it)
-            {
-                if (it == cend())
-                    return end();
-
-                auto node = const_cast<node_type*>(it.node());
-
-                node = delete_node(node);
-                if (!node)
-                    return iterator{find_largest_(), true};
-                else
-                    return iterator{const_cast<node_type*>(node), false};
-            }
-
-            void clear() noexcept
-            {
-                if (root_)
-                {
-                    delete root_;
-                    root_ = nullptr;
-                    size_ = size_type{};
-                }
-            }
-
-            void swap(rbtree& other)
-                noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
-                         noexcept(swap(declval<KeyComp&>(), declval<KeyComp&>())))
-            {
-                std::swap(root_, other.root_);
-                std::swap(size_, other.size_);
-                std::swap(key_compare_, other.key_compare_);
-                std::swap(key_extractor_, other.key_extractor_);
-            }
-
-            key_compare key_comp() const
-            {
-                return key_compare_;
-            }
-
-            iterator find(const key_type& key)
-            {
-                auto node = find_(key);
-                if (node)
-                    return iterator{node, false};
-                else
-                    return end();
-            }
-
-            const_iterator find(const key_type& key) const
-            {
-                auto node = find_(key);
-                if (node)
-                    return const_iterator{node, false};
-                else
-                    return end();
-            }
-
-            size_type count(const key_type& key) const
-            {
-                return Policy::count(*this, key);
-            }
-
-            iterator upper_bound(const key_type& key)
-            {
-                return Policy::upper_bound(*this, key);
-            }
-
-            const_iterator upper_bound(const key_type& key) const
-            {
-                return Policy::upper_bound_const(*this, key);
-            }
-
-            iterator lower_bound(const key_type& key)
-            {
-                return Policy::lower_bound(*this, key);
-            }
-
-            const_iterator lower_bound(const key_type& key) const
-            {
-                return Policy::lower_bound_const(*this, key);
-            }
-
-            pair<iterator, iterator> equal_range(const key_type& key)
-            {
-                return Policy::equal_range(*this, key);
-            }
-
-            pair<const_iterator, const_iterator> equal_range(const key_type& key) const
-            {
-                return Policy::equal_range_const(*this, key);
-            }
-
-            bool is_eq_to(const rbtree& other) const
-            {
-                if (size_ != other.size())
-                    return false;
-
-                auto it1 = begin();
-                auto it2 = other.begin();
-
-                // TODO: this doesn't compare values :/
-                while (keys_equal(*it1++, *it2++))
-                { /* DUMMY BODY */ }
-
-                return (it1 == end()) && (it2 == other.end());
-            }
-
-            const key_type& get_key(const value_type& val) const
-            {
-                return key_extractor_(val);
-            }
-
-            bool keys_comp(const key_type& key, const value_type& val) const
-            {
-                return key_compare_(key, key_extractor_(val));
-            }
-
-            bool keys_equal(const key_type& k1, const key_type& k2) const
-            {
-                return !key_compare_(k1, k2) && !key_compare_(k2, k1);
-            }
-
-            node_type* find_parent_for_insertion(const key_type& key) const
-            {
-                auto current = root_;
-                auto parent = current;
-
-                while (current)
-                {
-                    parent = current;
-                    if (key_compare_(key, key_extractor_(current->value)))
-                        current = current->left();
-                    else if (key_compare_(key_extractor_(current->value), key))
-                        current = current->right();
-                    else
-                        return current;
-                }
-
-                return parent;
-            }
-
-            node_type* delete_node(const node_type* n)
-            {
-                auto node = const_cast<node_type*>(n);
-                if (!node)
-                    return nullptr;
-
-                --size_;
-
-                auto succ = node->successor();
-                if (auto tmp = node->get_node_for_deletion(); tmp != nullptr)
-                {
-                    /**
-                     * This will kick in multi containers,
-                     * we popped one node from a list of nodes
-                     * with equivalent keys and we can delete it
-                     * and return the successor which was the next
-                     * in the list.
-                     */
-                    delete tmp;
-
-                    update_root_(succ); // Incase the first in list was root.
-                    return succ;
-                }
-                else if (node == root_)
-                { // Only executed if root_ is unique.
-                    root_ = nullptr;
-                    delete node;
-
-                    return nullptr;
-                }
-
-                if (node->left() && node->right())
-                {
-                    node->swap(succ);
-                    if (succ && !succ->parent())
-                        root_ = succ;
-
-                    // Node now has at most one child.
-                    // Also: If succ was nullptr, the swap
-                    //       didn't do anything and we can
-                    //       safely delete node.
-                    return delete_node(node);
-                }
-
-                auto child = node->right() ? node->right() : node->left();
-                if (!child)
-                {
-                    // Simply remove the node.
-                    // TODO: repair here too?
-                    node->unlink();
-                    delete node;
-                }
-                else
-                {
-                    // Replace with the child.
-                    child->parent(node->parent());
-                    if (node->is_left_child())
-                        child->parent()->left(child);
-                    else if (node->is_right_child())
-                        child->parent()->right(child);
-                    node->parent(nullptr);
-                    node->left(nullptr);
-                    node->right(nullptr);
-
-                    // Repair if needed.
-                    repair_after_erase_(node, child);
-                    update_root_(child);
-
-                    delete node;
-                }
-
-                return succ;
-            }
-
-            void insert_node(node_type* node, node_type* parent)
-            {
-                Policy::insert(*this, node, parent);
-            }
-
-        private:
-            node_type* root_;
-            size_type size_;
-            key_compare key_compare_;
-            key_extract key_extractor_;
-
-            node_type* find_(const key_type& key) const
-            {
-                auto current = root_;
-                while (current != nullptr)
-                {
-                    if (key_compare_(key, key_extractor_(current->value)))
-                        current = current->left();
-                    else if (key_compare_(key_extractor_(current->value), key))
-                        current = current->right();
-                    else
-                        return current;
-                }
-
-                return nullptr;
-            }
-
-            node_type* find_smallest_() const
-            {
-                if (root_)
-                    return root_->find_smallest();
-                else
-                    return nullptr;
-            }
-
-            node_type* find_largest_() const
-            {
-                if (root_)
-                    return root_->find_largest();
-                else
-                    return nullptr;
-            }
-
-            void update_root_(const node_type* node)
-            {
-                if (!node)
-                    return;
-
-                root_ = const_cast<node_type*>(node);
-                while (root_->parent())
-                    root_ = root_->parent();
-            }
-
-            void repair_after_insert_(const node_type* node)
-            {
-                // TODO: implement
-            }
-
-            void repair_after_erase_(const node_type* node, const node_type* child)
-            {
-                // TODO: implement
-            }
-
-            friend Policy;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/rbtree_iterators.hpp
===================================================================
--- uspace/lib/cpp/include/internal/rbtree_iterators.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,330 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_RBTREE_ITERATORS
-#define LIBCPP_INTERNAL_RBTREE_ITERATORS
-
-#include <internal/iterator.hpp>
-#include <internal/rbtree_node.hpp>
-#include <iterator>
-
-namespace std::aux
-{
-    /**
-     * Note: In order for these iterators to be reversible,
-     *       the end state of an iterator is represented by a flag
-     *       which can be set from true to false in operator--
-     *       (i.e. decrementing end iterator) or set from false to
-     *       true in operator++ (i.e. incrementing last before end
-     *       iterator).
-     */
-
-    template<class Value, class Reference, class Pointer, class Size, class Node>
-    class rbtree_iterator
-    {
-        public:
-            using value_type      = Value;
-            using size_type       = Size;
-            using reference       = Reference;
-            using pointer         = Pointer;
-            using difference_type = ptrdiff_t;
-
-            using iterator_category = bidirectional_iterator_tag;
-
-            using node_type = Node;
-
-            rbtree_iterator(node_type* current = nullptr, bool end = true)
-                : current_{current}, end_{end}
-            { /* DUMMY BODY */ }
-
-            rbtree_iterator(const rbtree_iterator&) = default;
-            rbtree_iterator& operator=(const rbtree_iterator&) = default;
-
-            reference operator*() const
-            {
-                return current_->value;
-            }
-
-            pointer operator->() const
-            {
-                return &current_->value;
-            }
-
-            rbtree_iterator& operator++()
-            {
-                if (end_)
-                    return *this;
-
-                if (current_)
-                {
-                    auto next = current_->successor();
-                    if (next)
-                        current_ = next;
-                    else
-                        end_ = true;
-                }
-
-                return *this;
-            }
-
-            rbtree_iterator operator++(int)
-            {
-                auto tmp = *this;
-                ++(*this);
-
-                return tmp;
-            }
-
-            rbtree_iterator& operator--()
-            {
-                if (end_)
-                {
-                    end_ = false;
-
-                    return *this;
-                }
-
-                if (current_)
-                {
-                    auto next = current_->predecessor();
-                    if (next)
-                        current_ = next;
-                    else
-                        end_ = true;
-                }
-
-                return *this;
-            }
-
-            rbtree_iterator operator--(int)
-            {
-                auto tmp = *this;
-                --(*this);
-
-                return tmp;
-            }
-
-            const node_type* node() const
-            {
-                return current_;
-            }
-
-            node_type* node()
-            {
-                return current_;
-            }
-
-            bool end() const
-            {
-                return end_;
-            }
-
-        private:
-            node_type* current_;
-            bool end_;
-    };
-
-    template<class Val, class Ref, class Ptr, class Sz, class N>
-    bool operator==(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
-                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
-    {
-        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
-    }
-
-    template<class Val, class Ref, class Ptr, class Sz, class N>
-    bool operator!=(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
-                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Value, class ConstReference, class ConstPointer, class Size, class Node>
-    class rbtree_const_iterator
-    {
-        using non_const_iterator_type = rbtree_iterator<
-            Value, get_non_const_ref_t<ConstReference>,
-            get_non_const_ptr_t<ConstPointer>, Size, Node
-        >;
-
-        public:
-            using value_type      = Value;
-            using size_type       = Size;
-            using const_reference = ConstReference;
-            using const_pointer   = ConstPointer;
-            using difference_type = ptrdiff_t;
-
-            using iterator_category = bidirectional_iterator_tag;
-
-            // For iterator_traits.
-            using reference = ConstReference;
-            using pointer   = ConstPointer;
-
-            using node_type = Node;
-
-            rbtree_const_iterator(const node_type* current = nullptr, bool end = true)
-                : current_{current}, end_{end}
-            { /* DUMMY BODY */ }
-
-            rbtree_const_iterator(const rbtree_const_iterator&) = default;
-            rbtree_const_iterator& operator=(const rbtree_const_iterator&) = default;
-
-            rbtree_const_iterator(const non_const_iterator_type& other)
-                : current_{other.node()}, end_{other.end()}
-            { /* DUMMY BODY */ }
-
-            rbtree_const_iterator& operator=(const non_const_iterator_type& other)
-            {
-                current_ = other.node();
-                end_ = other.end();
-
-                return *this;
-            }
-
-            const_reference operator*() const
-            {
-                return current_->value;
-            }
-
-            const_pointer operator->() const
-            {
-                return &current_->value;
-            }
-
-            rbtree_const_iterator& operator++()
-            {
-                if (end_)
-                    return *this;
-
-                if (current_)
-                {
-                    auto next = current_->successor();
-                    if (next)
-                        current_ = next;
-                    else
-                        end_ = true;
-                }
-
-                return *this;
-            }
-
-            rbtree_const_iterator operator++(int)
-            {
-                auto tmp = *this;
-                ++(*this);
-
-                return tmp;
-            }
-
-            rbtree_const_iterator& operator--()
-            {
-                if (end_)
-                {
-                    end_ = false;
-
-                    return *this;
-                }
-
-                if (current_)
-                {
-                    auto next = current_->predecessor();
-                    if (next)
-                        current_ = next;
-                    else
-                        end_ = true;
-                }
-
-                return *this;
-            }
-
-            rbtree_const_iterator operator--(int)
-            {
-                auto tmp = *this;
-                --(*this);
-
-                return tmp;
-            }
-
-            const node_type* node() const
-            {
-                return current_;
-            }
-
-            bool end() const
-            {
-                return end_;
-            }
-
-        private:
-            const node_type* current_;
-            bool end_;
-    };
-
-    template<class Val, class CRef, class CPtr, class Sz, class N>
-    bool operator==(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
-                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
-    {
-        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
-    }
-
-    template<class Val, class CRef, class CPtr, class Sz, class N>
-    bool operator!=(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
-                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Val, class Ref, class Ptr, class CRef, class CPtr, class Sz, class N>
-    bool operator==(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
-                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
-    {
-        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
-    }
-
-    template<class Val, class Ref, class Ptr, class CRef, class CPtr, class Sz, class N>
-    bool operator!=(const rbtree_iterator<Val, Ref, Ptr, Sz, N>& lhs,
-                    const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-
-    template<class Val, class CRef, class CPtr, class Ref, class Ptr, class Sz, class N>
-    bool operator==(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
-                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
-    {
-        return (lhs.node() == rhs.node()) && (lhs.end() == rhs.end());
-    }
-
-    template<class Val, class CRef, class CPtr, class Ref, class Ptr, class Sz, class N>
-    bool operator!=(const rbtree_const_iterator<Val, CRef, CPtr, Sz, N>& lhs,
-                    const rbtree_iterator<Val, Ref, Ptr, Sz, N>& rhs)
-    {
-        return !(lhs == rhs);
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/rbtree_node.hpp
===================================================================
--- uspace/lib/cpp/include/internal/rbtree_node.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,728 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_RBTREE_NODE
-#define LIBCPP_INTERNAL_RBTREE_NODE
-
-#include <cassert>
-#include <utility>
-
-namespace std::aux
-{
-    enum class rbcolor
-    {
-        red, black
-    };
-
-    template<class Node>
-    struct rbtree_utils
-    {
-        static Node* grandparent(Node* node)
-        {
-            if (node && node->parent())
-                return node->parent()->parent();
-            else
-                return nullptr;
-        }
-
-        static Node* brother(Node* node)
-        {
-            if (node && node->parent())
-            {
-                if (node == node->parent()->left())
-                    return node->parent()->right();
-                else
-                    return node->parent()->left();
-            }
-            else
-                return nullptr;
-        }
-
-        static Node* uncle(Node* node)
-        {
-            auto gp = grandparent(node);
-            if (gp)
-            {
-                if (node->parent() == gp->left())
-                    return gp->right();
-                else
-                    return gp->left();
-            }
-            else
-                return nullptr;
-        }
-
-        static bool is_left_child(const Node* node)
-        {
-            if (!node)
-                return false;
-
-            if (node->parent())
-                return node->parent()->left() == node;
-            else
-                return false;
-        }
-
-        static bool is_right_child(const Node* node)
-        {
-            if (!node)
-                return false;
-
-            if (node->parent())
-                return node->parent()->right() == node;
-            else
-                return false;
-        }
-
-        static void rotate_left(Node* node)
-        {
-            // TODO: implement
-        }
-
-        static void rotate_right(Node* node)
-        {
-            // TODO: implement
-        }
-
-        static Node* find_smallest(Node* node)
-        {
-            return const_cast<Node*>(find_smallest(const_cast<const Node*>(node)));
-        }
-
-        static const Node* find_smallest(const Node* node)
-        {
-            if (!node)
-                return nullptr;
-
-            while (node->left())
-                node = node->left();
-
-            return node;
-        }
-
-        static Node* find_largest(Node* node)
-        {
-            return const_cast<Node*>(find_largest(const_cast<const Node*>(node)));
-        }
-
-        static const Node* find_largest(const Node* node)
-        {
-            if (!node)
-                return nullptr;
-
-            while (node->right())
-                node = node->right();
-
-            return node;
-        }
-
-        static Node* successor(Node* node)
-        {
-            return const_cast<Node*>(successor(const_cast<const Node*>(node)));
-        }
-
-        static const Node* successor(const Node* node)
-        {
-            if (!node)
-                return nullptr;
-
-            if (node->right())
-                return find_smallest(node->right());
-            else
-            {
-                while (node && !is_left_child(node))
-                    node = node->parent();
-
-                if (node)
-                    return node->parent();
-                else
-                    return node;
-            }
-        }
-
-        static Node* predecessor(Node* node)
-        {
-            return const_cast<Node*>(predecessor(const_cast<const Node*>(node)));
-        }
-
-        static const Node* predecessor(const Node* node)
-        {
-            if (!node)
-                return nullptr;
-
-            if (node->left())
-                return find_largest(node->left());
-            else
-            {
-                while (node && is_left_child(node))
-                    node = node->parent();
-
-                if (node)
-                    return node->parent();
-                else
-                    return node;
-            }
-        }
-
-        static void add_left_child(Node* node, Node* child)
-        {
-            if (!node || !child)
-                return;
-
-            node->left(child);
-            child->parent(node);
-        }
-
-        static void add_right_child(Node* node, Node* child)
-        {
-            if (!node || !child)
-                return;
-
-            node->right(child);
-            child->parent(node);
-        }
-
-        static void swap(Node* node1, Node* node2)
-        {
-            if (!node1 || !node2)
-                return;
-
-            auto parent1 = node1->parent();
-            auto left1 = node1->left();
-            auto right1 = node1->right();
-            auto is_right1 = is_right_child(node1);
-
-            auto parent2 = node2->parent();
-            auto left2 = node2->left();
-            auto right2 = node2->right();
-            auto is_right2 = is_right_child(node2);
-
-            assimilate(node1, parent2, left2, right2, is_right2);
-            assimilate(node2, parent1, left1, right1, is_right1);
-        }
-
-        static void assimilate(
-            Node* node, Node* p, Node* l, Node* r, bool is_r
-        )
-        {
-            if (!node)
-                return;
-
-            node->parent(p);
-            if (node->parent())
-            {
-                if (is_r)
-                    node->parent()->right(node);
-                else
-                    node->parent()->left(node);
-            }
-
-            node->left(l);
-            if (node->left())
-                node->left()->parent(node);
-
-            node->right(r);
-            if (node->right())
-                node->right()->parent(node);
-        }
-    };
-
-    template<class T>
-    struct rbtree_single_node
-    {
-        using utils = rbtree_utils<rbtree_single_node<T>>;
-
-        public:
-            T value;
-            rbcolor color;
-
-            template<class... Args>
-            rbtree_single_node(Args&&... args)
-                : value{forward<Args>(args)...}, color{rbcolor::red},
-                  parent_{}, left_{}, right_{}
-            { /* DUMMY BODY */ }
-
-            rbtree_single_node* parent() const
-            {
-                return parent_;
-            }
-
-            void parent(rbtree_single_node* node)
-            {
-                parent_ = node;
-            }
-
-            rbtree_single_node* left() const
-            {
-                return left_;
-            }
-
-            void left(rbtree_single_node* node)
-            {
-                left_ = node;
-            }
-
-            rbtree_single_node* right() const
-            {
-                return right_;
-            }
-
-            void right(rbtree_single_node* node)
-            {
-                right_ = node;
-            }
-
-            rbtree_single_node* grandparent()
-            {
-                return utils::grandparent(this);
-            }
-
-            rbtree_single_node* brother()
-            {
-                return utils::brother(this);
-            }
-
-            rbtree_single_node* uncle()
-            {
-                return utils::uncle(this);
-            }
-
-            bool is_left_child() const
-            {
-                return utils::is_left_child(this);
-            }
-
-            bool is_right_child() const
-            {
-                return utils::is_right_child(this);
-            }
-
-            void rotate_left()
-            {
-                utils::rotate_left(this);
-            }
-
-            void rotate_right()
-            {
-                utils::rotate_right(this);
-            }
-
-            rbtree_single_node* find_smallest()
-            {
-                return utils::find_smallest(this);
-            }
-
-            const rbtree_single_node* find_smallest() const
-            {
-                return utils::find_smallest(this);
-            }
-
-            rbtree_single_node* find_largest()
-            {
-                return utils::find_largest(this);
-            }
-
-            const rbtree_single_node* find_largest() const
-            {
-                return utils::find_largest(this);
-            }
-
-            rbtree_single_node* successor()
-            {
-                return utils::successor(this);
-            }
-
-            const rbtree_single_node* successor() const
-            {
-                return utils::successor(this);
-            }
-
-            rbtree_single_node* predecessor()
-            {
-                return utils::predecessor(this);
-            }
-
-            const rbtree_single_node* predecessor() const
-            {
-                return utils::predecessor(this);
-            }
-
-            void add_left_child(rbtree_single_node* node)
-            {
-                utils::add_left_child(this, node);
-            }
-
-            void add_right_child(rbtree_single_node* node)
-            {
-                utils::add_right_child(this, node);
-            }
-
-            void swap(rbtree_single_node* other)
-            {
-                utils::swap(this, other);
-            }
-
-            void unlink()
-            {
-                if (is_left_child())
-                    parent_->left_ = nullptr;
-                else if (is_right_child())
-                    parent_->right_ = nullptr;
-            }
-
-            rbtree_single_node* get_node_for_deletion()
-            {
-                return nullptr;
-            }
-
-            rbtree_single_node* get_end()
-            {
-                return this;
-            }
-
-            const rbtree_single_node* get_end() const
-            {
-                return this;
-            }
-
-            ~rbtree_single_node()
-            {
-                parent_ = nullptr;
-                if (left_)
-                    delete left_;
-                if (right_)
-                    delete right_;
-            }
-
-        private:
-            rbtree_single_node* parent_;
-            rbtree_single_node* left_;
-            rbtree_single_node* right_;
-    };
-
-    template<class T>
-    struct rbtree_multi_node
-    {
-        using utils = rbtree_utils<rbtree_multi_node<T>>;
-
-        public:
-            T value;
-            rbcolor color;
-
-            template<class... Args>
-            rbtree_multi_node(Args&&... args)
-                : value{forward<Args>(args)...}, color{rbcolor::red},
-                  parent_{}, left_{}, right_{}, next_{}, first_{}
-            {
-                first_ = this;
-            }
-
-            rbtree_multi_node* parent() const
-            {
-                return parent_;
-            }
-
-            void parent(rbtree_multi_node* node)
-            {
-                parent_ = node;
-
-                auto tmp = first_;
-                while (tmp)
-                {
-                    tmp->parent_ = node;
-                    tmp = tmp->next_;
-                }
-            }
-
-            rbtree_multi_node* left() const
-            {
-                return left_;
-            }
-
-            void left(rbtree_multi_node* node)
-            {
-                left_ = node;
-
-                auto tmp = first_;
-                while (tmp)
-                {
-                    tmp->left_ = node;
-                    tmp = tmp->next_;
-                }
-            }
-
-            rbtree_multi_node* right() const
-            {
-                return right_;
-            }
-
-            void right(rbtree_multi_node* node)
-            {
-                right_ = node;
-
-                auto tmp = first_;
-                while (tmp)
-                {
-                    tmp->right_ = node;
-                    tmp = tmp->next_;
-                }
-            }
-
-            rbtree_multi_node* grandparent()
-            {
-                return utils::grandparent(this);
-            }
-
-            rbtree_multi_node* brother()
-            {
-                return utils::brother(this);
-            }
-
-            rbtree_multi_node* uncle()
-            {
-                return utils::uncle(this);
-            }
-
-            bool is_left_child() const
-            {
-                return utils::is_left_child(this);
-            }
-
-            bool is_right_child()
-            {
-                return utils::is_right_child(this);
-            }
-
-            void rotate_left()
-            {
-                utils::rotate_left(this);
-            }
-
-            void rotate_right()
-            {
-                utils::rotate_right(this);
-            }
-
-            rbtree_multi_node* find_smallest()
-            {
-                return utils::find_smallest(this);
-            }
-
-            const rbtree_multi_node* find_smallest() const
-            {
-                return utils::find_smallest(this);
-            }
-
-            rbtree_multi_node* find_largest()
-            {
-                return utils::find_largest(this);
-            }
-
-            const rbtree_multi_node* find_largest() const
-            {
-                return utils::find_largest(this);
-            }
-
-            rbtree_multi_node* successor()
-            {
-                return const_cast<
-                    rbtree_multi_node*
-                >(const_cast<const rbtree_multi_node*>(this)->successor());
-            }
-
-            const rbtree_multi_node* successor() const
-            {
-                if (next_)
-                    return next_;
-                else
-                    return utils::successor(this);
-            }
-
-            rbtree_multi_node* predecessor()
-            {
-                return const_cast<
-                    rbtree_multi_node*
-                >(const_cast<const rbtree_multi_node*>(this)->predecessor());
-            }
-
-            const rbtree_multi_node* predecessor() const
-            {
-                if (this != first_)
-                {
-                    auto tmp = first_;
-                    while (tmp->next_ != this)
-                        tmp = tmp->next_;
-
-                    return tmp;
-                }
-                else
-                {
-                    auto tmp = utils::predecessor(this);
-
-                    /**
-                     * If tmp was duplicate, we got a pointer
-                     * to the first node in the list. So we need
-                     * to move to the end.
-                     */
-                    while (tmp->next_ != nullptr)
-                        tmp = tmp->next_;
-
-                    return tmp;
-                }
-            }
-
-            void add_left_child(rbtree_multi_node* node)
-            {
-                utils::add_left_child(this, node);
-            }
-
-            void add_right_child(rbtree_multi_node* node)
-            {
-                utils::add_right_child(this, node);
-            }
-
-            void swap(rbtree_multi_node* other)
-            {
-                utils::swap(this, other);
-            }
-
-            rbtree_multi_node* get_node_for_deletion()
-            {
-                /**
-                 * To make sure we delete nodes in
-                 * the order of their insertion
-                 * (not required, but sensical), we
-                 * update then list and return this
-                 * for deletion.
-                 */
-                if (next_)
-                {
-                    // Make next the new this.
-                    next_->first_ = next_;
-                    if (is_left_child())
-                        parent_->left_ = next_;
-                    else if (is_right_child())
-                        parent_->right_ = next_;
-
-                    if (left_)
-                        left_->parent_ = next_;
-                    if (right_)
-                        right_->parent_ = next_;
-
-                    /**
-                     * Update the first_ pointer
-                     * of the rest of the list.
-                     */
-                    auto tmp = next_->next_;
-                    while (tmp)
-                    {
-                        tmp->first_ = next_;
-                        tmp = tmp->next_;
-                    }
-
-                    /**
-                     * Otherwise destructor could
-                     * destroy them.
-                     */
-                    parent_ = nullptr;
-                    left_ = nullptr;
-                    right_ = nullptr;
-                    next_ = nullptr;
-                    first_ = nullptr;
-
-                    return this; // This will get deleted.
-                }
-                else
-                    return nullptr;
-            }
-
-            void unlink()
-            {
-                if (is_left_child())
-                    parent_->left_ = nullptr;
-                else if (is_right_child())
-                    parent_->right_ = nullptr;
-            }
-
-            void add(rbtree_multi_node* node)
-            {
-                if (next_)
-                    next_->add(node);
-                else
-                {
-                    next_ = node;
-                    next_->first_ = first_;
-                    next_->parent_ = parent_;
-                    next_->left_ = left_;
-                    next_->right_ = right_;
-                }
-            }
-
-            rbtree_multi_node* get_end()
-            {
-                return const_cast<rbtree_multi_node*>(
-                    const_cast<const rbtree_multi_node*>(this)->get_end()
-                );
-            }
-
-            const rbtree_multi_node* get_end() const
-            {
-                if (!next_)
-                    return this;
-                else
-                {
-                    auto tmp = next_;
-                    while (tmp->next_)
-                        tmp = tmp->next_;
-
-                    return tmp;
-                }
-            }
-
-            ~rbtree_multi_node()
-            {
-                parent_ = nullptr;
-                if (left_)
-                    delete left_;
-                if (right_)
-                    delete right_;
-
-                // TODO: delete the list
-            }
-
-        private:
-            rbtree_multi_node* parent_;
-            rbtree_multi_node* left_;
-            rbtree_multi_node* right_;
-
-            rbtree_multi_node* next_;
-            rbtree_multi_node* first_;
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/rbtree_policies.hpp
===================================================================
--- uspace/lib/cpp/include/internal/rbtree_policies.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,458 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_RBTREE_POLICIES
-#define LIBCPP_INTERNAL_RBTREE_POLICIES
-
-#include <internal/rbtree_node.hpp>
-#include <utility>
-
-namespace std::aux
-{
-    struct rbtree_single_policy
-    {
-        template<class Tree, class Key>
-        static typename Tree::size_type count(const Tree& tree, const Key& key)
-        {
-            return tree.find(key) == tree.end() ? 0 : 1;
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::size_type erase(Tree& tree, const Key& key)
-        {
-            using size_type = typename Tree::size_type;
-
-            auto it = tree.find(key);
-            if (it == tree.end())
-                return size_type{};
-            else
-                tree.delete_node(it.node());
-            return size_type{1};
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::iterator lower_bound(const Tree& tree, const Key& key)
-        {
-            using iterator  = typename Tree::iterator;
-            using node_type = typename Tree::node_type;
-
-            auto it = lower_bound_const(tree, key);
-
-            return iterator{const_cast<node_type*>(it.node()), it.end()};
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::const_iterator lower_bound_const(const Tree& tree, const Key& key)
-        {
-            using const_iterator = typename Tree::const_iterator;
-
-            auto node = tree.find_parent_for_insertion(key);
-            const_iterator it{node, false};
-            auto beg = tree.begin();
-            auto end = tree.end();
-
-            if (tree.key_compare_(tree.get_key(*it), key))
-            {
-                // Predecessor.
-                if (it != end)
-                    return ++it;
-                else
-                    return it;
-            }
-            else if (tree.key_compare_(key, tree.get_key(*it)))
-            {
-                // Successor.
-                if (it != beg)
-                    return --it;
-                else
-                    return it;
-            }
-            else // Perfect match.
-                return it;
-
-            return it;
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::iterator upper_bound(const Tree& tree, const Key& key)
-        {
-            using iterator  = typename Tree::iterator;
-            using node_type = typename Tree::node_type;
-
-            auto it = upper_bound_const(tree, key);
-
-            return iterator{const_cast<node_type*>(it.node()), it.end()};
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::const_iterator upper_bound_const(const Tree& tree, const Key& key)
-        {
-            /**
-             * If key isn't in the tree, we get it's
-             * predecessor or tree.end(). If key is
-             * in the tree, we get it. So unless it
-             * is equal to end(), we can increment it
-             * to get the upper bound.
-             */
-            auto it = lower_bound_const(tree, key);
-            if (it == tree.end())
-                return it;
-            else
-                return ++it;
-        }
-
-        template<class Tree, class Key>
-        static pair<
-            typename Tree::iterator,
-            typename Tree::iterator
-        > equal_range(Tree& tree, const Key& key)
-        {
-            return make_pair(
-                lower_bound(tree, key),
-                upper_bound(tree, key)
-            );
-        }
-
-        template<class Tree, class Key>
-        static pair<
-            typename Tree::const_iterator,
-            typename Tree::const_iterator
-        > equal_range_const(const Tree& tree, const Key& key)
-        {
-            return make_pair(
-                lower_bound_const(tree, key),
-                upper_bound_const(tree, key)
-            );
-        }
-
-        /**
-         * Note: We have to duplicate code for emplace, insert(const&)
-         *       and insert(&&) here, because the node (which makes distinction
-         *       between the arguments) is only created if the value isn't
-         *       in the tree already.
-         */
-
-        template<class Tree, class... Args>
-        static pair<
-            typename Tree::iterator, bool
-        > emplace(Tree& tree, Args&&... args)
-        {
-            using value_type = typename Tree::value_type;
-            using iterator   = typename Tree::iterator;
-            using node_type  = typename Tree::node_type;
-
-            auto val = value_type{forward<Args>(args)...};
-            auto parent = tree.find_parent_for_insertion(tree.get_key(val));
-
-            if (parent && tree.keys_equal(tree.get_key(parent->value), tree.get_key(val)))
-                return make_pair(iterator{parent, false}, false);
-
-            auto node = new node_type{move(val)};
-
-            return insert(tree, node, parent);
-        }
-
-        template<class Tree, class Value>
-        static pair<
-            typename Tree::iterator, bool
-        > insert(Tree& tree, const Value& val)
-        {
-            using iterator  = typename Tree::iterator;
-            using node_type = typename Tree::node_type;
-
-            auto parent = tree.find_parent_for_insertion(tree.get_key(val));
-            if (parent && tree.keys_equal(tree.get_key(parent->value), tree.get_key(val)))
-                return make_pair(iterator{parent, false}, false);
-
-            auto node = new node_type{val};
-
-            return insert(tree, node, parent);
-        }
-
-        template<class Tree, class Value>
-        static pair<
-            typename Tree::iterator, bool
-        > insert(Tree& tree, Value&& val)
-        {
-            using iterator  = typename Tree::iterator;
-            using node_type = typename Tree::node_type;
-
-            auto parent = tree.find_parent_for_insertion(tree.get_key(val));
-            if (parent && tree.keys_equal(tree.get_key(parent->value), tree.get_key(val)))
-                return make_pair(iterator{parent, false}, false);
-
-            auto node = new node_type{forward<Value>(val)};
-
-            return insert(tree, node, parent);
-        }
-
-        template<class Tree>
-        static pair<
-            typename Tree::iterator, bool
-        > insert(
-            Tree& tree, typename Tree::node_type* node,
-            typename Tree::node_type* parent
-        )
-        {
-            using iterator  = typename Tree::iterator;
-
-            if (!node)
-                return make_pair(tree.end(), false);
-
-            ++tree.size_;
-            if (!parent)
-            {
-                node->color = rbcolor::black;
-                tree.root_ = node;
-            }
-            else
-            {
-                if (tree.keys_comp(tree.get_key(node->value), parent->value))
-                    parent->add_left_child(node);
-                else
-                    parent->add_right_child(node);
-
-                tree.repair_after_insert_(node);
-                tree.update_root_(node);
-            }
-
-            return make_pair(iterator{node, false}, true);
-        }
-    };
-
-    struct rbtree_multi_policy
-    {
-        template<class Tree, class Key>
-        static typename Tree::size_type count(const Tree& tree, const Key& key)
-        {
-            using size_type = typename Tree::size_type;
-
-            auto it = tree.find(key);
-            if (it == tree.end())
-                return size_type{};
-
-            size_type res{};
-            while (it != tree.end() && tree.keys_equal(tree.get_key(*it), key))
-            {
-                ++res;
-                ++it;
-            }
-
-            return res;
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::size_type erase(Tree& tree, const Key& key)
-        {
-            using size_type = typename Tree::size_type;
-
-            auto it = tree.find(key);
-            if (it == tree.end())
-                return size_type{};
-
-            size_type res{};
-            while (it != tree.end() && tree.keys_equal(tree.get_key(*it), key))
-            {
-                ++res;
-                it = tree.erase(it);
-            }
-
-            return res;
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::iterator lower_bound(const Tree& tree, const Key& key)
-        {
-            auto it = lower_bound_const(tree, key);
-
-            return typename Tree::iterator{
-                const_cast<typename Tree::node_type*>(it.node()), it.end()
-            };
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::const_iterator lower_bound_const(const Tree& tree, const Key& key)
-        {
-            using const_iterator = typename Tree::const_iterator;
-
-            auto node = tree.find_parent_for_insertion(key);
-            const_iterator it{node, false};
-            auto beg = tree.begin();
-            auto end = tree.end();
-
-            if (tree.keys_comp(key, *it))
-                --it; // Incase we are on a successor.
-            while (tree.keys_equal(tree.get_key(*it), key) && it != beg)
-                --it; // Skip keys that are equal.
-            if (it != beg)
-                ++it; // If we moved all the way to the start, key is the smallest.
-
-            if (tree.key_compare_(tree.get_key(*it), key))
-            {
-                // Predecessor.
-                if (it != end)
-                    return ++it;
-                else
-                    return it;
-            }
-
-            return it;
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::iterator upper_bound(const Tree& tree, const Key& key)
-        {
-            auto it = upper_bound_const(tree, key);
-
-            return typename Tree::iterator{
-                const_cast<typename Tree::node_type*>(it.node()), it.end()
-            };
-        }
-
-        template<class Tree, class Key>
-        static typename Tree::const_iterator upper_bound_const(const Tree& tree, const Key& key)
-        {
-            /**
-             * If key isn't in the tree, we get it's
-             * predecessor or tree.end(). If key is
-             * in the tree, we get it. So unless it
-             * is equal to end(), we keep incrementing
-             * until we get to the next key.
-             */
-            auto it = lower_bound(tree, key);
-            if (it == tree.end())
-                return it;
-            else if (tree.keys_equal(tree.get_key(*it), key))
-            {
-                while (it != tree.end() && tree.keys_equal(tree.get_key(*it), key))
-                    ++it;
-
-                return it;
-            }
-
-            return it;
-        }
-
-        template<class Tree, class Key>
-        static pair<
-            typename Tree::iterator,
-            typename Tree::iterator
-        > equal_range(const Tree& tree, const Key& key)
-        {
-            return make_pair(
-                lower_bound(tree, key),
-                upper_bound(tree, key)
-            );
-        }
-
-        template<class Tree, class Key>
-        static pair<
-            typename Tree::const_iterator,
-            typename Tree::const_iterator
-        > equal_range_const(const Tree& tree, const Key& key)
-        {
-            return make_pair(
-                lower_bound_const(tree, key),
-                upper_bound_const(tree, key)
-            );
-        }
-
-        template<class Tree, class... Args>
-        static typename Tree::iterator emplace(Tree& tree, Args&&... args)
-        {
-            using node_type  = typename Tree::node_type;
-
-            auto node = new node_type{forward<Args>(args)...};
-
-            return insert(tree, node);
-        }
-
-        template<class Tree, class Value>
-        static typename Tree::iterator insert(Tree& tree, const Value& val)
-        {
-            using node_type = typename Tree::node_type;
-
-            auto node = new node_type{val};
-
-            return insert(tree, node);
-        }
-
-        template<class Tree, class Value>
-        static typename Tree::iterator insert(Tree& tree, Value&& val)
-        {
-            using node_type = typename Tree::node_type;
-
-            auto node = new node_type{forward<Value>(val)};
-
-            return insert(tree, node);
-        }
-
-        template<class Tree>
-        static typename Tree::iterator insert(
-            Tree& tree, typename Tree::node_type* node,
-            typename Tree::node_type* = nullptr
-        )
-        {
-            using iterator  = typename Tree::iterator;
-
-            if (!node)
-                return tree.end();
-
-            auto parent = tree.find_parent_for_insertion(tree.get_key(node->value));
-
-            ++tree.size_;
-            if (!parent)
-            {
-                node->color = rbcolor::black;
-                tree.root_ = node;
-            }
-            else
-            {
-                if (tree.keys_comp(tree.get_key(node->value), parent->value))
-                    parent->add_left_child(node);
-                else if (tree.keys_comp(tree.get_key(parent->value), node->value))
-                    parent->add_right_child(node);
-                else
-                {
-                    parent->add(node); // List of nodes with equivalent keys.
-                    tree.update_root_(parent);
-
-                    return iterator{node, false};
-                }
-
-                tree.repair_after_insert_(node);
-                tree.update_root_(node);
-            }
-
-            return iterator{node, false};
-        }
-    };
-}
-
-#endif
-
Index: pace/lib/cpp/include/internal/result_of.hpp
===================================================================
--- uspace/lib/cpp/include/internal/result_of.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,57 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_RESULT_OF
-#define LIBCPP_INTERNAL_RESULT_OF
-
-#include <internal/invoke.hpp>
-
-namespace std
-{
-    /**
-     * Note: This doesn't work, C++14 standard allows for F
-     *       to be any complete type, our implementation
-     *       currently works like the C++11 version where
-     *       F has to be callable.
-     * TODO: Fix this.
-     */
-
-    template<class>
-    struct result_of;
-
-    template<class F, class... Args>
-    class result_of<F(Args...)>: aux::type_is<
-        decltype(aux::invoke(declval<F>(), declval<ArgTypes>()...))
-    >
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    using result_of_t = typename result_of<T>::type;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/streambufs.hpp
===================================================================
--- uspace/lib/cpp/include/internal/streambufs.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,171 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_STREAMBUFS
-#define LIBCPP_STREAMBUFS
-
-#include <iosfwd>
-#include <cstdio>
-#include <streambuf>
-
-namespace std::aux
-{
-    template<class Char, class Traits = char_traits<Char>>
-    class stdin_streambuf : public basic_streambuf<Char, Traits>
-    {
-        public:
-            stdin_streambuf()
-                : basic_streambuf<Char, Traits>{}, buffer_{nullptr}
-            { /* DUMMY BODY */ }
-
-            virtual ~stdin_streambuf()
-            {
-                if (buffer_)
-                    delete[] buffer_;
-            }
-
-        protected:
-            using traits_type = Traits;
-            using char_type   = typename traits_type::char_type;
-            using int_type    = typename traits_type::int_type;
-            using off_type    = typename traits_type::off_type;
-
-            using basic_streambuf<Char, Traits>::input_begin_;
-            using basic_streambuf<Char, Traits>::input_next_;
-            using basic_streambuf<Char, Traits>::input_end_;
-
-            int_type underflow() override
-            {
-                if (!this->gptr())
-                {
-                    buffer_ = new char_type[buf_size_];
-                    input_begin_ = input_next_ = input_end_ = buffer_;
-                }
-
-                off_type i{};
-                if (input_next_ < input_end_)
-                {
-                    auto idx = static_cast<off_type>(input_next_ - input_begin_);
-                    auto count = buf_size_ - idx;
-
-                    for (; i < count; ++i, ++idx)
-                        buffer_[i] = buffer_[idx];
-                }
-
-                for (; i < buf_size_; ++i)
-                {
-                    auto c = fgetc(in_);
-                    putchar(c); // TODO: Temporary source of feedback.
-                    if (c == traits_type::eof())
-                        break;
-
-                    buffer_[i] = static_cast<char_type>(c);
-
-                    if (buffer_[i] == '\n')
-                    {
-                        ++i;
-                        break;
-                    }
-                }
-
-                input_next_ = input_begin_;
-                input_end_ = input_begin_ + i;
-
-                if (i == 0)
-                    return traits_type::eof();
-
-                return traits_type::to_int_type(*input_next_);
-            }
-
-            int_type uflow() override
-            {
-                auto res = underflow();
-                ++input_next_;
-
-                return res;
-            }
-
-            void imbue(const locale& loc)
-            {
-                this->locale_ = loc;
-            }
-
-        private:
-            FILE* in_{stdin};
-
-            char_type* buffer_;
-
-            static constexpr off_type buf_size_{128};
-    };
-
-    template<class Char, class Traits = char_traits<Char>>
-    class stdout_streambuf: public basic_streambuf<Char, Traits>
-    {
-        public:
-            stdout_streambuf()
-                : basic_streambuf<Char, Traits>{}
-            { /* DUMMY BODY */ }
-
-            virtual ~stdout_streambuf()
-            { /* DUMMY BODY */ }
-
-        protected:
-            using traits_type = Traits;
-            using char_type   = typename traits_type::char_type;
-            using int_type    = typename traits_type::int_type;
-            using off_type    = typename traits_type::off_type;
-
-            int_type overflow(int_type c = traits_type::eof()) override
-            {
-                if (!traits_type::eq_int_type(c, traits_type::eof()))
-                {
-                    auto cc = traits_type::to_char_type(c);
-                    fwrite(&cc, sizeof(char_type), 1, out_);
-                }
-
-                return traits_type::not_eof(c);
-            }
-
-            streamsize xsputn(const char_type* s, streamsize n) override
-            {
-                return fwrite(s, sizeof(char_type), n, out_);
-            }
-
-            int sync() override
-            {
-                if (fflush(out_))
-                    return -1;
-                return 0;
-            }
-
-        private:
-            FILE* out_{stdout};
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/string.hpp
===================================================================
--- uspace/lib/cpp/include/internal/string.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,192 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_STRING
-#define LIBCPP_INTERNAL_STRING
-
-#include <ios>
-#include <string>
-
-namespace std
-{
-    /**
-     * 21.4.8.9, inserters and extractors:
-     */
-
-    template<class Char, class Traits, class Allocator>
-    basic_istream<Char, Traits>& operator>>(basic_istream<Char, Traits>& is,
-                                            basic_string<Char, Traits, Allocator>& str)
-    {
-        using sentry = typename basic_istream<Char, Traits>::sentry;
-        sentry sen{is, false};
-
-        if (sen)
-        {
-            str.erase();
-
-            auto max_size = is.width();
-            if (max_size <= 0)
-                max_size = static_cast<streamsize>(str.max_size());
-
-            streamsize i{};
-            for(; i < max_size; ++i)
-            {
-                auto ic = is.rdbuf()->sgetc();
-                if (Traits::eq_int_type(ic, Traits::eof()))
-                {
-                    is.setstate(ios_base::eofbit);
-                    break;
-                }
-
-                auto c = Traits::to_char_type(ic);
-                if(isspace(c, is.getloc()))
-                    break;
-
-                str.push_back(c);
-                is.rdbuf()->sbumpc();
-            }
-
-            if (i == 0)
-                is.setstate(ios_base::failbit);
-        }
-        else
-            is.setstate(ios_base::failbit);
-
-        return is;
-    }
-
-    template<class Char, class Traits, class Allocator>
-    basic_ostream<Char, Traits>& operator<<(basic_ostream<Char, Traits>& os,
-                                            const basic_string<Char, Traits, Allocator>& str)
-    {
-        // TODO: determine padding as described in 27.7.3.6.1
-        using sentry = typename basic_ostream<Char, Traits>::sentry;
-        sentry sen{os};
-
-        if (sen)
-        {
-            auto width = os.width();
-            auto size = str.size();
-
-            size_t to_pad{};
-            if (width > 0)
-                to_pad = (static_cast<size_t>(width) - size);
-
-            if (to_pad > 0)
-            {
-                if ((os.flags() & ios_base::adjustfield) != ios_base::left)
-                {
-                    for (std::size_t i = 0; i < to_pad; ++i)
-                        os.put(os.fill());
-                }
-
-                os.rdbuf()->sputn(str.data(), size);
-
-                if ((os.flags() & ios_base::adjustfield) == ios_base::left)
-                {
-                    for (std::size_t i = 0; i < to_pad; ++i)
-                        os.put(os.fill());
-                }
-            }
-            else
-                os.rdbuf()->sputn(str.data(), size);
-
-            os.width(0);
-        }
-
-        return os;
-    }
-
-    template<class Char, class Traits, class Allocator>
-    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>& is,
-                                         basic_string<Char, Traits, Allocator>& str,
-                                         Char delim)
-    {
-        typename basic_istream<Char, Traits>::sentry sen{is, true};
-
-        if (sen)
-        {
-            str.clear();
-            streamsize count{};
-
-            while (true)
-            {
-                auto ic = is.rdbuf()->sbumpc();
-                if (Traits::eq_int_type(ic, Traits::eof()))
-                {
-                    is.setstate(ios_base::eofbit);
-                    break;
-                }
-
-                auto c = Traits::to_char_type(ic);
-                if (Traits::eq(c, delim))
-                    break;
-
-                str.push_back(c);
-                ++count;
-
-                if (count >= static_cast<streamsize>(str.max_size()))
-                {
-                    is.setstate(ios_base::failbit);
-                    break;
-                }
-            }
-
-            if (count == 0)
-                is.setstate(ios_base::failbit);
-        }
-        else
-            is.setstate(ios_base::failbit);
-
-        return is;
-    }
-
-    template<class Char, class Traits, class Allocator>
-    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>&& is,
-                                         basic_string<Char, Traits, Allocator>& str,
-                                         Char delim)
-    {
-        return getline(is, str, delim);
-    }
-
-    template<class Char, class Traits, class Allocator>
-    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>& is,
-                                         basic_string<Char, Traits, Allocator>& str)
-    {
-        return getline(is, str, is.widen('\n'));
-    }
-
-    template<class Char, class Traits, class Allocator>
-    basic_istream<Char, Traits>& getline(basic_istream<Char, Traits>&& is,
-                                         basic_string<Char, Traits, Allocator>& str)
-    {
-        return getline(is, str, is.widen('\n'));
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/stringfwd.hpp
===================================================================
--- uspace/lib/cpp/include/internal/stringfwd.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_STRINGFWD
-#define LIBCPP_INTERNAL_STRINGFWD
-
-namespace std
-{
-    template<class Char>
-    struct char_traits;
-
-    template<class T>
-    struct allocator;
-
-    template<
-        class Char,
-        class Traits = char_traits<Char>,
-        class Allocator = allocator<Char>
-    >
-    class basic_string;
-
-    using string  = basic_string<char>;
-    using wstring = basic_string<wchar_t>;
-
-}
-
-#endif
Index: pace/lib/cpp/include/internal/test/mock.hpp
===================================================================
--- uspace/lib/cpp/include/internal/test/mock.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,80 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_TEST_MOCK
-#define LIBCPP_INTERNAL_TEST_MOCK
-
-#include <cstdlib>
-#include <tuple>
-
-namespace std::test
-{
-    /**
-     * Auxiliary type that lets us to monitor the number
-     * of calls to various functions for the purposes
-     * of testing smart pointers and other features of
-     * the library.
-     */
-    struct mock
-    {
-        static size_t constructor_calls;
-        static size_t copy_constructor_calls;
-        static size_t destructor_calls;
-        static size_t move_constructor_calls;
-
-        mock()
-        {
-            ++constructor_calls;
-        }
-
-        mock(const mock&)
-        {
-            ++copy_constructor_calls;
-        }
-
-        mock(mock&&)
-        {
-            ++move_constructor_calls;
-        }
-
-        ~mock()
-        {
-            ++destructor_calls;
-        }
-
-        static void clear()
-        {
-            constructor_calls = size_t{};
-            copy_constructor_calls = size_t{};
-            destructor_calls = size_t{};
-            move_constructor_calls = size_t{};
-        }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/test/test.hpp
===================================================================
--- uspace/lib/cpp/include/internal/test/test.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,167 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_TEST_TEST
-#define LIBCPP_TEST_TEST
-
-#include <utility>
-#include <iterator>
-#include <type_traits>
-
-namespace std::test
-{
-    class test_suite
-    {
-        public:
-            virtual bool run(bool) = 0;
-            virtual const char* name() = 0;
-
-            virtual ~test_suite() = default;
-
-            unsigned int get_failed() const noexcept;
-
-            unsigned int get_succeeded() const noexcept;
-
-        protected:
-            void report(bool, const char*);
-            void start();
-            bool end();
-
-            unsigned int failed_{};
-            unsigned int succeeded_{};
-            bool ok_{true};
-            bool report_{true};
-
-            template<class... Args>
-            void test_eq(const char* tname, Args&&... args)
-            {
-                if (!assert_eq(std::forward<Args>(args)...))
-                {
-                    report(false, tname);
-                    ++failed_;
-                    ok_ = false;
-                }
-                else
-                {
-                    report(true, tname);
-                    ++succeeded_;
-                }
-            }
-
-            template<class T, class U>
-            bool assert_eq(const T& lhs, const U& rhs)
-            {
-                return lhs == rhs;
-            }
-
-            template<class Iterator1, class Iterator2>
-            bool assert_eq(Iterator1 first1, Iterator1 last1,
-                           Iterator2 first2, Iterator2 last2)
-            {
-                auto len1 = std::distance(first1, last1);
-                auto len2 = std::distance(first2, last2);
-
-                using common_t = std::common_type_t<decltype(len1), decltype(len2)>;
-                auto len1_common = static_cast<common_t>(len1);
-                auto len2_common = static_cast<common_t>(len2);
-
-                if (len1_common != len2_common)
-                    return false;
-
-                while (first1 != last1)
-                {
-                    if (*first1++ != *first2++)
-                        return false;
-                }
-
-                return true;
-            }
-
-            template<class Iterator, class Container>
-            void test_contains(const char* tname, Iterator first,
-                               Iterator last, const Container& cont)
-            {
-                if (!assert_contains(first, last, cont))
-                {
-                    report(false, tname);
-                    ++failed_;
-                    ok_ = false;
-                }
-                else
-                {
-                    report(true, tname);
-                    ++succeeded_;
-                }
-            }
-
-            template<class Iterator1, class Iterator2, class Container>
-            void test_contains_multi(const char* tname, Iterator1 first1,
-                               Iterator1 last1, Iterator2 first2,
-                               const Container& cont)
-            {
-                if (!assert_contains_multi(first1, last1, first2, cont))
-                {
-                    report(false, tname);
-                    ++failed_;
-                    ok_ = false;
-                }
-                else
-                {
-                    report(true, tname);
-                    ++succeeded_;
-                }
-            }
-
-            template<class Iterator, class Container>
-            bool assert_contains(Iterator first, Iterator last, const Container& cont)
-            {
-                while (first != last)
-                {
-                    if (cont.find(*first++) == cont.end())
-                        return false;
-                }
-
-                return true;
-            }
-
-            template<class Iterator1, class Iterator2, class Container>
-            bool assert_contains_multi(Iterator1 first1, Iterator1 last1,
-                                       Iterator2 first2, const Container& cont)
-            {
-                while (first1 != last1)
-                {
-                    if (cont.count(*first1++) != *first2++)
-                        return false;
-                }
-
-                return true;
-            }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/test/tests.hpp
===================================================================
--- uspace/lib/cpp/include/internal/test/tests.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,261 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_TESTS
-#define LIBCPP_TESTS
-
-#include <cstdio>
-#include <internal/test/test.hpp>
-#include <vector>
-
-namespace std::test
-{
-    class test_set
-    {
-        public:
-            test_set() = default;
-
-            template<class T>
-            void add()
-            {
-                tests_.push_back(new T{});
-            }
-
-            bool run(bool report)
-            {
-                bool res{true};
-                unsigned int succeeded{};
-                unsigned int failed{};
-
-                for (auto test: tests_)
-                {
-                    res &= test->run(report);
-                    succeeded += test->get_succeeded();
-                    failed += test->get_failed();
-                }
-
-                if (report)
-                {
-                    std::printf("\n");
-                    if (res)
-                        std::printf("[TESTS SUCCEEDED!]");
-                    else
-                        std::printf("[TESTS FAILED]");
-                    std::printf("[%u OK][%u FAIL][%u TOTAL]\n",
-                                succeeded, failed, (succeeded + failed));
-                }
-
-                return res;
-            }
-
-            ~test_set()
-            {
-                // TODO: Gimme unique_ptr!
-                for (auto ptr: tests_)
-                    delete ptr;
-            }
-        private:
-            std::vector<test_suite*> tests_{};
-    };
-
-    class array_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-            array_test() = default;
-            ~array_test() = default;
-    };
-
-    class vector_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-            vector_test() = default;
-            ~vector_test() = default;
-
-        private:
-            void test_construction_and_assignment();
-            void test_insert();
-            void test_erase();
-    };
-
-    class string_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_construction_and_assignment();
-            void test_append();
-            void test_insert();
-            void test_erase();
-            void test_replace();
-            void test_copy();
-            void test_find();
-            void test_substr();
-            void test_compare();
-    };
-
-    class bitset_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_constructors_and_assignment();
-            void test_strings();
-            void test_operations();
-    };
-
-    class deque_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_constructors_and_assignment();
-            void test_resizing();
-            void test_push_pop();
-            void test_operations();
-    };
-
-    class tuple_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_constructors_and_assignment();
-            void test_creation();
-            void test_tie_and_structured_bindings();
-            void test_tuple_ops();
-    };
-
-    class map_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_constructors_and_assignment();
-            void test_histogram();
-            void test_emplace_insert();
-            void test_bounds_and_ranges();
-            void test_multi();
-            void test_reverse_iterators();
-            void test_multi_bounds_and_ranges();
-    };
-
-    class set_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_constructors_and_assignment();
-            void test_emplace_insert();
-            void test_bounds_and_ranges();
-            void test_multi();
-            void test_reverse_iterators();
-            void test_multi_bounds_and_ranges();
-    };
-
-    class unordered_map_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_constructors_and_assignment();
-            void test_histogram();
-            void test_emplace_insert();
-            void test_multi();
-    };
-
-    class unordered_set_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_constructors_and_assignment();
-            void test_emplace_insert();
-            void test_multi();
-    };
-
-    class numeric_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_algorithms();
-            void test_complex();
-    };
-
-    class adaptors_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_queue();
-            void test_priority_queue();
-            void test_stack();
-    };
-
-    class memory_test: public test_suite
-    {
-        public:
-            bool run(bool) override;
-            const char* name() override;
-
-        private:
-            void test_unique_ptr();
-            void test_shared_ptr();
-            void test_weak_ptr();
-            void test_allocators();
-            void test_pointers();
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/thread.hpp
===================================================================
--- uspace/lib/cpp/include/internal/thread.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,233 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_THREAD
-#define LIBCPP_INTERNAL_THREAD
-
-namespace std::hel
-{
-    extern "C" {
-        #include <fibril.h>
-        #include <fibril_synch.h>
-    }
-}
-
-#include <chrono>
-
-namespace std::aux
-{
-    struct fibril_tag
-    { /* DUMMY BODY */ };
-
-    struct thread_tag
-    { /* DUMMY BODY */ };
-
-    template<class>
-    struct threading_policy;
-
-    template<>
-    struct threading_policy<fibril_tag>
-    {
-        using mutex_type        = hel::fibril_mutex_t;
-        using thread_type       = hel::fid_t;
-        using condvar_type      = hel::fibril_condvar_t;
-        using time_unit         = hel::suseconds_t;
-        using shared_mutex_type = hel::fibril_rwlock_t;
-
-        struct thread
-        {
-            template<class Callable, class Payload>
-            static thread_type create(Callable clbl, Payload& pld)
-            {
-                return hel::fibril_create(clbl, (void*)&pld);
-            }
-
-            static void start(thread_type thr)
-            {
-                hel::fibril_add_ready(thr);
-            }
-
-            static thread_type this_thread()
-            {
-                return hel::fibril_get_id();
-            }
-
-            static void yield()
-            {
-                hel::fibril_yield();
-            }
-
-            /**
-             * Note: join & detach are performed at the C++
-             *       level at the moment, but eventually should
-             *       be moved here once joinable fibrils are in libc.
-             */
-        };
-
-        struct mutex
-        {
-            static void init(mutex_type& mtx)
-            {
-                hel::fibril_mutex_initialize(&mtx);
-            }
-
-            static void lock(mutex_type& mtx)
-            {
-                hel::fibril_mutex_lock(&mtx);
-            }
-
-            static void unlock(mutex_type& mtx)
-            {
-                hel::fibril_mutex_unlock(&mtx);
-            }
-
-            static bool try_lock(mutex_type& mtx)
-            {
-                return hel::fibril_mutex_trylock(&mtx);
-            }
-
-            static bool try_lock_for(mutex_type& mtx, time_unit timeout)
-            {
-                // TODO: we need fibril_mutex_trylock_for() :/
-                return try_lock(mtx);
-            }
-        };
-
-        struct condvar
-        {
-            static void init(condvar_type& cv)
-            {
-                hel::fibril_condvar_initialize(&cv);
-            }
-
-            static void wait(condvar_type& cv, mutex_type& mtx)
-            {
-                hel::fibril_condvar_wait(&cv, &mtx);
-            }
-
-            static int wait_for(condvar_type& cv, mutex_type& mtx, time_unit timeout)
-            {
-                return hel::fibril_condvar_wait_timeout(&cv, &mtx, timeout);
-            }
-
-            static void signal(condvar_type& cv)
-            {
-                hel::fibril_condvar_signal(&cv);
-            }
-
-            static void broadcast(condvar_type& cv)
-            {
-                hel::fibril_condvar_broadcast(&cv);
-            }
-        };
-
-        struct time
-        {
-            template<class Rep, class Period>
-            static time_unit convert(const std::chrono::duration<Rep, Period>& dur)
-            {
-                return std::chrono::duration_cast<std::chrono::duration<Rep, micro>>(dur).count();
-            }
-
-            static void sleep(time_unit time)
-            {
-                hel::fibril_usleep(time);
-            }
-        };
-
-        struct shared_mutex
-        {
-            static void init(shared_mutex_type& mtx)
-            {
-                hel::fibril_rwlock_initialize(&mtx);
-            }
-
-            static void lock(shared_mutex_type& mtx)
-            {
-                hel::fibril_rwlock_write_lock(&mtx);
-            }
-
-            static void unlock(shared_mutex_type& mtx)
-            {
-                hel::fibril_rwlock_write_unlock(&mtx);
-            }
-
-            static void lock_shared(shared_mutex_type& mtx)
-            {
-                hel::fibril_rwlock_read_lock(&mtx);
-            }
-
-            static void unlock_shared(shared_mutex_type& mtx)
-            {
-                hel::fibril_rwlock_read_unlock(&mtx);
-            }
-
-            static bool try_lock(shared_mutex_type& mtx)
-            {
-                // TODO: rwlocks don't have try locking capabilities
-                lock(mtx);
-
-                return true;
-            }
-
-            static bool try_lock_shared(shared_mutex_type& mtx)
-            {
-                lock(mtx);
-
-                return true;
-            }
-
-            static bool try_lock_for(shared_mutex_type& mtx, time_unit timeout)
-            {
-                return try_lock(mtx);
-            }
-
-            static bool try_lock_shared_for(shared_mutex_type& mtx, time_unit timeout)
-            {
-                return try_lock(mtx);
-            }
-        };
-    };
-
-    template<>
-    struct threading_policy<thread_tag>
-    {
-        // TODO:
-    };
-
-    using default_tag = fibril_tag;
-    using threading = threading_policy<default_tag>;
-
-    using thread_t       = typename threading::thread_type;
-    using mutex_t        = typename threading::mutex_type;
-    using condvar_t      = typename threading::condvar_type;
-    using time_unit_t    = typename threading::time_unit;
-    using shared_mutex_t = typename threading::shared_mutex_type;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/trycatch.hpp
===================================================================
--- uspace/lib/cpp/include/internal/trycatch.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,127 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_TRYCATCH
-#define LIBCPP_INTERNAL_TRYCATCH
-
-// TODO: This header should be included in every libcpp header.
-
-/**
- * For the time that exception support is not present
- * in HelenOS, we use mock macros in place of the keywords
- * try, throw and catch that allow us to atleast partially
- * mimic exception functionality (that is, without propagation
- * and stack unwinding).
- * The value of the macro below determines if the keyword
- * hiding macros get defined.
- */
-#define LIBCPP_EXCEPTIONS_SUPPORTED 0
-
-#if LIBCPP_EXCEPTIONS_SUPPORTED == 0
-
-namespace std
-{
-    /**
-     * In case the file where our macros get expanded
-     * does not include cstdlib.
-     */
-    extern "C" void abort(void) __attribute__((noreturn));
-    extern "C" int printf(const char*, ...);
-
-    namespace aux
-    {
-        /**
-         * Monitors the state of the program with
-         * regards to exceptions.
-         */
-        extern bool exception_thrown;
-
-        inline constexpr bool try_blocks_allowed{true};
-    }
-}
-
-/**
- * These macros allow us to choose how the program
- * should behave when an exception is thrown
- * (LIBCPP_EXCEPTION_HANDLE_THROW) or caught
- * (LIBCPP_EXCEPTION_HANDLE_CATCH).
- * We also provide three handlers that either
- * hang the program (allowing us to read the
- * message), exit the program (allowing us to
- * redirect the message to some output file and
- * end) or ignore the throw (in which case the
- * state of program will be broken, but since
- * we output messages on both and catch, this option
- * might allow us to see which catch statement
- * catches the "thrown exception" (supposing
- * the program doesn't crash before reaching
- * that statement.
- */
-#define LIBCPP_EXCEPTION_HANG         while (true);
-#define LIBCPP_EXCEPTION_ABORT        ::std::abort();
-#define LIBCPP_EXCEPTION_IGNORE       /* IGNORE */
-#define LIBCPP_EXCEPTION_HANDLE_THROW LIBCPP_EXCEPTION_IGNORE
-#define LIBCPP_EXCEPTION_HANDLE_CATCH LIBCPP_EXCEPTION_HANG
-
-#define try if constexpr (::std::aux::try_blocks_allowed)
-
-#define throw \
-    do {\
-        ::std::aux::exception_thrown = true; \
-        printf("[EXCEPTION] Thrown at %s:%d\n", __FILE__, __LINE__); \
-        LIBCPP_EXCEPTION_HANDLE_THROW \
-    } while (false);
-
-#define catch(expr) \
-    if (::std::aux::exception_thrown) \
-    { \
-        printf("[EXCEPTION] Caught < "#expr" > at %s:%d\n", __FILE__, __LINE__); \
-        ::std::aux::exception_thrown = false; \
-        LIBCPP_EXCEPTION_HANDLE_CATCH \
-    } \
-    if constexpr (false)
-
-/**
- * This macro can be used for testing the library. If
- * exception handling is not available, it uses the
- * internal bool variable and if it is, it uses a
- * universal catch clause in which it sets the passed
- * checking variable to true.
- */
-#define LIBCPP_EXCEPTION_THROW_CHECK(variable) \
-    variable = ::std::aux::exception_thrown
-
-#else
-#define LIBCPP_EXCEPTION_THROW_CHECK(variable) \
-    catch (...) \
-    { \
-        variable = true; \
-    }
-#endif
-
-#endif
Index: pace/lib/cpp/include/internal/tuple/tuple_cat.hpp
===================================================================
--- uspace/lib/cpp/include/internal/tuple/tuple_cat.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,172 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_TUPLE_TUPLE_CAT
-#define LIBCPP_INTERNAL_TUPLE_TUPLE_CAT
-
-#include <utility>
-
-namespace std
-{ // forward declarations
-    template<class... Ts>
-    struct tuple;
-
-    template<size_t I, class T>
-    struct tuple_element;
-
-    template<size_t I, class... Ts>
-    constexpr typename tuple_element<I, tuple<Ts...>>::type& get(tuple<Ts...>& tpl) noexcept;
-
-    template<class T, T...>
-    struct integer_sequence;
-
-    template<size_t... Is>
-    using index_sequence = integer_sequence<size_t, Is...>;
-}
-
-namespace std::aux
-{
-    template<class...>
-    struct tuple_append;
-
-    template<class... Ts, class... Us, class... Vs>
-    struct tuple_append<tuple<Ts...>, tuple<Us...>, Vs...>
-        : type_is<tuple<Ts..., Us...>>
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using tuple_append_t = typename tuple_append<Ts...>::type;
-
-    template<class...>
-    struct remove_first_tuple;
-
-    template<class... Ts, class... Tuples>
-    struct remove_first_tuple<tuple<Ts...>, Tuples...>
-        : type_is<Tuples...>
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using remove_first_tuple_t = typename remove_first_tuple<Ts...>::type;
-
-    template<class...>
-    struct get_first_tuple;
-
-    template<class... Ts, class... Tuples>
-    struct get_first_tuple<tuple<Ts...>, Tuples...>
-        : type_is<tuple<Ts...>>
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using get_first_tuple_t = typename get_first_tuple<Ts...>::type;
-
-    template<class...>
-    struct tuple_cat_type_impl;
-
-    template<class... Ts, class... Tuples>
-    struct tuple_cat_type_impl<tuple<Ts...>, Tuples...>
-        : type_is<
-        typename tuple_cat_type_impl<
-            tuple_append_t<tuple<Ts...>, get_first_tuple_t<Tuples...>>,
-            remove_first_tuple_t<Tuples...>
-        >::type
-    >
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using tuple_cat_type_impl_t = typename tuple_cat_type_impl<Ts...>::type;
-
-    template<class...>
-    struct tuple_cat_type;
-
-    template<class... Ts, class... Tuples>
-    struct tuple_cat_type<tuple<Ts...>, Tuples...>
-        : type_is<tuple_cat_type_impl_t<tuple<Ts...>, Tuples...>>
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using tuple_cat_type_t = typename tuple_cat_type<Ts...>::type;
-
-    template<class...>
-    struct concatenate_sequences;
-
-    template<size_t... Is1, size_t... Is2>
-    struct concatenate_sequences<index_sequence<Is1...>, index_sequence<Is2...>>
-        : type_is<index_sequence<Is1..., Is2...>>
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using concatenate_sequences_t = typename concatenate_sequences<Ts...>::type;
-
-    template<class...>
-    struct append_indices;
-
-    template<size_t... Is, class... Ts, class... Tuples>
-    struct append_indices<index_sequence<Is...>, tuple<Ts...>, Tuples...>
-        : append_indices<
-        concatenate_sequences_t<
-            index_sequence<Is...>, make_index_sequence<sizeof...(Ts)>
-        >,
-        Tuples...
-    >
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using append_indices_t = typename append_indices<Ts...>::types;
-
-    template<class...>
-    struct generate_indices;
-
-    template<class... Ts, class... Tuples>
-    struct generate_indices<tuple<Ts...>, Tuples...>
-        : type_is<
-        append_indices_t<
-            make_index_sequence<sizeof...(Ts)>,
-            Tuples...
-        >
-    >
-    { /* DUMMY BODY */ };
-
-    template<class... Ts>
-    using generate_indices_t = typename generate_indices<Ts...>::type;
-
-    template<class... Tuples, size_t... Is1, size_t... Is2>
-    tuple_cat_type_t<Tuples...> tuple_cat(Tuples&&... tpls,
-                                          index_sequence<Is1...>,
-                                          index_sequence<Is2...>)
-    {
-        return tuple_cat_type_t<Tuples...>{
-            get<Is1...>(
-                get<Is2...>(
-                    forward<Tuples>(tpls)
-                )
-            )...
-        };
-    }
-}
-
-#endif
Index: pace/lib/cpp/include/internal/tuple/tuple_ops.hpp
===================================================================
--- uspace/lib/cpp/include/internal/tuple/tuple_ops.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,124 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_TUPLE_TUPLE_OPS
-#define LIBCPP_INTERNAL_TUPLE_TUPLE_OPS
-
-#include <utility>
-
-namespace std
-{ // forward declarations
-    template<class... Ts>
-    struct tuple;
-
-    template<size_t I, class T>
-    struct tuple_element;
-
-    template<size_t I, class... Ts>
-    constexpr typename tuple_element<I, tuple<Ts...>>::type& get(tuple<Ts...>& tpl) noexcept;
-}
-
-namespace std::aux
-{
-    template<size_t I, size_t N>
-    struct tuple_ops
-    {
-        template<class T, class U>
-        static void assign_copy(T& lhs, const U& rhs)
-        {
-            get<I>(lhs) = get<I>(rhs);
-
-            tuple_ops<I + 1, N>::assign_copy(lhs, rhs);
-        }
-
-        template<class T, class U>
-        static void assign_move(T& lhs, U&& rhs)
-        {
-            get<I>(lhs) = move(get<I>(rhs));
-
-            tuple_ops<I + 1, N>::assign_move(lhs, move(rhs));
-        }
-
-        template<class T, class U>
-        static void swap(T& lhs, U& rhs)
-        {
-            std::swap(get<I>(lhs), get<I>(rhs));
-
-            tuple_ops<I + 1, N>::swap(lhs, rhs);
-        }
-
-        template<class T, class U>
-        static bool eq(const T& lhs, const U& rhs)
-        {
-            return (get<I>(lhs) == get<I>(rhs)) && tuple_ops<I + 1, N>::eq(lhs, rhs);
-        }
-
-        template<class T, class U>
-        static bool lt(const T& lhs, const U& rhs)
-        {
-            return (get<I>(lhs) < get<I>(rhs)) ||
-                (!(get<I>(rhs) < get<I>(lhs)) && tuple_ops<I + 1, N>::lt(lhs, rhs));
-        }
-    };
-
-    template<size_t N>
-    struct tuple_ops<N, N>
-    {
-        template<class T, class U>
-        static void assign_copy(T& lhs, const U& rhs)
-        {
-            get<N>(lhs) = get<N>(rhs);
-        }
-
-        template<class T, class U>
-        static void assign_move(T& lhs, U&& rhs)
-        {
-            get<N>(lhs) = move(get<N>(rhs));
-        }
-
-        template<class T, class U>
-        static void swap(T& lhs, U& rhs)
-        {
-            std::swap(get<N>(lhs), get<N>(rhs));
-        }
-
-        template<class T, class U>
-        static bool eq(const T& lhs, const U& rhs)
-        {
-            return get<N>(lhs) == get<N>(rhs);
-        }
-
-        template<class T, class U>
-        static bool lt(const T& lhs, const U& rhs)
-        {
-            return get<N>(lhs) < get<N>(rhs);
-        }
-    };
-}
-
-#endif
Index: pace/lib/cpp/include/internal/type_traits/references.hpp
===================================================================
--- uspace/lib/cpp/include/internal/type_traits/references.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_TYPE_TRAITS_REFERENCES
-#define LIBCPP_INTERNAL_TYPE_TRAITS_REFERENCES
-
-#include <internal/aux.hpp>
-
-namespace std
-{
-    /**
-     * 20.10.7.2, reference modifications:
-     */
-
-    template<class T>
-    struct remove_reference: aux::type_is<T>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct remove_reference<T&>: aux::type_is<T>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct remove_reference<T&&>: aux::type_is<T>
-    { /* DUMMY BODY */ };
-
-    // TODO: is this good?
-    template<class T>
-    struct add_lvalue_reference: aux::type_is<T&>
-    { /* DUMMY BODY */ };
-
-    // TODO: Special case when T is not referencable!
-    template<class T>
-    struct add_rvalue_reference: aux::type_is<T&&>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct add_rvalue_reference<T&>: aux::type_is<T&>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    using remove_reference_t = typename remove_reference<T>::type;
-
-    template<class T>
-    using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
-
-    template<class T>
-    using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/type_traits/result_of.hpp
===================================================================
--- uspace/lib/cpp/include/internal/type_traits/result_of.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,73 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_TYPE_TRAITS_RESULT_OF
-#define LIBCPP_INTERNAL_TYPE_TRAITS_RESULT_OF
-
-#include <internal/functional/invoke.hpp>
-
-namespace std
-{
-    template<class>
-    struct is_function;
-
-    template<class>
-    struct is_class;
-
-    template<class>
-    struct is_member_pointer;
-
-    template<bool, class>
-    struct enable_if;
-
-    template<class>
-    struct decay;
-
-    template<class>
-    struct remove_pointer;
-
-    template<class>
-    struct result_of
-    { /* DUMMY BODY */ };
-
-    template<class F, class... ArgTypes>
-    struct result_of<F(ArgTypes...)>: aux::type_is<
-        typename enable_if<
-            is_function<typename decay<typename remove_pointer<F>::type>::type>::value ||
-            is_class<typename decay<F>::type>::value ||
-            is_member_pointer<typename decay<F>::type>::value,
-            decltype(aux::invoke(declval<F>(), declval<ArgTypes>()...))
-        >::type
-    >
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    using result_of_t = typename result_of<T>::type;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/type_transformation.hpp
===================================================================
--- uspace/lib/cpp/include/internal/type_transformation.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,63 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_TYPE_TRANSFORMATION
-#define LIBCPP_INTERNAL_TYPE_TRANSFORMATION
-
-#include <internal/aux.hpp>
-#include <type_traits>
-
-namespace std
-{
-    template<class>
-    class reference_wrapper;
-}
-
-namespace std::aux
-{
-    /**
-     * Used by tuple to decay reference wrappers to references
-     * in make_tuple.
-     */
-
-    template<class T>
-    struct remove_reference_wrapper: type_is<T>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    struct remove_reference_wrapper<reference_wrapper<T>>: type_is<T&>
-    { /* DUMMY BODY */ };
-
-    template<class T>
-    using remove_reference_wrapper_t = typename remove_reference_wrapper<T>::type;
-
-    template<class T>
-    using transform_tuple_types_t = remove_reference_wrapper_t<decay_t<T>>;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/utility/declval.hpp
===================================================================
--- uspace/lib/cpp/include/internal/utility/declval.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_UTILITY_DECLVAL
-#define LIBCPP_INTERNAL_UTILITY_DECLVAL
-
-#include <internal/type_traits/references.hpp>
-
-namespace std
-{
-    /**
-     * 20.2.5, function template declval:
-     * Note: This function only needs declaration, not
-     *       implementation.
-     */
-
-    template<class T>
-    add_rvalue_reference_t<T> declval() noexcept;
-}
-
-#endif
Index: pace/lib/cpp/include/internal/utility/forward_move.hpp
===================================================================
--- uspace/lib/cpp/include/internal/utility/forward_move.hpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,59 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBCPP_INTERNAL_UTILITY_FORWARD_MOVE
-#define LIBCPP_INTERNAL_UTILITY_FORWARD_MOVE
-
-#include <internal/type_traits/references.hpp>
-
-namespace std
-{
-    /**
-     * 20.2.4, forward/move helpers:
-     */
-
-    template<class T>
-    constexpr T&& forward(remove_reference_t<T>& t) noexcept
-    {
-        return static_cast<T&&>(t);
-    }
-
-    template<class T>
-    constexpr T&& forward(remove_reference_t<T>&& t) noexcept
-    {
-        return static_cast<T&&>(t);
-    }
-
-    template<class T>
-    constexpr remove_reference_t<T>&& move(T&& t) noexcept
-    {
-        return static_cast<remove_reference_t<T>&&>(t);
-    }
-}
-
-#endif
Index: uspace/lib/cpp/include/memory
===================================================================
--- uspace/lib/cpp/include/memory	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/memory	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -27,11 +27,11 @@
  */
 
-#include <internal/memory/allocator_arg.hpp>
-#include <internal/memory/allocator_traits.hpp>
-#include <internal/memory/addressof.hpp>
-#include <internal/memory/misc.hpp>
-#include <internal/memory/owner_less.hpp>
-#include <internal/memory/pointer_traits.hpp>
-#include <internal/memory/shared_ptr.hpp>
-#include <internal/memory/unique_ptr.hpp>
-#include <internal/memory/weak_ptr.hpp>
+#include <__bits/memory/allocator_arg.hpp>
+#include <__bits/memory/allocator_traits.hpp>
+#include <__bits/memory/addressof.hpp>
+#include <__bits/memory/misc.hpp>
+#include <__bits/memory/owner_less.hpp>
+#include <__bits/memory/pointer_traits.hpp>
+#include <__bits/memory/shared_ptr.hpp>
+#include <__bits/memory/unique_ptr.hpp>
+#include <__bits/memory/weak_ptr.hpp>
Index: uspace/lib/cpp/include/string
===================================================================
--- uspace/lib/cpp/include/string	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/string	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -28,3 +28,3 @@
 
 #include <impl/string.hpp>
-#include <internal/string.hpp>
+#include <__bits/string.hpp>
Index: uspace/lib/cpp/include/type_traits
===================================================================
--- uspace/lib/cpp/include/type_traits	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/type_traits	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -28,4 +28,4 @@
 
 #include <impl/type_traits.hpp>
-#include <internal/type_traits/references.hpp>
-#include <internal/type_traits/result_of.hpp>
+#include <__bits/type_traits/references.hpp>
+#include <__bits/type_traits/result_of.hpp>
Index: uspace/lib/cpp/include/utility
===================================================================
--- uspace/lib/cpp/include/utility	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/include/utility	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -28,4 +28,4 @@
 
 #include <impl/utility.hpp>
-#include <internal/utility/declval.hpp>
-#include <internal/utility/forward_move.hpp>
+#include <__bits/utility/declval.hpp>
+#include <__bits/utility/forward_move.hpp>
Index: uspace/lib/cpp/src/__bits/runtime.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/runtime.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/runtime.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdlib>
+#include <cstdint>
+#include <__bits/abi.hpp>
+#include <exception>
+#include <mutex>
+
+namespace __cxxabiv1
+{
+    namespace aux
+    {
+        struct destructor_t
+        {
+            void (*func)(void*);
+            void* ptr;
+            void* dso;
+        };
+
+        destructor_t* destructors{nullptr};
+        std::size_t destructor_count{0};
+        std::size_t destructor_size{32};
+
+        /**
+         * C atexit does not pass any arguments,
+         * but __cxa_finalize requires one so we
+         * use a wrapper.
+         */
+        void atexit_destructors()
+        {
+            __cxa_finalize(nullptr);
+        }
+    }
+
+    /**
+     * No need for a body, this function is called when a virtual
+     * call of a pure virtual function cannot be made.
+     */
+    extern "C" void __cxa_pure_call()
+    {
+        std::terminate();
+    }
+
+    extern "C" int __cxa_atexit(void (*f)(void*), void* p, void* d)
+    {
+        if (!aux::destructors)
+        {
+            aux::destructors = new aux::destructor_t[aux::destructor_size];
+            std::atexit(aux::atexit_destructors);
+        }
+        else if (aux::destructor_count >= aux::destructor_size)
+        {
+            auto tmp = std::realloc(aux::destructors, aux::destructor_size * 2);
+
+            if (!tmp)
+                return -1;
+
+            aux::destructors = static_cast<aux::destructor_t*>(tmp);
+            aux::destructor_size *= 2;
+        }
+
+        auto& destr = aux::destructors[aux::destructor_count++];
+        destr.func = f;
+        destr.ptr = p;
+        destr.dso = d;
+
+        return 0;
+    }
+
+    extern "C" void __cxa_finalize(void *f)
+    {
+        if (!f)
+        {
+            for (std::size_t i = aux::destructor_count; i > 0; --i)
+            {
+                if (aux::destructors[i - 1].func)
+                    (*aux::destructors[i - 1].func)(aux::destructors[i - 1].ptr);
+            }
+        }
+        else
+        {
+            for (std::size_t i = aux::destructor_count; i > 0; --i)
+            {
+                if (aux::destructors[i - 1].func == f)
+                {
+                    (*aux::destructors[i - 1].func)(aux::destructors[i - 1].ptr);
+                    aux::destructors[i - 1].func = nullptr;
+                    aux::destructors[i - 1].ptr = nullptr;
+                    aux::destructors[i - 1].dso = nullptr;
+                    // TODO: shift and decrement count
+                }
+            }
+        }
+    }
+
+    using guard_t = std::uint64_t;
+    std::mutex static_guard_mtx{};
+
+    extern "C" int __cxa_guard_acquire(guard_t* guard)
+    {
+        static_guard_mtx.lock();
+
+        return !*((std::uint8_t*)guard);
+    }
+
+    extern "C" void __cxa_guard_release(guard_t* guard)
+    {
+        *((std::uint8_t*)guard) = 1;
+
+        static_guard_mtx.unlock();
+    }
+
+    extern "C" void __cxa_guard_abort(guard_t* guard)
+    {
+        static_guard_mtx.unlock();
+    }
+
+    __fundamental_type_info::~__fundamental_type_info()
+    { /* DUMMY BODY */ }
+
+    __array_type_info::~__array_type_info()
+    { /* DUMMY BODY */ }
+
+    __function_type_info::~__function_type_info()
+    { /* DUMMY BODY */ }
+
+    __enum_type_info::~__enum_type_info()
+    { /* DUMMY BODY */ }
+
+    __class_type_info::~__class_type_info()
+    { /* DUMMY BODY */ }
+
+    __si_class_type_info::~__si_class_type_info()
+    { /* DUMMY BODY */ }
+
+    __vmi_class_type_info::~__vmi_class_type_info()
+    { /* DUMMY BODY */ }
+
+    __pbase_type_info::~__pbase_type_info()
+    { /* DUMMY BODY */ }
+
+    __pointer_type_info::~__pointer_type_info()
+    { /* DUMMY BODY */ }
+
+    __pointer_to_member_type_info::~__pointer_to_member_type_info()
+    { /* DUMMY BODY */ }
+
+    /**
+     * This structure represents part of the vtable segment
+     * that contains data related to dynamic_cast.
+     */
+    struct vtable
+    {
+        // Unimportant to us.
+
+        std::ptrdiff_t offset_to_top;
+        std::type_info* tinfo;
+
+        // Actual vtable.
+    };
+    extern "C" void* __dynamic_cast(const void* sub, const __class_type_info* src,
+                                    const __class_type_info* dst, std::ptrdiff_t offset)
+    {
+        // TODO: implement
+        // NOTE: as far as I understand it, we get vtable prefix from sub, get the type_info
+        //       ptr from that and then climb the inheritance hierarchy upwards till we either
+        //       fint dst or fail and return nullptr
+        return nullptr;
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/adaptors.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/adaptors.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/adaptors.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdlib>
+#include <deque>
+#include <functional>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <iterator>
+#include <queue>
+#include <stack>
+#include <vector>
+
+namespace std::test
+{
+    namespace aux
+    {
+        template<class T, class Comp = std::less<T>>
+        class priority_queue_iterator
+        {
+            public:
+                using value_type      = T;
+                using reference       = const T&;
+                using size_type       = size_t;
+                using pointer         = value_type*;
+                using difference_type = size_t;
+
+                using iterator_category = forward_iterator_tag;
+
+                priority_queue_iterator(
+                    priority_queue<value_type, std::vector<value_type>, Comp> q,
+                    bool end = false
+                )
+                    : queue_{q}, end_{end}
+                { /* DUMMY BODY */ }
+
+                priority_queue_iterator(const priority_queue_iterator& other)
+                    : queue_{other.queue_}, end_{other.end_}
+                { /* DUMMY BODY */ }
+
+                reference operator*()
+                {
+                    return queue_.top();
+                }
+
+                priority_queue_iterator& operator++()
+                {
+                    queue_.pop();
+
+                    if (queue_.empty())
+                        end_ = true;
+
+                    return *this;
+                }
+
+                priority_queue_iterator operator++(int)
+                {
+                    auto old = *this;
+                    ++(*this);
+
+                    return old;
+                }
+
+                bool operator==(const priority_queue_iterator& rhs) const
+                {
+                    return end_ == rhs.end_;
+                }
+
+                bool operator!=(const priority_queue_iterator& rhs) const
+                {
+                    return !(*this == rhs);
+                }
+
+            private:
+                priority_queue<value_type, std::vector<value_type>, Comp> queue_;
+                bool end_;
+        };
+    }
+
+    bool adaptors_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_queue();
+        test_priority_queue();
+        test_stack();
+
+        return end();
+    }
+
+    const char* adaptors_test::name()
+    {
+        return "adaptors";
+    }
+
+    void adaptors_test::test_queue()
+    {
+        std::queue<int> q{std::deque<int>{1}};
+
+        test_eq("queue initialized from deque not empty", q.empty(), false);
+        test_eq("queue initialized form queue size", q.size(), 1U);
+        test_eq("single element queue front == back", q.front(), q.back());
+
+        q.push(2);
+        test_eq("queue push", q.back(), 2);
+        test_eq("queue size", q.size(), 2U);
+
+        q.pop();
+        test_eq("queue pop", q.front(), 2);
+
+        q.emplace(4);
+        test_eq("queue emplace", q.back(), 4);
+    }
+
+    void adaptors_test::test_priority_queue()
+    {
+        auto check1 = {9, 8, 5, 4, 2, 1};
+        std::vector<int> data{5, 4, 2, 8, 1};
+        std::priority_queue<int> q1{data.begin(), data.end()};
+
+        test_eq("priority_queue initialized from iterator range not empty", q1.empty(), false);
+        test_eq("priority_queue initialized from iterator range size", q1.size(), 5U);
+
+        q1.push(9);
+        test_eq("priority_queue push pt1", q1.size(), 6U);
+        test_eq("priority_queue push pt2", q1.top(), 9);
+
+        test_eq(
+            "priority_queue initialized from iterator range ops",
+            check1.begin(), check1.end(),
+            aux::priority_queue_iterator<int>{q1},
+            aux::priority_queue_iterator<int>{q1, true}
+        );
+
+        auto check2 = {1, 2, 3, 4, 5, 8};
+        std::priority_queue<int, std::vector<int>, std::greater<int>> q2{std::greater<int>{}, data};
+
+        test_eq("priority_queue initialized from vector and compare not empty", q2.empty(), false);
+        test_eq("priority_queue initialized from vector and compare size", q2.size(), 5U);
+
+        q2.push(3);
+        test_eq("priority_queue push pt1", q2.size(), 6U);
+        test_eq("priority_queue push pt2", q2.top(), 1);
+
+        test_eq(
+            "priority_queue initialized from vector and compare ops",
+            check2.begin(), check2.end(),
+            aux::priority_queue_iterator<int, std::greater<int>>{q2},
+            aux::priority_queue_iterator<int, std::greater<int>>{q2, true}
+        );
+    }
+
+    void adaptors_test::test_stack()
+    {
+        std::stack<int> s{std::deque<int>{1}};
+
+        test_eq("stack initialized from deque top", s.top(), 1);
+        test_eq("stack initialized from deque size", s.size(), 1U);
+        test_eq("stack initialized from deque not empty", s.empty(), false);
+
+        s.push(2);
+        test_eq("stack push top", s.top(), 2);
+        test_eq("stack push size", s.size(), 2U);
+
+        s.pop();
+        test_eq("stack pop top", s.top(), 1);
+        test_eq("stack pop size", s.size(), 1U);
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/array.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/array.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/array.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <algorithm>
+#include <array>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+
+namespace std::test
+{
+    bool array_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        auto check1 = {1, 2, 3, 4};
+        auto check2 = {4, 3, 2, 1};
+        auto check3 = {5, 5, 5, 5};
+
+        std::array<int, 4> arr1{1, 2, 3, 4};
+        test_eq(
+            "initializer list construction",
+            arr1.begin(), arr1.end(),
+            check1.begin(), check1.end()
+        );
+
+        auto it = arr1.begin();
+        test_eq(
+            "iterator increment",
+            *(++it), arr1[1]
+        );
+        test_eq(
+            "iterator decrement",
+            *(--it), arr1[0]
+        );
+
+        std::array<int, 4> arr2{arr1};
+        test_eq(
+            "copy construction",
+            arr1.begin(), arr1.end(),
+            arr2.begin(), arr2.end()
+        );
+
+        std::reverse(arr2.begin(), arr2.end());
+        test_eq(
+            "reverse",
+            arr2.begin(), arr2.end(),
+            check2.begin(), check2.end()
+        );
+        test_eq(
+            "reverse iterator",
+            arr1.rbegin(), arr1.rend(),
+            arr2.begin(), arr2.end()
+        );
+
+
+        std::array<int, 4> arr3{};
+        arr3.fill(5);
+        test_eq(
+            "fill",
+            arr3.begin(), arr3.end(),
+            check3.begin(), check3.end()
+        );
+
+        arr2.swap(arr3);
+        test_eq(
+            "swap part 1",
+            arr2.begin(), arr2.end(),
+            check3.begin(), check3.end()
+        );
+        test_eq(
+            "swap part 2",
+            arr3.begin(), arr3.end(),
+            check2.begin(), check2.end()
+        );
+
+        // TODO: test bound checking of at when implemented
+
+        std::array<int, 3> arr4{1, 2, 3};
+        auto [a, b, c] = arr4;
+        test_eq("structured binding part 1", a, 1);
+        test_eq("structured binding part 2", b, 2);
+        test_eq("structured binding part 3", c, 3);
+
+        return end();
+    }
+
+    const char* array_test::name()
+    {
+        return "array";
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/bitset.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/bitset.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/bitset.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <bitset>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <sstream>
+#include <string>
+
+namespace std::test
+{
+    bool bitset_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_constructors_and_assignment();
+        test_strings();
+        test_operations();
+
+        return end();
+    }
+
+    const char* bitset_test::name()
+    {
+        return "bitset";
+    }
+
+    void bitset_test::test_constructors_and_assignment()
+    {
+        // 00101010bin == 42dec (note that the bits are reversed in bitset)
+        auto check1 = {false, true, false, true, false, true, false, false};
+        std::bitset<8> b1{42};
+        test_eq(
+            "from number to number equivalence",
+            b1.to_ulong(), 42UL
+        );
+
+        auto it = check1.begin();
+        size_t i{};
+        for (; i < 8U; ++i)
+        {
+            if (*it++ != b1[i])
+                break;
+        }
+        test_eq("from number iterating over bits", i, 8U);
+
+        std::bitset<8> b2{"00101010"};
+        test_eq(
+            "from string to number equivalence",
+            b2.to_ulong(), 42UL
+        );
+
+        it = check1.begin();
+        i = size_t{};
+        for (; i < 8U; ++i)
+        {
+            if (*it++ != b2[i])
+                break;
+        }
+        test_eq("from string iterating over bits", i, 8U);
+
+        std::bitset<16> b3{0b1111'1101'1011'1010};
+        test_eq(
+            "from binary to number equivalence",
+            b3.to_ulong(), 0b1111'1101'1011'1010UL
+        );
+
+        std::bitset<64> b4{0xABCD'DCBA'DEAD'BEEF};
+        test_eq(
+            "from hex to number equivalence",
+            b4.to_ulong(), 0xABCD'DCBA'DEAD'BEEF
+        );
+
+        std::bitset<8> b5{"XXYXYXYX", 8U, 'X', 'Y'};
+        test_eq(
+            "from string with different 0/1 values equivalence",
+            b5.to_ulong(), 42U
+        );
+
+        std::bitset<8> b6{"XXYXYXYXXXX IGNORED", 8U, 'X', 'Y'};
+        test_eq(
+            "from prefix string with different 0/1 values equivalence",
+            b6.to_ulong(), 42U
+        );
+
+        std::bitset<8> b7{std::string{"XXXXYXYXYX"}, 2U, 8U, 'X', 'Y'};
+        test_eq(
+            "from substring with different 0/1 values equivalence",
+            b7.to_ulong(), 42U
+        );
+    }
+
+    void bitset_test::test_strings()
+    {
+        std::bitset<8> b1{42};
+        auto s1 = b1.to_string();
+        test_eq(
+            "to string",
+            s1, "00101010"
+        );
+
+        auto s2 = b1.to_string('X', 'Y');
+        test_eq(
+            "to string string with different 0/1 values",
+            s2, "XXYXYXYX"
+        );
+
+        std::istringstream iss{"00101010"};
+        std::bitset<8> b2{};
+        iss >> b2;
+        test_eq(
+            "istream operator>>",
+            b2.to_ulong(), 42UL
+        );
+
+        std::ostringstream oss{};
+        oss << b2;
+        std::string s3{oss.str()};
+        std::string s4{"00101010"};
+        test_eq(
+            "ostream operator<<",
+            s3, s4
+        );
+    }
+
+    void bitset_test::test_operations()
+    {
+        std::bitset<8> b1{};
+
+        b1.set(3);
+        test_eq("set", b1[3], true);
+
+        b1.reset(3);
+        test_eq("reset", b1[3], false);
+
+        b1.flip(3);
+        test_eq("flip", b1[3], true);
+
+        b1 >>= 1;
+        test_eq("lshift new", b1[2], true);
+        test_eq("lshift old", b1[3], false);
+
+        b1 <<= 1;
+        test_eq("rshift new", b1[2], false);
+        test_eq("rshift old", b1[3], true);
+
+        test_eq("any1", b1.any(), true);
+        test_eq("none1", b1.none(), false);
+        test_eq("all1", b1.all(), false);
+
+        b1 <<= 7;
+        test_eq("any2", b1.any(), false);
+        test_eq("none2", b1.none(), true);
+        test_eq("all2", b1.all(), false);
+
+        b1.set();
+        test_eq("set + all", b1.all(), true);
+
+        b1.reset();
+        test_eq("reset + none", b1.none(), true);
+
+        std::bitset<8> b2{0b0101'0101};
+        std::bitset<8> b3{0b1010'1010};
+        b2.flip();
+        test_eq("flip all", b2, b3);
+
+        std::bitset<8> b4{0b0011'0101};
+        std::bitset<8> b5{0b1010'1100};
+        test_eq("and", (b4 & b5), std::bitset<8>{0b0010'0100});
+        test_eq("or", (b4 | b5), std::bitset<8>{0b1011'1101});
+        test_eq("count", b4.count(), 4U);
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/deque.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/deque.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/deque.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <deque>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <utility>
+
+namespace std::test
+{
+    bool deque_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_constructors_and_assignment();
+        test_resizing();
+        test_push_pop();
+        test_operations();
+
+        return end();
+    }
+
+    const char* deque_test::name()
+    {
+        return "deque";
+    }
+
+    void deque_test::test_constructors_and_assignment()
+    {
+        auto check1 = {0, 0, 0, 0, 0};
+        std::deque<int> d1(5U);
+        test_eq(
+            "size construction",
+            check1.begin(), check1.end(),
+            d1.begin(), d1.end()
+        );
+
+        auto check2 = {1, 1, 1, 1, 1};
+        std::deque<int> d2(5U, 1);
+        test_eq(
+            "value construction",
+            check2.begin(), check2.end(),
+            d2.begin(), d2.end()
+        );
+
+        auto check3 = {1, 2, 3, 4, 5};
+        std::deque<int> d3{check3.begin(), check3.end()};
+        test_eq(
+            "iterator range construction",
+            check3.begin(), check3.end(),
+            d3.begin(), d3.end()
+        );
+
+        std::deque<int> d4{d3};
+        test_eq(
+            "copy construction",
+            check3.begin(), check3.end(),
+            d4.begin(), d4.end()
+        );
+
+        std::deque<int> d5{std::move(d4)};
+        test_eq(
+            "move construction",
+            check3.begin(), check3.end(),
+            d5.begin(), d5.end()
+        );
+        test_eq("move construction - origin empty", d4.empty(), true);
+
+        std::deque<int> d6{check3};
+        test_eq(
+            "inializer list construction",
+            check3.begin(), check3.end(),
+            d6.begin(), d6.end()
+        );
+
+        d4 = d6;
+        test_eq(
+            "copy assignment",
+            check3.begin(), check3.end(),
+            d4.begin(), d4.end()
+        );
+
+        d6 = std::move(d4);
+        test_eq(
+            "move assignment",
+            check3.begin(), check3.end(),
+            d6.begin(), d6.end()
+        );
+        test_eq("move assignment - origin empty", d4.empty(), true);
+
+        d4 = check3;
+        test_eq(
+            "initializer list assignment",
+            check3.begin(), check3.end(),
+            d4.begin(), d4.end()
+        );
+
+        std::deque<int> d7{};
+        d7.assign(check3.begin(), check3.end());
+        test_eq(
+            "iterator range assign()",
+            check3.begin(), check3.end(),
+            d7.begin(), d7.end()
+        );
+
+        d7.assign(5U, 1);
+        test_eq(
+            "value assign()",
+            check2.begin(), check2.end(),
+            d7.begin(), d7.end()
+        );
+
+        d7.assign(check3);
+        test_eq(
+            "initializer list assign()",
+            check3.begin(), check3.end(),
+            d7.begin(), d7.end()
+        );
+    }
+
+    void deque_test::test_resizing()
+    {
+        auto check1 = {1, 2, 3};
+        auto check2 = {1, 2, 3, 0, 0};
+        std::deque<int> d1{1, 2, 3, 4, 5};
+
+        d1.resize(3U);
+        test_eq(
+            "downsize",
+            check1.begin(), check1.end(),
+            d1.begin(), d1.end()
+        );
+
+        d1.resize(5U);
+        test_eq(
+            "upsize",
+            check2.begin(), check2.end(),
+            d1.begin(), d1.end()
+        );
+
+        auto check3 = {1, 2, 3, 9, 9};
+        std::deque<int> d2{1, 2, 3, 4, 5};
+
+        d2.resize(3U, 9);
+        test_eq(
+            "downsize with default value",
+            check1.begin(), check1.end(),
+            d2.begin(), d2.end()
+        );
+
+        d2.resize(5U, 9);
+        test_eq(
+            "upsize with default value",
+            check3.begin(), check3.end(),
+            d2.begin(), d2.end()
+        );
+
+        d2.resize(0U);
+        test_eq("resize to 0", d2.empty(), true);
+    }
+
+    void deque_test::test_push_pop()
+    {
+        std::deque<int> d1{};
+
+        d1.push_back(42);
+        test_eq("push_back to empty equivalence", d1[0], 42);
+        test_eq("push_back to empty size", d1.size(), 1U);
+
+        d1.push_front(21);
+        test_eq("push_front after push_back equivalence", d1[0], 21);
+        test_eq("push_front after push_back size", d1.size(), 2U);
+
+        for (int i = 0; i <= 100; ++i)
+            d1.push_back(i);
+        test_eq("back after bucket test", d1.back(), 100);
+
+        d1.pop_back();
+        test_eq("back after pop_back", d1.back(), 99);
+        d1.pop_front();
+        test_eq("front after pop_front", d1.back(), 99);
+
+
+        for (int i = 0; i <= 100; ++i)
+            d1.push_front(i);
+        test_eq("front after bucket test", d1.front(), 100);
+
+        std::deque<int> d2{};
+
+        d2.push_front(42);
+        test_eq("push_front to empty equivalence", d2[0], 42);
+        test_eq("push_front to empty size", d2.size(), 1U);
+
+        d2.push_back(21);
+        test_eq("push_back after push_front equivalence", d2[1], 21);
+        test_eq("push_back after push_front size", d2.size(), 2U);
+
+        d2.clear();
+        test_eq("clear() - empty()", d2.empty(), true);
+        test_eq("clear() - iterators", d2.begin(), d2.end());
+    }
+
+    void deque_test::test_operations()
+    {
+        auto check1 = {
+            1, 2, 3, 4, 11, 22, 33, 44, 55, 66, 77, 88,
+            5, 6, 7, 8, 9, 10, 11, 12
+        };
+        auto to_insert = {11, 22, 33, 44, 55, 66, 77, 88};
+
+        std::deque<int> d1{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
+        std::deque<int> d2{d1};
+        std::deque<int> d3{d1};
+        std::deque<int> d4{d1};
+
+        d1.insert(d1.begin() + 5, to_insert.begin(), to_insert.end());
+        test_eq(
+            "insert iterator range",
+            check1.begin(), check1.end(),
+            d1.begin(), d1.end()
+        );
+
+        d2.insert(d2.begin() + 5, to_insert);
+        test_eq(
+            "insert initializer list",
+            check1.begin(), check1.end(),
+            d2.begin(), d2.end()
+        );
+
+        auto check2 = {
+            1, 2, 3, 4, 99, 99, 99, 99, 99, 99, 99, 99,
+            5, 6, 7, 8, 9, 10, 11, 12
+        };
+        d3.insert(d3.begin() + 5, 8U, 99);
+        test_eq(
+            "insert value n times",
+            check2.begin(), check2.end(),
+            d3.begin(), d3.end()
+        );
+
+        auto check3 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
+        d3.erase(d3.begin() + 4, d3.begin() + 12);
+        test_eq(
+            "erase iterator range",
+            check3.begin(), check3.end(),
+            d3.begin(), d3.end()
+        );
+
+        auto check4 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12};
+        d3.erase(d3.begin() + 10);
+        test_eq(
+            "erase",
+            check4.begin(), check4.end(),
+            d3.begin(), d3.end()
+        );
+
+        d2.swap(d3);
+        test_eq(
+            "swap1",
+            check1.begin(), check1.end(),
+            d3.begin(), d3.end()
+        );
+        test_eq(
+            "swap2",
+            check4.begin(), check4.end(),
+            d2.begin(), d2.end()
+        );
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/map.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/map.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/map.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <map>
+#include <string>
+#include <sstream>
+#include <utility>
+
+namespace std::test
+{
+    bool map_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_constructors_and_assignment();
+        test_histogram();
+        test_emplace_insert();
+        test_bounds_and_ranges();
+        test_multi();
+        test_reverse_iterators();
+        test_multi_bounds_and_ranges();
+
+        return end();
+    }
+
+    const char* map_test::name()
+    {
+        return "map";
+    }
+
+    void map_test::test_constructors_and_assignment()
+    {
+        auto check1 = {
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{4, 4},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{7, 7}
+        };
+        auto src1 = {
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{4, 4}
+        };
+
+        std::map<int, int> m1{src1};
+        test_eq(
+            "initializer list initialization",
+            check1.begin(), check1.end(),
+            m1.begin(), m1.end()
+        );
+        test_eq("size", m1.size(), 7U);
+
+        std::map<int, int> m2{src1.begin(), src1.end()};
+        test_eq(
+            "iterator range initialization",
+            check1.begin(), check1.end(),
+            m2.begin(), m2.end()
+        );
+
+        std::map<int, int> m3{m1};
+        test_eq(
+            "copy initialization",
+            check1.begin(), check1.end(),
+            m3.begin(), m3.end()
+        );
+
+        std::map<int, int> m4{std::move(m1)};
+        test_eq(
+            "move initialization",
+            check1.begin(), check1.end(),
+            m4.begin(), m4.end()
+        );
+        test_eq("move initialization - origin empty", m1.size(), 0U);
+        test_eq("empty", m1.empty(), true);
+
+        m1 = m4;
+        test_eq(
+            "copy assignment",
+            check1.begin(), check1.end(),
+            m1.begin(), m1.end()
+        );
+
+        m4 = std::move(m1);
+        test_eq(
+            "move assignment",
+            check1.begin(), check1.end(),
+            m4.begin(), m4.end()
+        );
+        test_eq("move assignment - origin empty", m1.size(), 0U);
+
+        m1 = src1;
+        test_eq(
+            "initializer list assignment",
+            check1.begin(), check1.end(),
+            m1.begin(), m1.end()
+        );
+    }
+
+    void map_test::test_histogram()
+    {
+        std::string str{"a b a a c d b e a b b e d c a e"};
+        std::map<std::string, std::size_t> map{};
+        std::istringstream iss{str};
+        std::string word{};
+
+        while (iss >> word)
+            ++map[word];
+
+        test_eq("histogram pt1", map["a"], 5U);
+        test_eq("histogram pt2", map["b"], 4U);
+        test_eq("histogram pt3", map["c"], 2U);
+        test_eq("histogram pt4", map["d"], 2U);
+        test_eq("histogram pt5", map["e"], 3U);
+        test_eq("histogram pt6", map["f"], 0U);
+        test_eq("at", map.at("a"), 5U);
+    }
+
+    void map_test::test_emplace_insert()
+    {
+        std::map<int, int> map1{};
+
+        auto res1 = map1.emplace(1, 2);
+        test_eq("first emplace succession", res1.second, true);
+        test_eq("first emplace equivalence pt1", res1.first->first, 1);
+        test_eq("first emplace equivalence pt2", res1.first->second, 2);
+
+        auto res2 = map1.emplace(1, 3);
+        test_eq("second emplace failure", res2.second, false);
+        test_eq("second emplace equivalence pt1", res2.first->first, 1);
+        test_eq("second emplace equivalence pt2", res2.first->second, 2);
+
+        auto res3 = map1.emplace_hint(map1.begin(), 2, 4);
+        test_eq("first emplace_hint succession", (res3 != map1.end()), true);
+        test_eq("first emplace_hint equivalence pt1", res3->first, 2);
+        test_eq("first emplace_hint equivalence pt2", res3->second, 4);
+
+        auto res4 = map1.emplace_hint(map1.begin(), 2, 5);
+        test_eq("second emplace_hint failure", (res4 != map1.end()), true);
+        test_eq("second emplace_hint equivalence pt1", res4->first, 2);
+        test_eq("second emplace_hint equivalence pt2", res4->second, 4);
+
+        std::map<int, std::string> map2{};
+        auto res5 = map2.insert(std::pair<const int, const char*>{5, "A"});
+        test_eq("conversion insert succession", res5.second, true);
+        test_eq("conversion insert equivalence pt1", res5.first->first, 5);
+        test_eq("conversion insert equivalence pt2", res5.first->second, std::string{"A"});
+
+        auto res6 = map2.insert(std::pair<const int, std::string>{6, "B"});
+        test_eq("first insert succession", res6.second, true);
+        test_eq("first insert equivalence pt1", res6.first->first, 6);
+        test_eq("first insert equivalence pt2", res6.first->second, std::string{"B"});
+
+        auto res7 = map2.insert(std::pair<const int, std::string>{6, "C"});
+        test_eq("second insert failure", res7.second, false);
+        test_eq("second insert equivalence pt1", res7.first->first, 6);
+        test_eq("second insert equivalence pt2", res7.first->second, std::string{"B"});
+
+        auto res8 = map2.insert_or_assign(6, std::string{"D"});
+        test_eq("insert_or_*assign* result", res8.second, false);
+        test_eq("insert_or_*assign* equivalence pt1", res8.first->first, 6);
+        test_eq("insert_or_*assign* equivalence pt2", res8.first->second, std::string{"D"});
+
+        auto res9 = map2.insert_or_assign(7, std::string{"E"});
+        test_eq("*insert*_or_assign result", res9.second, true);
+        test_eq("*insert*_or_assign equivalence pt1", res9.first->first, 7);
+        test_eq("*insert*_or_assign equivalence pt2", res9.first->second, std::string{"E"});
+
+        auto res10 = map2.erase(map2.find(7));
+        test_eq("erase", map2.find(7), map2.end());
+        test_eq("highest erased", res10, map2.end());
+
+        auto res11 = map2.erase(6);
+        test_eq("erase by key pt1", res11, 1U);
+        auto res12 = map2.erase(6);
+        test_eq("erase by key pt2", res12, 0U);
+
+        std::map<int, int> map3{};
+        map3[1] = 1;
+        auto res13 = map3.erase(1);
+        test_eq("erase root by key pt1", res13, 1U);
+        test_eq("erase root by key pt2", map3.empty(), true);
+
+        map3[2] = 2;
+        auto res14 = map3.erase(map3.begin());
+        test_eq("erase root by iterator pt1", res14, map3.end());
+        test_eq("erase root by iterator pt2", map3.empty(), true);
+
+        map2.clear();
+        test_eq("clear", map2.empty(), true);
+
+        map3[1] = 1;
+        auto res15 = map3.count(1);
+        test_eq("count", res15, 1U);
+    }
+
+    void map_test::test_bounds_and_ranges()
+    {
+        std::map<int, int> map{};
+        for (int i = 0; i < 10; ++i)
+            map[i] = i;
+        for (int i = 15; i < 20; ++i)
+            map[i] = i;
+
+        auto res1 = map.lower_bound(5);
+        test_eq("lower_bound of present key", res1->first, 5);
+
+        auto res2 = map.lower_bound(13);
+        test_eq("lower_bound of absent key", res2->first, 9);
+
+        auto res3 = map.upper_bound(7);
+        test_eq("upper_bound of present key", res3->first, 8);
+
+        auto res4 = map.upper_bound(12);
+        test_eq("upper_bound of absent key", res4->first, 15);
+
+        auto res5 = map.equal_range(4);
+        test_eq("equal_range of present key pt1", res5.first->first, 4);
+        test_eq("equal_range of present key pt2", res5.second->first, 5);
+
+        auto res6 = map.equal_range(14);
+        test_eq("equal_range of absent key pt1", res6.first->first, 9);
+        test_eq("equal_range of absent key pt2", res6.second->first, 15);
+    }
+
+    void map_test::test_multi()
+    {
+        auto check1 = {
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{4, 4},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{7, 7}
+        };
+        auto src1 = {
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{4, 4}
+        };
+
+        std::multimap<int, int> mmap{src1};
+        test_eq(
+            "multi construction",
+            check1.begin(), check1.end(),
+            mmap.begin(), mmap.end()
+        );
+
+        auto res1 = mmap.count(6);
+        test_eq("multi count", res1, 3U);
+
+        auto res2 = mmap.emplace(7, 2);
+        test_eq("multi duplicit emplace pt1", res2->first, 7);
+        test_eq("multi duplicit emplace pt2", res2->second, 2);
+        test_eq("multi duplicit emplace pt3", mmap.count(7), 2U);
+
+        auto res3 = mmap.emplace(8, 5);
+        test_eq("multi unique emplace pt1", res3->first, 8);
+        test_eq("multi unique emplace pt2", res3->second, 5);
+        test_eq("multi unique emplace pt3", mmap.count(8), 1U);
+
+        auto res4 = mmap.insert(std::pair<const int, int>{8, 6});
+        test_eq("multi duplicit insert pt1", res4->first, 8);
+        test_eq("multi duplicit insert pt2", res4->second, 6);
+        test_eq("multi duplicit insert pt3", mmap.count(8), 2U);
+
+        auto res5 = mmap.insert(std::pair<const int, int>{9, 8});
+        test_eq("multi unique insert pt1", res5->first, 9);
+        test_eq("multi unique insert pt2", res5->second, 8);
+        test_eq("multi unique insert pt3", mmap.count(9), 1U);
+
+        auto res6 = mmap.erase(8);
+        test_eq("multi erase by key pt1", res6, 2U);
+        test_eq("multi erase by key pt2", mmap.count(8), 0U);
+
+        auto res7 = mmap.erase(mmap.find(7));
+        test_eq("multi erase by iterator pt1", res7->first, 7);
+        test_eq("multi erase by iterator pt2", mmap.count(7), 1U);
+    }
+
+    void map_test::test_reverse_iterators()
+    {
+        auto check1 = {
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{4, 4},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{1, 1}
+        };
+        auto src1 = {
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{4, 4}
+        };
+
+        std::multimap<int, int> mmap{src1};
+        test_eq(
+            "multi reverse iterators",
+            check1.begin(), check1.end(),
+            mmap.rbegin(), mmap.rend()
+        );
+
+        auto check2 = {
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{4, 4},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{1, 1}
+        };
+        auto src2 = {
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{4, 4}
+        };
+
+        std::map<int, int> map{src2};
+        test_eq(
+            "reverse iterators",
+            check2.begin(), check2.end(),
+            map.rbegin(), map.rend()
+        );
+    }
+
+    void map_test::test_multi_bounds_and_ranges()
+    {
+        auto check1 = {
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{1, 2}
+        };
+        auto check2 = {
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{5, 6},
+            std::pair<const int, int>{5, 7}
+        };
+        auto check3 = {
+            std::pair<const int, int>{6, 6}
+        };
+        auto src = {
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{1, 2},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{5, 6},
+            std::pair<const int, int>{5, 7},
+            std::pair<const int, int>{6, 6}
+        };
+
+        std::multimap<int, int> mmap{src};
+        auto res1 = mmap.equal_range(1);
+        test_eq(
+            "multi equal_range at the start",
+            check1.begin(), check1.end(),
+            res1.first, res1.second
+        );
+
+        auto res2 = mmap.equal_range(5);
+        test_eq(
+            "multi equal_range in the middle",
+            check2.begin(), check2.end(),
+            res2.first, res2.second
+        );
+
+        auto res3 = mmap.equal_range(6);
+        test_eq(
+            "multi equal_range at the end + single element range",
+            check3.begin(), check3.end(),
+            res3.first, res3.second
+        );
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/memory.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/memory.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/memory.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <initializer_list>
+#include <__bits/test/mock.hpp>
+#include <__bits/test/tests.hpp>
+#include <memory>
+#include <type_traits>
+#include <utility>
+
+namespace std::test
+{
+    namespace aux
+    {
+        struct dummy_pointer1
+        {
+            using element_type    = int;
+            using difference_type = bool;
+
+            template<class U>
+            using rebind = unsigned;
+
+            int tag{};
+
+            static dummy_pointer1 pointer_to(element_type& x)
+            {
+                dummy_pointer1 res;
+                res.tag = x;
+                return res;
+            }
+        };
+
+        template<class T, class... Args>
+        struct dummy_pointer2
+        {
+            using element_type    = signed char;
+            using difference_type = unsigned char;
+        };
+
+        struct dummy_allocator1
+        {
+            using value_type = int;
+        };
+
+        struct dummy_allocator2
+        {
+            using value_type         = int;
+            using pointer            = char*;
+            using const_pointer      = const void*;
+            using void_pointer       = bool*;
+            using const_void_pointer = volatile bool*;
+            using difference_type    = short;
+            using size_type          = long;
+
+            using propagate_on_container_copy_assignment = std::true_type;
+            using propagate_on_container_move_assignment = std::true_type;
+            using propagate_on_container_swap            = std::true_type;
+            using is_always_equal                        = std::true_type;
+        };
+    }
+
+    bool memory_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_unique_ptr();
+        test_shared_ptr();
+        test_weak_ptr();
+        test_allocators();
+        test_pointers();
+
+        return end();
+    }
+
+    const char* memory_test::name()
+    {
+        return "memory";
+    }
+
+    void memory_test::test_unique_ptr()
+    {
+        mock::clear();
+        {
+            auto ptr = std::make_unique<mock>();
+            test_eq("unique_ptr get() when non-null", (ptr.get() != nullptr), true);
+            test_eq("unique_ptr operator bool when non-null", (bool)ptr, true);
+        }
+        test_eq("unique_ptr make_unique", mock::constructor_calls, 1U);
+        test_eq("unique_ptr out of scope", mock::destructor_calls, 1U);
+
+        mock::clear();
+        {
+            auto ptr = std::make_unique<mock>();
+            delete ptr.release();
+        }
+        test_eq("unique_ptr release", mock::destructor_calls, 1U);
+
+        mock::clear();
+        {
+            auto ptr = std::make_unique<mock>();
+            ptr.reset(new mock{});
+        }
+        test_eq("unique_ptr reset", mock::destructor_calls, 2U);
+
+        mock::clear();
+        {
+            std::unique_ptr<mock> ptr1{};
+            test_eq("unique_ptr get() when null", ptr1.get(), nullptr);
+            test_eq("unique_ptr operator bool when null", (bool)ptr1, false);
+            {
+                auto ptr2 = std::make_unique<mock>();
+                ptr1 = std::move(ptr2);
+            }
+            test_eq("unique_ptr move pt1", mock::destructor_calls, 0U);
+        }
+        test_eq("unique_ptr move pt2", mock::destructor_calls, 1U);
+
+        mock::clear();
+        {
+            auto ptr = std::make_unique<mock[]>(10U);
+            test_eq("unique_ptr make_unique array version", mock::constructor_calls, 10U);
+
+            new(&ptr[5]) mock{};
+            test_eq("placement new into the array", mock::constructor_calls, 11U);
+            test_eq("original not destroyed during placement new", mock::destructor_calls, 0U);
+        }
+        test_eq("unique_ptr array out of scope", mock::destructor_calls, 10U);
+    }
+
+    void memory_test::test_shared_ptr()
+    {
+        mock::clear();
+        {
+            auto ptr1 = std::make_shared<mock>();
+            test_eq("shared_ptr make_shared", mock::constructor_calls, 1U);
+            test_eq("shared_ptr unique", ptr1.unique(), true);
+            {
+                auto ptr2 = ptr1;
+                test_eq("shared_ptr copy pt1", ptr1.use_count(), 2L);
+                test_eq("shared_ptr copy pt2", ptr2.use_count(), 2L);
+                test_eq("shared_ptr copy no constructor call", mock::copy_constructor_calls, 0U);
+                test_eq("shared_ptr not unique", ptr1.unique(), false);
+
+                auto ptr3 = std::move(ptr2);
+                test_eq("shared_ptr move pt1", ptr1.use_count(), 2L);
+                test_eq("shared_ptr move pt2", ptr3.use_count(), 2L);
+                test_eq("shared_ptr move pt3", ptr2.use_count(), 0L);
+
+                test_eq("shared_ptr move origin empty", (bool)ptr2, false);
+            }
+            test_eq("shared_ptr copy out of scope", mock::destructor_calls, 0U);
+        }
+        test_eq("shared_ptr original out of scope", mock::destructor_calls, 1U);
+    }
+
+    void memory_test::test_weak_ptr()
+    {
+        mock::clear();
+        {
+            std::weak_ptr<mock> wptr1{};
+            {
+                auto ptr1 = std::make_shared<mock>();
+                wptr1 = ptr1;
+                {
+                    std::weak_ptr<mock> wptr2 = ptr1;
+                    test_eq("weak_ptr shares use count", wptr2.use_count(), 1L);
+                    test_eq("weak_ptr not expired", wptr2.expired(), false);
+
+                    auto ptr2 = wptr2.lock();
+                    test_eq("locked ptr increases use count", ptr1.use_count(), 2L);
+                }
+            }
+            test_eq("weak_ptr expired after all shared_ptrs die", wptr1.expired(), true);
+            test_eq("shared object destroyed while weak_ptr exists", mock::destructor_calls, 1U);
+        }
+    }
+
+    void memory_test::test_allocators()
+    {
+        using dummy_traits1 = std::allocator_traits<aux::dummy_allocator1>;
+        using dummy_traits2 = std::allocator_traits<aux::dummy_allocator2>;
+
+        /**
+         * First dummy allocator doesn't provide
+         * anything except for the mandatory value_type,
+         * so we get all the defaults here.
+         */
+        static_assert(std::is_same_v<typename dummy_traits1::pointer, int*>);
+        static_assert(std::is_same_v<typename dummy_traits1::const_pointer, const int*>);
+        static_assert(std::is_same_v<typename dummy_traits1::void_pointer, void*>);
+        static_assert(std::is_same_v<typename dummy_traits1::const_void_pointer, const void*>);
+        static_assert(std::is_same_v<typename dummy_traits1::difference_type, ptrdiff_t>);
+        static_assert(std::is_same_v<typename dummy_traits1::size_type, std::make_unsigned_t<ptrdiff_t>>);
+        static_assert(std::is_same_v<typename dummy_traits1::propagate_on_container_copy_assignment, std::false_type>);
+        static_assert(std::is_same_v<typename dummy_traits1::propagate_on_container_move_assignment, std::false_type>);
+        static_assert(std::is_same_v<typename dummy_traits1::propagate_on_container_swap, std::false_type>);
+        static_assert(std::is_same_v<typename dummy_traits1::is_always_equal, typename std::is_empty<aux::dummy_allocator1>::type>);
+
+        /**
+         * Second dummy allocator provides all typedefs, so
+         * the the traits just use identity.
+         */
+        static_assert(std::is_same_v<typename dummy_traits2::pointer, char*>);
+        static_assert(std::is_same_v<typename dummy_traits2::const_pointer, const void*>);
+        static_assert(std::is_same_v<typename dummy_traits2::void_pointer, bool*>);
+        static_assert(std::is_same_v<typename dummy_traits2::const_void_pointer, volatile bool*>);
+        static_assert(std::is_same_v<typename dummy_traits2::difference_type, short>);
+        static_assert(std::is_same_v<typename dummy_traits2::size_type, long>);
+        static_assert(std::is_same_v<typename dummy_traits2::propagate_on_container_copy_assignment, std::true_type>);
+        static_assert(std::is_same_v<typename dummy_traits2::propagate_on_container_move_assignment, std::true_type>);
+        static_assert(std::is_same_v<typename dummy_traits2::propagate_on_container_swap, std::true_type>);
+        static_assert(std::is_same_v<typename dummy_traits2::is_always_equal, std::true_type>);
+    }
+
+    void memory_test::test_pointers()
+    {
+        using dummy_traits1 = std::pointer_traits<aux::dummy_pointer1>;
+        using dummy_traits2 = std::pointer_traits<aux::dummy_pointer2<int, char>>;
+        using int_traits    = std::pointer_traits<int*>;
+
+        static_assert(std::is_same_v<typename dummy_traits1::pointer, aux::dummy_pointer1>);
+        static_assert(std::is_same_v<typename dummy_traits1::element_type, int>);
+        static_assert(std::is_same_v<typename dummy_traits1::difference_type, bool>);
+        static_assert(std::is_same_v<typename dummy_traits1::template rebind<long>, unsigned>);
+
+        int x{10};
+        test_eq("pointer_traits<Ptr>::pointer_to", dummy_traits1::pointer_to(x).tag, 10);
+        test_eq("pointer_traits<T*>::pointer_to", int_traits::pointer_to(x), &x);
+
+        static_assert(std::is_same_v<typename dummy_traits2::pointer, aux::dummy_pointer2<int, char>>);
+        static_assert(std::is_same_v<typename dummy_traits2::element_type, signed char>);
+        static_assert(std::is_same_v<typename dummy_traits2::difference_type, unsigned char>);
+
+        static_assert(std::is_same_v<typename int_traits::pointer, int*>);
+        static_assert(std::is_same_v<typename int_traits::element_type, int>);
+        static_assert(std::is_same_v<typename int_traits::difference_type, ptrdiff_t>);
+        static_assert(std::is_same_v<typename int_traits::rebind<char>, char*>);
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/mock.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/mock.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/mock.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <__bits/test/mock.hpp>
+
+namespace std::test
+{
+    size_t mock::constructor_calls{};
+    size_t mock::copy_constructor_calls{};
+    size_t mock::destructor_calls{};
+    size_t mock::move_constructor_calls{};
+}
Index: uspace/lib/cpp/src/__bits/test/numeric.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/numeric.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/numeric.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <array>
+#include <complex>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <numeric>
+#include <utility>
+
+using namespace std::literals;
+using namespace complex_literals;
+
+namespace std::test
+{
+    bool numeric_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_algorithms();
+        test_complex();
+
+        return end();
+    }
+
+    const char* numeric_test::name()
+    {
+        return "numeric";
+    }
+
+    void numeric_test::test_algorithms()
+    {
+        auto data1 = {1, 2, 3, 4, 5};
+
+        auto res1 = std::accumulate(data1.begin(), data1.end(), 5);
+        test_eq("accumulate pt1", res1, 20);
+
+        auto res2 = std::accumulate(
+            data1.begin(), data1.end(), 2,
+            [](const auto& lhs, const auto& rhs){
+                return lhs * rhs;
+            }
+        );
+        test_eq("accumulate pt2", res2, 240);
+
+        auto res3 = std::accumulate(data1.begin(), data1.begin(), 10);
+        test_eq("accumulate pt3", res3, 10);
+
+        auto data2 = {3, 5, 2, 8, 7};
+        auto data3 = {4, 6, 1, 0, 5};
+
+        auto res4 = std::inner_product(
+            data2.begin(), data2.end(), data3.begin(), 0
+        );
+        test_eq("inner_product pt1", res4, 79);
+
+        auto res5 = std::inner_product(
+            data2.begin(), data2.end(), data3.begin(), 10,
+            [](const auto& lhs, const auto& rhs){
+                return lhs + rhs;
+            },
+            [](const auto& lhs, const auto& rhs){
+                return 2 * (lhs + rhs);
+            }
+        );
+        test_eq("inner_product pt2", res5, 92);
+
+        auto data4 = {1, 3, 2, 4, 5};
+        auto check1 = {1, 4, 6, 10, 15};
+        std::array<int, 5> result{};
+
+        auto res6 = std::partial_sum(
+            data4.begin(), data4.end(), result.begin()
+        );
+        test_eq(
+            "partial sum pt1",
+            check1.begin(), check1.end(),
+            result.begin(), result.end()
+        );
+        test_eq("partial sum pt2", res6, result.end());
+
+        auto check2 = {1, 3, 6, 24, 120};
+        auto res7 = std::partial_sum(
+            data4.begin(), data4.end(), result.begin(),
+            [](const auto& lhs, const auto& rhs){
+                return lhs * rhs;
+            }
+        );
+        test_eq(
+            "partial sum pt3",
+            check2.begin(), check2.end(),
+            result.begin(), result.end()
+        );
+        test_eq("partial sum pt4", res7, result.end());
+
+        auto check3 = {1, 2, -1, 2, 1};
+        auto res8 = std::adjacent_difference(
+            data4.begin(), data4.end(), result.begin()
+        );
+        test_eq(
+            "adjacent_difference pt1",
+            check3.begin(), check3.end(),
+            result.begin(), result.end()
+        );
+        test_eq("adjacent_difference pt2", res8, result.end());
+
+        auto check4 = {1, 3, 6, 8, 20};
+        auto res9 = std::adjacent_difference(
+            data4.begin(), data4.end(), result.begin(),
+            [](const auto& lhs, const auto& rhs){
+                return lhs * rhs;
+            }
+        );
+        test_eq(
+            "adjacent_difference pt3",
+            check4.begin(), check4.end(),
+            result.begin(), result.end()
+        );
+        test_eq("adjacent_difference pt4", res9, result.end());
+
+        auto check5 = {4, 5, 6, 7, 8};
+        std::iota(result.begin(), result.end(), 4);
+        test_eq(
+            "iota", check5.begin(), check5.end(),
+            result.begin(), result.end()
+        );
+    }
+
+    void numeric_test::test_complex()
+    {
+        auto c1 = 1.f + 2.5if;
+        test_eq("complex literals pt1", c1.real(), 1.f);
+        test_eq("complex literals pt2", c1.imag(), 2.5f);
+
+        std::complex<double> c2{2.0, 0.5};
+        test_eq("complex value initialization", c2, (2.0 + 0.5i));
+
+        std::complex<double> c3{c2};
+        test_eq("complex copy initialization", c3, (2.0 + 0.5i));
+
+        std::complex<double> c4{c1};
+        test_eq("complex conversion initialization", c4, (1.0 + 2.5i));
+
+        test_eq("complex sum", ((1.0 + 2.5i) + (3.0 + 0.5i)), (4.0 + 3.0i));
+        test_eq("complex sub", ((2.0 + 3.0i) - (1.0 + 5.0i)), (1.0 - 2.0i));
+        test_eq("complex mul", ((2.0 + 2.0i) * (2.0 + 3.0i)), (-2.0 + 10.0i));
+        test_eq("complex div", ((2.0 - 1.0i) / (3.0 + 4.0i)), (0.08 - 0.44i));
+        test_eq("complex unary minus", -(1.0 + 1.0i), (-1.0 - 1.0i));
+        test_eq("complex abs", std::abs(2.0 - 4.0i), 20.0);
+        test_eq("complex real", std::real(2.0 + 3.0i), 2.0);
+        test_eq("complex imag", std::imag(2.0 + 3.0i), 3.0);
+    }
+}
+
Index: uspace/lib/cpp/src/__bits/test/set.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/set.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/set.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <set>
+#include <string>
+#include <utility>
+
+namespace std::test
+{
+    bool set_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_constructors_and_assignment();
+        test_emplace_insert();
+        test_bounds_and_ranges();
+        test_multi();
+        test_reverse_iterators();
+        test_multi_bounds_and_ranges();
+
+        return end();
+    }
+
+    const char* set_test::name()
+    {
+        return "set";
+    }
+
+    void set_test::test_constructors_and_assignment()
+    {
+        auto check1 = {1, 2, 3, 4, 5, 6, 7};
+        auto src1 = {3, 1, 5, 2, 7, 6, 4};
+
+        std::set<int> s1{src1};
+        test_eq(
+            "initializer list initialization",
+            check1.begin(), check1.end(),
+            s1.begin(), s1.end()
+        );
+        test_eq("size", s1.size(), 7U);
+
+        std::set<int> s2{src1.begin(), src1.end()};
+        test_eq(
+            "iterator range initialization",
+            check1.begin(), check1.end(),
+            s2.begin(), s2.end()
+        );
+
+        std::set<int> s3{s1};
+        test_eq(
+            "copy initialization",
+            check1.begin(), check1.end(),
+            s3.begin(), s3.end()
+        );
+
+        std::set<int> s4{std::move(s1)};
+        test_eq(
+            "move initialization",
+            check1.begin(), check1.end(),
+            s4.begin(), s4.end()
+        );
+        test_eq("move initialization - origin empty", s1.size(), 0U);
+        test_eq("empty", s1.empty(), true);
+
+        s1 = s4;
+        test_eq(
+            "copy assignment",
+            check1.begin(), check1.end(),
+            s1.begin(), s1.end()
+        );
+
+        s4 = std::move(s1);
+        test_eq(
+            "move assignment",
+            check1.begin(), check1.end(),
+            s4.begin(), s4.end()
+        );
+        test_eq("move assignment - origin empty", s1.size(), 0U);
+
+        s1 = src1;
+        test_eq(
+            "initializer list assignment",
+            check1.begin(), check1.end(),
+            s1.begin(), s1.end()
+        );
+    }
+
+    void set_test::test_emplace_insert()
+    {
+        std::set<int> set1{};
+
+        auto res1 = set1.emplace(1);
+        test_eq("first emplace succession", res1.second, true);
+        test_eq("first emplace equivalence", *res1.first, 1);
+
+        auto res2 = set1.emplace(1);
+        test_eq("second emplace failure", res2.second, false);
+        test_eq("second emplace equivalence", *res2.first, 1);
+
+        auto res3 = set1.emplace_hint(set1.begin(), 2);
+        test_eq("first emplace_hint succession", (res3 != set1.end()), true);
+        test_eq("first emplace_hint equivalence", *res3, 2);
+
+        auto res4 = set1.emplace_hint(set1.begin(), 2);
+        test_eq("second emplace_hint failure", (res4 != set1.end()), true);
+        test_eq("second emplace_hint equivalence", *res4, 2);
+
+        std::set<std::string> set2{};
+        auto res5 = set2.insert("A");
+        test_eq("conversion insert succession", res5.second, true);
+        test_eq("conversion insert equivalence", *res5.first, std::string{"A"});
+
+        auto res6 = set2.insert(std::string{"B"});
+        test_eq("first insert succession", res6.second, true);
+        test_eq("first insert equivalence", *res6.first, std::string{"B"});
+
+        auto res7 = set2.insert(std::string{"B"});
+        test_eq("second insert failure", res7.second, false);
+        test_eq("second insert equivalence", *res7.first, std::string{"B"});
+
+        auto res10 = set1.erase(set1.find(2));
+        test_eq("erase", set1.find(2), set1.end());
+        test_eq("highest erased", res10, set1.end());
+
+        set2.insert(std::string{"G"});
+        set2.insert(std::string{"H"});
+        set2.insert(std::string{"K"});
+        auto res11 = set2.erase(std::string{"G"});
+        test_eq("erase by key pt1", res11, 1U);
+        auto res12 = set2.erase(std::string{"M"});
+        test_eq("erase by key pt2", res12, 0U);
+
+        std::set<int> set3{};
+        set3.insert(1);
+        auto res13 = set3.erase(1);
+        test_eq("erase root by key pt1", res13, 1U);
+        test_eq("erase root by key pt2", set3.empty(), true);
+
+        set3.insert(3);
+        auto res14 = set3.erase(set3.begin());
+        test_eq("erase root by iterator pt1", res14, set3.end());
+        test_eq("erase root by iterator pt2", set3.empty(), true);
+
+        set2.clear();
+        test_eq("clear", set2.empty(), true);
+
+        set3.insert(1);
+        auto res15 = set3.count(1);
+        test_eq("count", res15, 1U);
+    }
+
+    void set_test::test_bounds_and_ranges()
+    {
+        std::set<int> set{};
+        for (int i = 0; i < 10; ++i)
+            set.insert(i);
+        for (int i = 15; i < 20; ++i)
+            set.insert(i);
+
+        auto res1 = set.lower_bound(5);
+        test_eq("lower_bound of present key", *res1, 5);
+
+        auto res2 = set.lower_bound(13);
+        test_eq("lower_bound of absent key", *res2, 9);
+
+        auto res3 = set.upper_bound(7);
+        test_eq("upper_bound of present key", *res3, 8);
+
+        auto res4 = set.upper_bound(12);
+        test_eq("upper_bound of absent key", *res4, 15);
+
+        auto res5 = set.equal_range(4);
+        test_eq("equal_range of present key pt1", *res5.first, 4);
+        test_eq("equal_range of present key pt2", *res5.second, 5);
+
+        auto res6 = set.equal_range(14);
+        test_eq("equal_range of absent key pt1", *res6.first, 9);
+        test_eq("equal_range of absent key pt2", *res6.second, 15);
+    }
+
+    void set_test::test_multi()
+    {
+        auto check1 = {1, 2, 3, 3, 4, 5, 6, 6, 6, 7};
+        auto src1 = {3, 6, 1, 5, 6, 3, 2, 7, 6, 4};
+
+        std::multiset<int> mset{src1};
+        test_eq(
+            "multi construction",
+            check1.begin(), check1.end(),
+            mset.begin(), mset.end()
+        );
+
+        auto res1 = mset.count(6);
+        test_eq("multi count", res1, 3U);
+
+        auto res2 = mset.emplace(7);
+        test_eq("multi duplicit emplace pt1", *res2, 7);
+        test_eq("multi duplicit emplace pt2", mset.count(7), 2U);
+
+        auto res3 = mset.emplace(8);
+        test_eq("multi unique emplace pt1", *res3, 8);
+        test_eq("multi unique emplace pt2", mset.count(8), 1U);
+
+        auto res4 = mset.insert(8);
+        test_eq("multi duplicit insert pt1", *res4, 8);
+        test_eq("multi duplicit insert pt2", mset.count(8), 2U);
+
+        auto res5 = mset.insert(9);
+        test_eq("multi unique insert pt1", *res5, 9);
+        test_eq("multi unique insert pt2", mset.count(9), 1U);
+
+        auto res6 = mset.erase(8);
+        test_eq("multi erase by key pt1", res6, 2U);
+        test_eq("multi erase by key pt2", mset.count(8), 0U);
+
+        auto res7 = mset.erase(mset.find(7));
+        test_eq("multi erase by iterator pt1", *res7, 7);
+        test_eq("multi erase by iterator pt2", mset.count(7), 1U);
+    }
+
+    void set_test::test_reverse_iterators()
+    {
+        auto check1 = {7, 6, 6, 6, 5, 4, 3, 3, 2, 1};
+        auto src1 = {3, 6, 1, 5, 6, 3, 2, 7, 6, 4};
+
+        std::multiset<int> mset{src1};
+        test_eq(
+            "multi reverse iterators",
+            check1.begin(), check1.end(),
+            mset.rbegin(), mset.rend()
+        );
+
+        auto check2 = {7, 6, 5, 4, 3, 2, 1};
+        auto src2 = {3, 1, 5, 2, 7, 6, 4};
+
+        std::set<int> set{src2};
+        test_eq(
+            "reverse iterators",
+            check2.begin(), check2.end(),
+            set.rbegin(), set.rend()
+        );
+    }
+
+    void set_test::test_multi_bounds_and_ranges()
+    {
+        auto check1 = {1, 1};
+        auto check2 = {5, 5, 5};
+        auto check3 = {6};
+        auto src = {1, 1, 2, 3, 5, 5, 5, 6};
+
+        std::multiset<int> mset{src};
+        auto res1 = mset.equal_range(1);
+        test_eq(
+            "multi equal_range at the start",
+            check1.begin(), check1.end(),
+            res1.first, res1.second
+        );
+
+        auto res2 = mset.equal_range(5);
+        test_eq(
+            "multi equal_range in the middle",
+            check2.begin(), check2.end(),
+            res2.first, res2.second
+        );
+
+        auto res3 = mset.equal_range(6);
+        test_eq(
+            "multi equal_range at the end + single element range",
+            check3.begin(), check3.end(),
+            res3.first, res3.second
+        );
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/string.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/string.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/string.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,706 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <string>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <cstdio>
+
+namespace std::test
+{
+    bool string_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_construction_and_assignment();
+        test_append();
+        test_insert();
+        test_erase();
+        test_replace();
+        test_copy();
+        test_find();
+        test_substr();
+        test_compare();
+
+        return end();
+    }
+
+    const char* string_test::name()
+    {
+        return "string";
+    }
+
+    void string_test::test_construction_and_assignment()
+    {
+        const char* check1 = "hello";
+
+        std::string str1{"hello"};
+        test_eq(
+            "size of string",
+            str1.size(), 5ul
+        );
+        test_eq(
+            "initialization from a cstring literal",
+            str1.begin(), str1.end(),
+            check1, check1 + 5
+        );
+
+        std::string str2{str1};
+        test_eq(
+            "copy constructor",
+            str1.begin(), str1.end(),
+            str2.begin(), str2.end()
+        );
+
+        std::string str3{std::move(str1)};
+        test_eq(
+            "move constructor equality",
+            str2.begin(), str2.end(),
+            str3.begin(), str3.end()
+        );
+        test_eq(
+            "move constructor source empty",
+            str1.size(), 0ul
+        );
+
+        std::string str4{};
+        test_eq(
+            "default constructor empty",
+            str4.size(), 0ul
+        );
+
+        str4.assign(str3, 2ul, 2ul);
+        test_eq(
+            "assign substring to an empty string",
+            str4.begin(), str4.end(),
+            str3.begin() + 2, str3.begin() + 4
+        );
+
+        std::string str5{str3.begin() + 2, str3.begin() + 4};
+        test_eq(
+            "constructor from a pair of iterators",
+            str5.begin(), str5.end(),
+            str3.begin() + 2, str3.begin() + 4
+        );
+    }
+
+    void string_test::test_append()
+    {
+        std::string check{"hello, world"};
+
+        std::string str1{"hello, "};
+        str1.append("world");
+        test_eq(
+            "append cstring",
+            str1.begin(), str1.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str2{"hello, "};
+        str2.append(std::string{"world"});
+        test_eq(
+            "append rvalue string",
+            str2.begin(), str2.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str3{"hello, "};
+        std::string apendee{"world"};
+        str3.append(apendee);
+        test_eq(
+            "append lvalue string",
+            str3.begin(), str3.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str4{"hello, "};
+        str4.append(apendee.begin(), apendee.end());
+        test_eq(
+            "append iterator range",
+            str4.begin(), str4.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str5{"hello, "};
+        str5.append({'w', 'o', 'r', 'l', 'd'});
+        test_eq(
+            "append initializer list",
+            str5.begin(), str5.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str6{"hello, "};
+        str6 += "world";
+        test_eq(
+            "append using +=",
+            str6.begin(), str6.end(),
+            check.begin(), check.end()
+        );
+    }
+
+    void string_test::test_insert()
+    {
+        std::string check{"hello, world"};
+
+        std::string str1{", world"};
+        str1.insert(0, "hello");
+        test_eq(
+            "insert at the beggining",
+            str1.begin(), str1.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str2{"hello,world"};
+        str2.insert(str2.begin() + 6, ' ');
+        test_eq(
+            "insert char in the middle",
+            str2.begin(), str2.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str3{"heo, world"};
+        str3.insert(str3.begin() + 2, 2ul, 'l');
+        test_eq(
+            "insert n chars",
+            str3.begin(), str3.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str4{"h, world"};
+        std::string insertee{"ello"};
+        str4.insert(str4.begin() + 1, insertee.begin(),
+                    insertee.end());
+        test_eq(
+            "insert iterator range",
+            str4.begin(), str4.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str5{"hel, world"};
+        std::initializer_list<char> init{'l', 'o'};
+        str5.insert(str5.begin() + 3, init);
+        test_eq(
+            "insert initializer list",
+            str5.begin(), str5.end(),
+            check.begin(), check.end()
+        );
+    }
+
+    void string_test::test_erase()
+    {
+        std::string check{"hello"};
+
+        std::string str1{"heXllo"};
+        str1.erase(str1.begin() + 2);
+        test_eq(
+            "erase single char in the middle",
+            str1.begin(), str1.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str2{"Xhello"};
+        str2.erase(str2.begin());
+        test_eq(
+            "erase single char at the beginning",
+            str2.begin(), str2.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str3{"helloX"};
+        str3.erase(str3.begin() + 5);
+        test_eq(
+            "erase single char at the end",
+            str3.begin(), str3.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str4{"XXXhello"};
+        str4.erase(0, 3);
+        test_eq(
+            "erase string at the beginning",
+            str4.begin(), str4.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str5{"heXXXllo"};
+        str5.erase(2, 3);
+        test_eq(
+            "erase string in the middle",
+            str5.begin(), str5.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str6{"helloXXX"};
+        str6.erase(5);
+        test_eq(
+            "erase string at the end",
+            str6.begin(), str6.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str7{"hellXXXo"};
+        str7.erase(str7.begin() + 4, str7.begin() + 7);
+        test_eq(
+            "erase iterator range",
+            str7.begin(), str7.end(),
+            check.begin(), check.end()
+        );
+    }
+
+    void string_test::test_replace()
+    {
+        std::string check{"hello, world"};
+
+        std::string str1{"helXXX world"};
+        str1.replace(3, 3, "lo,", 3);
+        test_eq(
+            "replace with full string",
+            str1.begin(), str1.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str2{"helXXX world"};
+        str2.replace(3, 3, "lo,YYY", 3);
+        test_eq(
+            "replace with prefix of a string",
+            str2.begin(), str2.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str3{"helXXX world"};
+        str3.replace(3, 3, "YYlo,YYY", 2, 3);
+        test_eq(
+            "replace with substring of a string",
+            str3.begin(), str3.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str4{"heXXo, world"};
+        str4.replace(2, 2, 2, 'l');
+        test_eq(
+            "replace with repeated characters",
+            str4.begin(), str4.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str5{"heXXXXo, world"};
+        str5.replace(2, 4, 2, 'l');
+        test_eq(
+            "replace with repeated characters (shrinking)",
+            str5.begin(), str5.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str6{"helXXXXX world"};
+        str6.replace(3, 5, "YYlo,YYY", 2, 3);
+        test_eq(
+            "replace with substring of a string (shrinking)",
+            str6.begin(), str6.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str7{"helXXXXX world"};
+        std::string replacer{"YYlo,YYY"};
+        str7.replace(3, 5, replacer, 2, 3);
+        test_eq(
+            "replace with substring of a string (shrinking, std::string)",
+            str7.begin(), str7.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str8{"helXXXXX world"};
+        str8.replace(str8.begin() + 3, str8.begin() + 8, "lo,");
+        test_eq(
+            "replace with a string (iterators)",
+            str8.begin(), str8.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str9{"heXXXXo, world"};
+        str9.replace(str9.begin() + 2, str9.begin() + 6, 2, 'l');
+        test_eq(
+            "replace with repeated characters (shrinking, iterators)",
+            str9.begin(), str9.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str10{"helXXXXX world"};
+        str10.replace(str10.begin() + 3, str10.begin() + 8,
+                      replacer.begin() + 2, replacer.begin() + 5);
+        test_eq(
+            "replace with substring of a string (shrinking, iterators x2)",
+            str10.begin(), str10.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str11{"helXXXXX world"};
+        str11.replace(str11.begin() + 3, str11.begin() + 8,
+                      {'l', 'o', ','});
+        test_eq(
+            "replace with an initializer list (shrinking, iterators)",
+            str11.begin(), str11.end(),
+            check.begin(), check.end()
+        );
+
+        std::string str12{"helXXX world"};
+        str12.replace(str12.begin() + 3, str12.begin() + 6,
+                      {'l', 'o', ','});
+        test_eq(
+            "replace with an initializer list (iterators)",
+            str12.begin(), str12.end(),
+            check.begin(), check.end()
+        );
+    }
+
+    void string_test::test_copy()
+    {
+        std::string check{"CCABB"};
+
+        std::string str1{"ACCCA"};
+        std::string str2{"BBBBB"};
+
+        str1.copy(const_cast<char*>(str2.c_str()), 3, 2);
+        test_eq(
+            "copy",
+            str2.begin(), str2.end(),
+            check.begin(), check.end()
+        );
+    }
+
+    void string_test::test_find()
+    {
+        std::string target{"ABC"};
+        auto miss = std::string::npos;
+
+        std::string str1{"xxABCxx"};
+
+        auto idx = str1.find(target, 0);
+        test_eq(
+            "find from start (success)",
+            idx, 2ul
+        );
+
+        idx = str1.find(target, 3);
+        test_eq(
+            "find from start (fail, late start)",
+            idx, miss
+        );
+
+        idx = str1.rfind(target, miss);
+        test_eq(
+            "rfind from end (success)",
+            idx, 2ul
+        );
+
+        idx = str1.rfind(target, 1);
+        test_eq(
+            "rfind from start (fail, late start)",
+            idx, miss
+        );
+
+        idx = str1.find('B', 2);
+        test_eq(
+            "find char from middle (success)",
+            idx, 3ul
+        );
+
+        idx = str1.rfind('B', 2);
+        test_eq(
+            "rfind char from middle (success)",
+            idx, 3ul
+        );
+
+        std::string str2{"xxABCxxABCxx"};
+
+        idx = str2.find(target, 0);
+        test_eq(
+            "find from start (success, multiple)",
+            idx, 2ul
+        );
+
+        idx = str2.find(target, 5);
+        test_eq(
+            "find from middle (success, multiple)",
+            idx, 7ul
+        );
+
+        idx = str2.rfind(target, miss);
+        test_eq(
+            "rfind from end (success, multiple)",
+            idx, 7ul
+        );
+
+        idx = str2.rfind(target, 6);
+        test_eq(
+            "rfind from mid (success, multiple)",
+            idx, 2ul
+        );
+
+        std::string str3{"xxBxxAxxCxx"};
+
+        idx = str3.find_first_of(target);
+        test_eq(
+            "find first of from start (success)",
+            idx, 2ul
+        );
+
+        idx = str3.find_first_of(target, 6);
+        test_eq(
+            "find first of from middle (success)",
+            idx, 8ul
+        );
+
+        idx = str3.find_first_of("DEF", 3);
+        test_eq(
+            "find first of from middle (fail, not in string)",
+            idx, miss
+        );
+
+        idx = str3.find_first_of(target, 9);
+        test_eq(
+            "find first of from middle (fail, late start)",
+            idx, miss
+        );
+
+        idx = str3.find_first_of("");
+        test_eq(
+            "find first of from start (fail, no target)",
+            idx, miss
+        );
+
+        idx = str3.find_first_of('A', 1);
+        test_eq(
+            "find first of char (success)",
+            idx, 5ul
+        );
+
+        idx = str3.find_first_of('A', 6);
+        test_eq(
+            "find first of char (fail)",
+            idx, miss
+        );
+
+        idx = str3.find_last_of(target);
+        test_eq(
+            "find last of from start (success)",
+            idx, 8ul
+        );
+
+        idx = str3.find_last_of(target, 6);
+        test_eq(
+            "find last of from middle (success)",
+            idx, 5ul
+        );
+
+        idx = str3.find_last_of("DEF", 3);
+        test_eq(
+            "find last of from middle (fail, not in string)",
+            idx, miss
+        );
+
+        idx = str3.find_last_of(target, 1);
+        test_eq(
+            "find last of from middle (fail, late start)",
+            idx, miss
+        );
+
+        idx = str3.find_last_of("");
+        test_eq(
+            "find last of from start (fail, no target)",
+            idx, miss
+        );
+
+        idx = str3.find_last_of('A', str3.size() - 1);
+        test_eq(
+            "find last of char (success)",
+            idx, 5ul
+        );
+
+        idx = str3.find_last_of('A', 3);
+        test_eq(
+            "find last of char (fail)",
+            idx, miss
+        );
+
+        std::string not_target{"xB"};
+
+        idx = str3.find_first_not_of(not_target);
+        test_eq(
+            "find first not of from start (success)",
+            idx, 5ul
+        );
+
+        idx = str3.find_first_not_of(not_target, 6);
+        test_eq(
+            "find first not of from middle (success)",
+            idx, 8ul
+        );
+
+        idx = str3.find_first_not_of("xABC", 3);
+        test_eq(
+            "find first not of from middle (fail, not in string)",
+            idx, miss
+        );
+
+        idx = str3.find_first_not_of(not_target, 9);
+        test_eq(
+            "find first not of from middle (fail, late start)",
+            idx, miss
+        );
+
+        idx = str3.find_first_not_of("");
+        test_eq(
+            "find first not of from start (success, no target)",
+            idx, 0ul
+        );
+
+        idx = str3.find_first_not_of('x', 3);
+        test_eq(
+            "find first not of char (success)",
+            idx, 5ul
+        );
+
+        idx = str3.find_first_of('a', 9);
+        test_eq(
+            "find first not of char (fail)",
+            idx, miss
+        );
+
+        std::string not_last_target{"xC"};
+
+        idx = str3.find_last_not_of(not_last_target);
+        test_eq(
+            "find last not of from start (success)",
+            idx, 5ul
+        );
+
+        idx = str3.find_last_not_of(not_last_target, 4);
+        test_eq(
+            "find last not of from middle (success)",
+            idx, 2ul
+        );
+
+        idx = str3.find_last_not_of("xABC");
+        test_eq(
+            "find last not of from middle (fail, not in string)",
+            idx, miss
+        );
+
+        idx = str3.find_last_not_of(not_last_target, 1);
+        test_eq(
+            "find last not of from middle (fail, late start)",
+            idx, miss
+        );
+
+        idx = str3.find_last_not_of("");
+        test_eq(
+            "find last not of from start (success, no target)",
+            idx, str3.size() - 1
+        );
+
+        idx = str3.find_last_not_of('x', str3.size() - 1);
+        test_eq(
+            "find last not of char (success)",
+            idx, 8ul
+        );
+
+        idx = str3.find_last_not_of('x', 1);
+        test_eq(
+            "find last not of char (fail)",
+            idx, miss
+        );
+    }
+
+    void string_test::test_substr()
+    {
+        std::string check1{"abcd"};
+        std::string check2{"bcd"};
+        std::string check3{"def"};
+
+        std::string str{"abcdef"};
+        auto substr1 = str.substr(0, 4);
+        auto substr2 = str.substr(1, 3);
+        auto substr3 = str.substr(3);
+
+        test_eq(
+            "prefix substring",
+            substr1.begin(), substr1.end(),
+            check1.begin(), check1.end()
+        );
+
+        test_eq(
+            "substring",
+            substr2.begin(), substr2.end(),
+            check2.begin(), check2.end()
+        );
+
+        test_eq(
+            "suffix substring",
+            substr3.begin(), substr3.end(),
+            check3.begin(), check3.end()
+        );
+    }
+
+    void string_test::test_compare()
+    {
+        std::string str1{"aabbb"};
+        std::string str2{"bbbaa"};
+        std::string str3{"bbb"};
+
+        auto res = str1.compare(str1);
+        test_eq(
+            "compare equal",
+            res, 0
+        );
+
+        res = str1.compare(str2.c_str());
+        test_eq(
+            "compare less",
+            res, -1
+        );
+
+        res = str2.compare(str1);
+        test_eq(
+            "compare greater",
+            res, 1
+        );
+
+        res = str1.compare(2, 3, str2);
+        test_eq(
+            "compare substring less",
+            res, -1
+        );
+
+        res = str1.compare(2, 3, str3);
+        test_eq(
+            "compare substring equal",
+            res, 0
+        );
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/test.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/test.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/test.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdio>
+#include <__bits/test/test.hpp>
+
+namespace std::test
+{
+    void test_suite::report(bool result, const char* tname)
+    {
+        if (!report_)
+            return;
+
+        if (result)
+            std::printf("[%s][%s] ... OK\n", name(), tname);
+        else
+            std::printf("[%s][%s] ... FAIL\n", name(), tname);
+    }
+
+    void test_suite::start()
+    {
+        if (report_)
+            std::printf("\n[TEST START][%s]\n", name());
+    }
+
+    bool test_suite::end()
+    {
+        if (report_)
+            std::printf("[TEST END][%s][%u OK][%u FAIL]\n",
+                        name(), succeeded_, failed_);
+        return ok_;
+    }
+
+    unsigned int test_suite::get_failed() const noexcept
+    {
+        return failed_;
+    }
+
+    unsigned int test_suite::get_succeeded() const noexcept
+    {
+        return succeeded_;
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/tuple.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/tuple.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/tuple.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <functional>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <string>
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+namespace std::test
+{
+    bool tuple_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_constructors_and_assignment();
+        test_creation();
+        test_tie_and_structured_bindings();
+        test_tuple_ops();
+
+        return end();
+    }
+
+    const char* tuple_test::name()
+    {
+        return "tuple";
+    }
+
+    void tuple_test::test_constructors_and_assignment()
+    {
+        std::tuple<int, float> tpl1{1, .5f};
+        test_eq("value initialization pt1", std::get<0>(tpl1), 1);
+        test_eq("value initialization pt2", std::get<1>(tpl1), .5f);
+
+        auto p = std::make_pair(2, 1.f);
+        std::tuple<int, float> tpl2{p};
+        test_eq("pair initialization pt1", std::get<0>(tpl2), 2);
+        test_eq("pair initialization pt2", std::get<1>(tpl2), 1.f);
+
+        tpl1 = p;
+        test_eq("pair assignment pt1", std::get<0>(tpl1), 2);
+        test_eq("pair assignment pt2", std::get<1>(tpl1), 1.f);
+
+        auto tpl3 = std::make_tuple(std::string{"A"}, std::string{"B"});
+        auto tpl4 = std::make_tuple(std::string{"C"}, std::string{"D"});
+        tpl3 = std::move(tpl4);
+        test_eq("move assignment pt1", std::get<0>(tpl3), std::string{"C"});
+        test_eq("move assignment pt2", std::get<1>(tpl3), std::string{"D"});
+
+        auto tpl5 = std::make_tuple(1, .5f);
+        auto tpl6{std::move(tpl5)};
+        test_eq("move initialization pt1", std::get<0>(tpl6), 1);
+        test_eq("move initialization pt2", std::get<1>(tpl6), .5f);
+    }
+
+    void tuple_test::test_creation()
+    {
+        auto tpl1 = std::make_tuple(1, .5f, std::string{"test"}, true);
+        static_assert(std::is_same_v<std::tuple_element_t<0, decltype(tpl1)>, int>);
+        static_assert(std::is_same_v<std::tuple_element_t<1, decltype(tpl1)>, float>);
+        static_assert(std::is_same_v<std::tuple_element_t<2, decltype(tpl1)>, std::string>);
+        static_assert(std::is_same_v<std::tuple_element_t<3, decltype(tpl1)>, bool>);
+
+        test_eq("make_tuple pt1", std::get<0>(tpl1), 1);
+        test_eq("make_tuple pt2", std::get<1>(tpl1), .5f);
+        test_eq("make_tuple pt3", std::get<2>(tpl1), std::string{"test"});
+        test_eq("make_tuple pt4", std::get<3>(tpl1), true);
+
+        static_assert(std::tuple_size_v<decltype(tpl1)> == 4);
+
+        int i{};
+        float f{};
+        auto tpl2 = std::make_tuple(std::ref(i), std::cref(f));
+        static_assert(std::is_same_v<std::tuple_element_t<0, decltype(tpl2)>, int&>);
+        static_assert(std::is_same_v<std::tuple_element_t<1, decltype(tpl2)>, const float&>);
+
+        std::get<0>(tpl2) = 3;
+        test_eq("modify reference in tuple", i, 3);
+
+        auto tpl3 = std::forward_as_tuple(i, f);
+        static_assert(std::is_same_v<std::tuple_element_t<0, decltype(tpl3)>, int&>);
+        static_assert(std::is_same_v<std::tuple_element_t<1, decltype(tpl3)>, float&>);
+
+        std::get<1>(tpl3) = 1.5f;
+        test_eq("modify reference in forward_as_tuple", f, 1.5f);
+    }
+
+    void tuple_test::test_tie_and_structured_bindings()
+    {
+        int i1{};
+        float f1{};
+        auto tpl = std::make_tuple(1, .5f);
+        std::tie(i1, f1) = tpl;
+
+        test_eq("tie unpack pt1", i1, 1);
+        test_eq("tie unpack pt2", f1, .5f);
+
+        std::get<0>(tpl) = 2;
+        std::tie(i1, std::ignore) = tpl;
+
+        test_eq("tie unpack with ignore", i1, 2);
+
+        auto [i2, f2] = tpl;
+        test_eq("structured bindings pt1", i2, 2);
+        test_eq("structured bindings pt2", f2, .5f);
+    }
+
+    void tuple_test::test_tuple_ops()
+    {
+        auto tpl1 = std::make_tuple(1, .5f);
+        auto tpl2 = std::make_tuple(1, .5f);
+        auto tpl3 = std::make_tuple(1, 1.f);
+        auto tpl4 = std::make_tuple(2, .5f);
+        auto tpl5 = std::make_tuple(2, 1.f);
+
+        test_eq("tuple == pt1", (tpl1 == tpl2), true);
+        test_eq("tuple == pt2", (tpl1 == tpl3), false);
+        test_eq("tuple == pt3", (tpl1 == tpl4), false);
+        test_eq("tuple < pt1", (tpl1 < tpl2), false);
+        test_eq("tuple < pt2", (tpl1 < tpl3), true);
+        test_eq("tuple < pt3", (tpl1 < tpl4), true);
+        test_eq("tuple < pt4", (tpl1 < tpl5), true);
+
+        tpl1.swap(tpl5);
+        test_eq("tuple swap pt1", std::get<0>(tpl1), 2);
+        test_eq("tuple swap pt2", std::get<1>(tpl1), 1.f);
+        test_eq("tuple swap pt3", std::get<0>(tpl5), 1);
+        test_eq("tuple swap pt4", std::get<1>(tpl5), .5f);
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/unordered_map.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/unordered_map.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/unordered_map.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <unordered_map>
+#include <string>
+#include <sstream>
+#include <utility>
+
+namespace std::test
+{
+    bool unordered_map_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_constructors_and_assignment();
+        test_histogram();
+        test_emplace_insert();
+        test_multi();
+
+        return end();
+    }
+
+    const char* unordered_map_test::name()
+    {
+        return "unordered_map";
+    }
+
+    void unordered_map_test::test_constructors_and_assignment()
+    {
+        auto check1 = {1, 2, 3, 4, 5, 6, 7};
+        auto src1 = {
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{4, 4}
+        };
+
+        std::unordered_map<int, int> m1{src1};
+        test_contains(
+            "initializer list initialization",
+            check1.begin(), check1.end(), m1
+        );
+        test_eq("size", m1.size(), 7U);
+
+        std::unordered_map<int, int> m2{src1.begin(), src1.end()};
+        test_contains(
+            "iterator range initialization",
+            check1.begin(), check1.end(), m2
+        );
+
+        std::unordered_map<int, int> m3{m1};
+        test_contains(
+            "copy initialization",
+            check1.begin(), check1.end(), m3
+        );
+
+        std::unordered_map<int, int> m4{std::move(m1)};
+        test_contains(
+            "move initialization",
+            check1.begin(), check1.end(), m4
+        );
+        test_eq("move initialization - origin empty", m1.size(), 0U);
+        test_eq("empty", m1.empty(), true);
+
+        m1 = m4;
+        test_contains(
+            "copy assignment",
+            check1.begin(), check1.end(), m1
+        );
+
+        m4 = std::move(m1);
+        test_contains(
+            "move assignment",
+            check1.begin(), check1.end(), m4
+        );
+        test_eq("move assignment - origin empty", m1.size(), 0U);
+
+        m1 = src1;
+        test_contains(
+            "initializer list assignment",
+            check1.begin(), check1.end(), m1
+        );
+    }
+
+    void unordered_map_test::test_histogram()
+    {
+        std::string str{"a b a a c d b e a b b e d c a e"};
+        std::unordered_map<std::string, std::size_t> unordered_map{};
+        std::istringstream iss{str};
+        std::string word{};
+
+        while (iss >> word)
+            ++unordered_map[word];
+
+        test_eq("histogram pt1", unordered_map["a"], 5U);
+        test_eq("histogram pt2", unordered_map["b"], 4U);
+        test_eq("histogram pt3", unordered_map["c"], 2U);
+        test_eq("histogram pt4", unordered_map["d"], 2U);
+        test_eq("histogram pt5", unordered_map["e"], 3U);
+        test_eq("histogram pt6", unordered_map["f"], 0U);
+        test_eq("at", unordered_map.at("a"), 5U);
+    }
+
+    void unordered_map_test::test_emplace_insert()
+    {
+        std::unordered_map<int, int> map1{};
+
+        auto res1 = map1.emplace(1, 2);
+        test_eq("first emplace succession", res1.second, true);
+        test_eq("first emplace equivalence pt1", res1.first->first, 1);
+        test_eq("first emplace equivalence pt2", res1.first->second, 2);
+
+        auto res2 = map1.emplace(1, 3);
+        test_eq("second emplace failure", res2.second, false);
+        test_eq("second emplace equivalence pt1", res2.first->first, 1);
+        test_eq("second emplace equivalence pt2", res2.first->second, 2);
+
+        auto res3 = map1.emplace_hint(map1.begin(), 2, 4);
+        test_eq("first emplace_hint succession", (res3 != map1.end()), true);
+        test_eq("first emplace_hint equivalence pt1", res3->first, 2);
+        test_eq("first emplace_hint equivalence pt2", res3->second, 4);
+
+        auto res4 = map1.emplace_hint(map1.begin(), 2, 5);
+        test_eq("second emplace_hint failure", (res4 != map1.end()), true);
+        test_eq("second emplace_hint equivalence pt1", res4->first, 2);
+        test_eq("second emplace_hint equivalence pt2", res4->second, 4);
+
+        std::unordered_map<int, std::string> map2{};
+        auto res5 = map2.insert(std::pair<const int, const char*>{5, "A"});
+        test_eq("conversion insert succession", res5.second, true);
+        test_eq("conversion insert equivalence pt1", res5.first->first, 5);
+        test_eq("conversion insert equivalence pt2", res5.first->second, std::string{"A"});
+
+        auto res6 = map2.insert(std::pair<const int, std::string>{6, "B"});
+        test_eq("first insert succession", res6.second, true);
+        test_eq("first insert equivalence pt1", res6.first->first, 6);
+        test_eq("first insert equivalence pt2", res6.first->second, std::string{"B"});
+
+        auto res7 = map2.insert(std::pair<const int, std::string>{6, "C"});
+        test_eq("second insert failure", res7.second, false);
+        test_eq("second insert equivalence pt1", res7.first->first, 6);
+        test_eq("second insert equivalence pt2", res7.first->second, std::string{"B"});
+
+        auto res8 = map2.insert_or_assign(6, std::string{"D"});
+        test_eq("insert_or_*assign* result", res8.second, false);
+        test_eq("insert_or_*assign* equivalence pt1", res8.first->first, 6);
+        test_eq("insert_or_*assign* equivalence pt2", res8.first->second, std::string{"D"});
+
+        auto res9 = map2.insert_or_assign(7, std::string{"E"});
+        test_eq("*insert*_or_assign result", res9.second, true);
+        test_eq("*insert*_or_assign equivalence pt1", res9.first->first, 7);
+        test_eq("*insert*_or_assign equivalence pt2", res9.first->second, std::string{"E"});
+
+        auto res10 = map2.erase(map2.find(7));
+        test_eq("erase", map2.find(7), map2.end());
+        test_eq("highest erased", res10, map2.end());
+
+        auto res11 = map2.erase(6);
+        test_eq("erase by key pt1", res11, 1U);
+        auto res12 = map2.erase(6);
+        test_eq("erase by key pt2", res12, 0U);
+
+        auto res13 = map2.insert(std::pair<const int, const char*>{11, "test"});
+        test_eq("insert with constructible argument pt1", res13.second, true);
+        test_eq("insert with constructible argument pt2", res13.first->first, 11);
+        test_eq("insert with constructible argument pt3", res13.first->second, std::string{"test"});
+
+        std::unordered_map<int, int> map3{};
+        map3[1] = 1;
+        auto res15 = map3.count(1);
+        test_eq("count", res15, 1U);
+
+        map2.clear();
+        test_eq("clear", map2.empty(), true);
+    }
+
+    void unordered_map_test::test_multi()
+    {
+        auto check_keys = {1, 2, 3, 4, 5, 6, 7};
+        auto check_counts = {1U, 1U, 2U, 1U, 1U, 3U, 1U};
+        auto src = {
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{1, 1},
+            std::pair<const int, int>{5, 5},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{3, 3},
+            std::pair<const int, int>{2, 2},
+            std::pair<const int, int>{7, 7},
+            std::pair<const int, int>{6, 6},
+            std::pair<const int, int>{4, 4}
+        };
+
+        std::unordered_multimap<int, int> mmap{src};
+        test_contains_multi(
+            "multi construction",
+            check_keys.begin(), check_keys.end(),
+            check_counts.begin(), mmap
+        );
+
+        auto res1 = mmap.count(6);
+        test_eq("multi count", res1, 3U);
+
+        auto res2 = mmap.emplace(7, 2);
+        test_eq("multi duplicit emplace pt1", res2->first, 7);
+        test_eq("multi duplicit emplace pt2", res2->second, 2);
+        test_eq("multi duplicit emplace pt3", mmap.count(7), 2U);
+
+        auto res3 = mmap.emplace(8, 5);
+        test_eq("multi unique emplace pt1", res3->first, 8);
+        test_eq("multi unique emplace pt2", res3->second, 5);
+        test_eq("multi unique emplace pt3", mmap.count(8), 1U);
+
+        auto res4 = mmap.insert(std::pair<const int, int>{8, 6});
+        test_eq("multi duplicit insert pt1", res4->first, 8);
+        test_eq("multi duplicit insert pt2", res4->second, 6);
+        test_eq("multi duplicit insert pt3", mmap.count(8), 2U);
+
+        auto res5 = mmap.insert(std::pair<const int, int>{9, 8});
+        test_eq("multi unique insert pt1", res5->first, 9);
+        test_eq("multi unique insert pt2", res5->second, 8);
+        test_eq("multi unique insert pt3", mmap.count(9), 1U);
+
+        auto res6 = mmap.erase(8);
+        test_eq("multi erase by key pt1", res6, 2U);
+        test_eq("multi erase by key pt2", mmap.count(8), 0U);
+
+        // To check that the bucket still works.
+        mmap.insert(std::pair<const int, int>{8, 8});
+        test_eq("multi erase keeps bucket intact", (mmap.find(8) != mmap.end()), true);
+
+        auto res7 = mmap.erase(mmap.find(7));
+        test_eq("multi erase by iterator pt1", res7->first, 7);
+        test_eq("multi erase by iterator pt2", mmap.count(7), 1U);
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/unordered_set.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/unordered_set.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/unordered_set.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <unordered_set>
+#include <string>
+#include <utility>
+
+namespace std::test
+{
+    bool unordered_set_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_constructors_and_assignment();
+        test_emplace_insert();
+        test_multi();
+
+        return end();
+    }
+
+    const char* unordered_set_test::name()
+    {
+        return "unordered_set";
+    }
+
+    void unordered_set_test::test_constructors_and_assignment()
+    {
+        auto check1 = {1, 2, 3, 4, 5, 6, 7};
+        auto src1 = {3, 1, 5, 2, 7, 6, 4};
+
+        std::unordered_set<int> s1{src1};
+        test_contains(
+            "initializer list initialization",
+            check1.begin(), check1.end(), s1
+        );
+        test_eq("size", s1.size(), 7U);
+
+        std::unordered_set<int> s2{src1.begin(), src1.end()};
+        test_contains(
+            "iterator range initialization",
+            check1.begin(), check1.end(), s2
+        );
+
+        std::unordered_set<int> s3{s1};
+        test_contains(
+            "copy initialization",
+            check1.begin(), check1.end(), s3
+        );
+
+        std::unordered_set<int> s4{std::move(s1)};
+        test_contains(
+            "move initialization",
+            check1.begin(), check1.end(), s4
+        );
+        test_eq("move initialization - origin empty", s1.size(), 0U);
+        test_eq("empty", s1.empty(), true);
+
+        s1 = s4;
+        test_contains(
+            "copy assignment",
+            check1.begin(), check1.end(), s1
+        );
+
+        s4 = std::move(s1);
+        test_contains(
+            "move assignment",
+            check1.begin(), check1.end(), s4
+        );
+        test_eq("move assignment - origin empty", s1.size(), 0U);
+
+        s1 = src1;
+        test_contains(
+            "initializer list assignment",
+            check1.begin(), check1.end(), s1
+        );
+    }
+
+    void unordered_set_test::test_emplace_insert()
+    {
+        std::unordered_set<int> set1{};
+
+        auto res1 = set1.emplace(1);
+        test_eq("first emplace succession", res1.second, true);
+        test_eq("first emplace equivalence", *res1.first, 1);
+
+        auto res2 = set1.emplace(1);
+        test_eq("second emplace failure", res2.second, false);
+        test_eq("second emplace equivalence", *res2.first, 1);
+
+        auto res3 = set1.emplace_hint(set1.begin(), 2);
+        test_eq("first emplace_hint succession", (res3 != set1.end()), true);
+        test_eq("first emplace_hint equivalence", *res3, 2);
+
+        auto res4 = set1.emplace_hint(set1.begin(), 2);
+        test_eq("second emplace_hint failure", (res4 != set1.end()), true);
+        test_eq("second emplace_hint equivalence", *res4, 2);
+
+        std::unordered_set<std::string> set2{};
+        auto res5 = set2.insert("A");
+        test_eq("conversion insert succession", res5.second, true);
+        test_eq("conversion insert equivalence", *res5.first, std::string{"A"});
+
+        auto res6 = set2.insert(std::string{"B"});
+        test_eq("first insert succession", res6.second, true);
+        test_eq("first insert equivalence", *res6.first, std::string{"B"});
+
+        auto res7 = set2.insert(std::string{"B"});
+        test_eq("second insert failure", res7.second, false);
+        test_eq("second insert equivalence", *res7.first, std::string{"B"});
+
+        auto res10 = set1.erase(set1.find(2));
+        test_eq("erase", set1.find(2), set1.end());
+        test_eq("highest erased", res10, set1.end());
+
+        set2.insert(std::string{"G"});
+        set2.insert(std::string{"H"});
+        set2.insert(std::string{"K"});
+        auto res11 = set2.erase(std::string{"G"});
+        test_eq("erase by key pt1", res11, 1U);
+        auto res12 = set2.erase(std::string{"M"});
+        test_eq("erase by key pt2", res12, 0U);
+
+        std::unordered_set<int> set3{};
+        set3.insert(1);
+        auto res13 = set3.erase(1);
+        test_eq("erase only element by key pt1", res13, 1U);
+        test_eq("erase only element by key pt2", set3.empty(), true);
+
+        set3.insert(3);
+        auto res14 = set3.erase(set3.begin());
+        test_eq("erase only element by iterator pt1", res14, set3.end());
+        test_eq("erase only element by iterator pt2", set3.empty(), true);
+
+        set2.clear();
+        test_eq("clear", set2.empty(), true);
+
+        set3.insert(1);
+        auto res15 = set3.count(1);
+        test_eq("count", res15, 1U);
+
+        set3.insert(15);
+        auto res16 = set3.find(15);
+        test_eq("find", *res16, 15);
+    }
+
+    void unordered_set_test::test_multi()
+    {
+        auto check_keys = {1, 2, 3, 4, 5, 6, 7};
+        auto check_counts = {1U, 1U, 2U, 1U, 1U, 3U, 1U};
+        auto src1 = {3, 6, 1, 5, 6, 3, 2, 7, 6, 4};
+
+        std::unordered_multiset<int> mset{src1};
+        test_contains_multi(
+            "multi construction",
+            check_keys.begin(), check_keys.end(),
+            check_counts.begin(), mset
+        );
+
+        auto res1 = mset.count(6);
+        test_eq("multi count", res1, 3U);
+
+        auto res2 = mset.emplace(7);
+        test_eq("multi duplicit emplace pt1", *res2, 7);
+        test_eq("multi duplicit emplace pt2", mset.count(7), 2U);
+
+        auto res3 = mset.emplace(8);
+        test_eq("multi unique emplace pt1", *res3, 8);
+        test_eq("multi unique emplace pt2", mset.count(8), 1U);
+
+        auto res4 = mset.insert(8);
+        test_eq("multi duplicit insert pt1", *res4, 8);
+        test_eq("multi duplicit insert pt2", mset.count(8), 2U);
+
+        auto res5 = mset.insert(9);
+        test_eq("multi unique insert pt1", *res5, 9);
+        test_eq("multi unique insert pt2", mset.count(9), 1U);
+
+        auto res6 = mset.erase(8);
+        test_eq("multi erase by key pt1", res6, 2U);
+        test_eq("multi erase by key pt2", mset.count(8), 0U);
+
+        auto res7 = mset.erase(mset.find(7));
+        test_eq("multi erase by iterator pt1", *res7, 7);
+        test_eq("multi erase by iterator pt2", mset.count(7), 1U);
+    }
+}
Index: uspace/lib/cpp/src/__bits/test/vector.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/test/vector.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/test/vector.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <algorithm>
+#include <initializer_list>
+#include <__bits/test/tests.hpp>
+#include <utility>
+#include <vector>
+
+namespace std::test
+{
+    bool vector_test::run(bool report)
+    {
+        report_ = report;
+        start();
+
+        test_construction_and_assignment();
+        test_insert();
+        test_erase();
+
+        return end();
+    }
+
+    const char* vector_test::name()
+    {
+        return "vector";
+    }
+
+    void vector_test::test_construction_and_assignment()
+    {
+        auto check1 = {1, 2, 3, 4};
+        auto check2 = {4, 3, 2, 1};
+        auto check3 = {5, 5, 5, 5};
+
+        std::vector<int> vec1{};
+        vec1.push_back(1);
+        vec1.push_back(2);
+        vec1.push_back(3);
+        vec1.push_back(4);
+        test_eq(
+            "default constructor + push_back",
+            vec1.begin(), vec1.end(),
+            check1.begin(), check1.end()
+        );
+
+        std::vector<int> vec2{4, 3, 2, 1};
+        test_eq(
+            "initializer list constructor",
+            vec2.begin(), vec2.end(),
+            check2.begin(), check2.end()
+        );
+
+        std::vector<int> vec3(11);
+        test_eq("capacity constructor", 11ul, vec3.capacity());
+
+        std::vector<int> vec4(4ul, 5);
+        test_eq(
+            "replication constructor",
+            vec4.begin(), vec4.end(),
+            check3.begin(), check3.end()
+        );
+
+        // TODO: iterator constructor when implemented
+
+        std::vector<int> vec6{vec4};
+        test_eq(
+            "copy constructor",
+            vec6.begin(), vec6.end(),
+            vec4.begin(), vec4.end()
+        );
+
+        std::vector<int> vec7{std::move(vec6)};
+        test_eq(
+            "move constructor equality",
+            vec7.begin(), vec7.end(),
+            vec4.begin(), vec4.end()
+        );
+        test_eq(
+            "move constructor source empty",
+            vec6.size(), 0ul
+        );
+
+        std::vector<int> vec8{check1};
+        test_eq(
+            "explicit initializer list constructor",
+            vec8.begin(), vec8.end(),
+            check1.begin(), check1.end()
+        );
+
+        std::vector<int> vec9{};
+        vec9 = vec8;
+        test_eq(
+            "copy assignment",
+            vec9.begin(), vec9.end(),
+            vec8.begin(), vec8.end()
+        );
+
+        // TODO: move assignment when implemented
+        std::vector<int> vec10{};
+        vec10 = std::move(vec9);
+        test_eq(
+            "move assignment",
+            vec10.begin(), vec10.end(),
+            vec8.begin(), vec8.end()
+        );
+
+        test_eq("move assignment origin empty", vec9.size(), 0U);
+    }
+
+    void vector_test::test_insert()
+    {
+        auto check1 = {1, 2, 3, 99, 4, 5};
+        auto check2 = {1, 2, 3, 99, 99, 99, 99, 99, 4, 5};
+        auto check3 = {1, 2, 3, 1, 2, 3, 99, 4, 5, 4, 5};
+
+        std::vector<int> vec1{1, 2, 3, 4, 5};
+        auto it = vec1.insert(vec1.begin() + 3, 99);
+        test_eq(
+            "single element insert",
+            vec1.begin(), vec1.end(),
+            check1.begin(), check1.end()
+        );
+        test_eq(
+            "iterator returned from insert",
+            *it, 99
+        );
+
+        std::vector<int> vec2{1, 2, 3, 4, 5};
+        vec2.insert(vec2.begin() + 3, 5ul, 99);
+        test_eq(
+            "multiple element insert",
+            vec2.begin(), vec2.end(),
+            check2.begin(), check2.end()
+        );
+
+        std::vector<int> vec3{1, 2, 3, 4, 5};
+        vec3.insert(vec3.begin() + 3, vec2.begin() + 3, vec2.begin() + 8);
+        test_eq(
+            "iterator insert",
+            vec3.begin(), vec3.end(),
+            check2.begin(), check2.end()
+        );
+
+        std::vector<int> vec4{1, 2, 3, 4, 5};
+        vec4.insert(vec4.begin() + 3, check1);
+        test_eq(
+            "initializer list insert",
+            vec4.begin(), vec4.end(),
+            check3.begin(), check3.end()
+        );
+
+        std::vector<int> vec5{1, 2, 3, 4, 5};
+        vec5.insert(vec5.begin() + 3, {1, 2, 3, 99, 4, 5});
+        test_eq(
+            "implicit initializer list insert",
+            vec5.begin(), vec5.end(),
+            check3.begin(), check3.end()
+        );
+
+        std::vector<int> vec6{};
+        vec6.insert(vec6.begin(), check3);
+        test_eq(
+            "insert to empty vector",
+            vec6.begin(), vec6.end(),
+            check3.begin(), check3.end()
+        );
+    }
+
+    void vector_test::test_erase()
+    {
+        auto check1 = {1, 2, 3, 5};
+        auto check2 = {1, 5};
+        auto check3 = {1, 3, 5};
+
+        std::vector<int> vec1{1, 2, 3, 4, 5};
+        vec1.erase(vec1.begin() + 3);
+        test_eq(
+            "single element erase",
+            vec1.begin(), vec1.end(),
+            check1.begin(), check1.end()
+        );
+
+        std::vector<int> vec2{1, 2, 3, 4, 5};
+        vec2.erase(vec2.begin() + 1, vec2.begin() + 4);
+        test_eq(
+            "range erase",
+            vec2.begin(), vec2.end(),
+            check2.begin(), check2.end()
+        );
+
+        std::vector<int> vec3{1, 2, 3, 4, 5};
+        for (auto it = vec3.begin(); it != vec3.end();)
+        {
+            if (*it % 2 == 0)
+                it = vec3.erase(it);
+            else
+                ++it;
+        }
+        test_eq(
+            "erase all even numbers",
+            vec3.begin(), vec3.end(),
+            check3.begin(), check3.end()
+        );
+    }
+}
Index: uspace/lib/cpp/src/__bits/trycatch.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/trycatch.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/trycatch.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2018 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <__bits/trycatch.hpp>
+
+bool ::std::aux::exception_thrown{false};
Index: uspace/lib/cpp/src/__bits/unwind.cpp
===================================================================
--- uspace/lib/cpp/src/__bits/unwind.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
+++ uspace/lib/cpp/src/__bits/unwind.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2017 Jaroslav Jindrak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdint>
+#include <cstdlib>
+
+namespace __cxxabiv1
+{
+    /**
+     * Stack unwinding functionality - Level 1.
+     */
+
+    enum _Unwind_Reason_Code
+    {
+        _URC_NO_REASON                = 0,
+        _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
+        _URC_FATAL_PHASE2_ERROR       = 2,
+        _URC_FATAL_PHASE1_ERROR       = 3,
+        _URC_NORMAL_STOP              = 4,
+        _URC_END_OF_STACK             = 5,
+        _URC_HANDLER_FOUND            = 6,
+        _URC_INSTALL_CONTEXT          = 7,
+        _URC_CONTINUE_UNWIND          = 8
+    };
+
+    struct _Unwind_Exception;
+    using _Unwind_Exception_Cleanup_Fn = void (*)(_Unwind_Reason_Code, _Unwind_Exception*);
+
+    struct _Unwind_Exception
+    {
+        std::uint64_t exception_class;
+        _Unwind_Exception_Cleanup_Fn exception_cleanup;
+        std::uint64_t private_1;
+        std::uint64_t private_2;
+    };
+
+    /* Opaque structure. */
+    struct _Unwind_Context;
+
+    using _Unwind_Action = int;
+    namespace
+    {
+        const _Unwind_Action _UA_SEARCH_PHASE  = 1;
+        const _Unwind_Action _UA_CLEANUP_PHASE = 2;
+        const _Unwind_Action _UA_HANDLER_FRAME = 4;
+        const _Unwind_Action _UA_FORCE_HANDLER = 8;
+    }
+
+    /**
+     * TODO: Explain parameter semantics.
+     */
+    using _Unwind_Stop_Fn = _Unwind_Reason_Code(*)(
+        int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
+        _Unwind_Context*, void*
+    );
+
+    extern "C" _Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception*, _Unwind_Stop_Fn, void*)
+    {
+        // TODO: implement
+        return _URC_NO_REASON;
+    }
+
+    extern "C" void _Unwind_Resume(_Unwind_Exception*)
+    {
+        // TODO: implement
+    }
+
+    extern "C" void _Unwind_DeleteException(_Unwind_Exception*)
+    {
+        // TODO: implement
+    }
+
+    extern "C" std::uint64_t _Unwind_GetGR(_Unwind_Context*, int)
+    {
+        // TODO: implement
+        return 0;
+    }
+
+    extern "C" void _Unwind_SetGR(_Unwind_Context*, int, std::uint64_t)
+    {
+        // TODO: implement
+    }
+
+    extern "C" std::uint64_t _Unwind_GetIP(_Unwind_Context*)
+    {
+        // TODO: implement
+        return 0;
+    }
+
+    extern "C" void _Unwind_SetIP(_Unwind_Context*, std::uint64_t)
+    {
+        // TODO: implement
+    }
+
+    extern "C" std::uint64_t _Unwind_GetLanguageSpecificData(_Unwind_Context*)
+    {
+        // TODO: implement
+        return 0;
+    }
+
+    extern "C" std::uint64_t _Unwind_GetRegionStart(_Unwind_Context*)
+    {
+        // TODO: implement
+        return 0;
+    }
+
+    /**
+     * TODO: Explain parameter semantics.
+     */
+    using __personality_routine = _Unwind_Reason_Code(*)(
+        int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
+        _Unwind_Context*, void*
+    );
+
+    /**
+     * Stack unwinding functionality - Level 2.
+     */
+    struct __cxa_exception
+    {
+        std::type_info* exceptionType;
+        void (*exceptionDestructor)(void*);
+        // TODO: Add handler types to <exception>.
+        /* std::unexpected_handler unexpectedHandler; */
+        void (*unexpectedHandler)();
+        /* std::terminate_handler terminateHandler; */
+        void (*terminateHandler)();
+        __cxa_exception* nextException;
+
+        int handlerCount;
+        int handlerSwitchValue;
+        const char* actionRecord;
+        const char* languageSpecificData;
+        void* catchTemp;
+        void* adjujstedPtr;
+
+        _Unwind_Exception unwindHeader;
+    };
+
+    struct __cxa_eh_globals
+    {
+        __cxa_exception* caughtExceptions;
+        unsigned int uncaughtExceptions;
+    };
+
+    extern "C" __cxa_eh_globals* __cxa_get_globals();
+
+    extern "C" __cxa_eh_globals* __cxa_get_globals_fast();
+
+    extern "C" void* __cxa_allocate_exception(std::size_t thrown_size)
+    {
+        // TODO: implement
+        return nullptr;
+    }
+
+    extern "C" void __cxa_free_exception(void* thrown_exception)
+    {
+        // TODO: implement
+    }
+
+    extern "C" void __cxa_throw(void* thrown_exception, std::type_info* tinfo, void (*dest)(void*))
+    {
+        // TODO: implement
+    }
+
+    extern "C" void* __cxa_get_exception_ptr(void*  exception_object)
+    {
+        // TODO: implement
+        return nullptr;
+    }
+
+    extern "C" void* __cxa_begin_catch(void* exception_object)
+    {
+        // TODO: implement
+        return nullptr;
+    }
+
+    extern "C" void __cxa_end_catch()
+    {
+        // TODO: implement
+    }
+
+    extern "C" void __cxa_rethrow()
+    {
+        // TODO: implement
+    }
+
+    extern "C" void __cxa_bad_cast()
+    {
+        // TODO: implement
+    }
+
+    extern "C" void __cxa_bad_typeid()
+    {
+        // TODO: implement
+    }
+
+    extern "C" void __cxa_throw_bad_array_new_length()
+    {
+        // TODO: implement
+    }
+}
Index: pace/lib/cpp/src/internal/runtime.cpp
===================================================================
--- uspace/lib/cpp/src/internal/runtime.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,196 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <cstdlib>
-#include <cstdint>
-#include <internal/abi.hpp>
-#include <exception>
-#include <mutex>
-
-namespace __cxxabiv1
-{
-    namespace aux
-    {
-        struct destructor_t
-        {
-            void (*func)(void*);
-            void* ptr;
-            void* dso;
-        };
-
-        destructor_t* destructors{nullptr};
-        std::size_t destructor_count{0};
-        std::size_t destructor_size{32};
-
-        /**
-         * C atexit does not pass any arguments,
-         * but __cxa_finalize requires one so we
-         * use a wrapper.
-         */
-        void atexit_destructors()
-        {
-            __cxa_finalize(nullptr);
-        }
-    }
-
-    /**
-     * No need for a body, this function is called when a virtual
-     * call of a pure virtual function cannot be made.
-     */
-    extern "C" void __cxa_pure_call()
-    {
-        std::terminate();
-    }
-
-    extern "C" int __cxa_atexit(void (*f)(void*), void* p, void* d)
-    {
-        if (!aux::destructors)
-        {
-            aux::destructors = new aux::destructor_t[aux::destructor_size];
-            std::atexit(aux::atexit_destructors);
-        }
-        else if (aux::destructor_count >= aux::destructor_size)
-        {
-            auto tmp = std::realloc(aux::destructors, aux::destructor_size * 2);
-
-            if (!tmp)
-                return -1;
-
-            aux::destructors = static_cast<aux::destructor_t*>(tmp);
-            aux::destructor_size *= 2;
-        }
-
-        auto& destr = aux::destructors[aux::destructor_count++];
-        destr.func = f;
-        destr.ptr = p;
-        destr.dso = d;
-
-        return 0;
-    }
-
-    extern "C" void __cxa_finalize(void *f)
-    {
-        if (!f)
-        {
-            for (std::size_t i = aux::destructor_count; i > 0; --i)
-            {
-                if (aux::destructors[i - 1].func)
-                    (*aux::destructors[i - 1].func)(aux::destructors[i - 1].ptr);
-            }
-        }
-        else
-        {
-            for (std::size_t i = aux::destructor_count; i > 0; --i)
-            {
-                if (aux::destructors[i - 1].func == f)
-                {
-                    (*aux::destructors[i - 1].func)(aux::destructors[i - 1].ptr);
-                    aux::destructors[i - 1].func = nullptr;
-                    aux::destructors[i - 1].ptr = nullptr;
-                    aux::destructors[i - 1].dso = nullptr;
-                    // TODO: shift and decrement count
-                }
-            }
-        }
-    }
-
-    using guard_t = std::uint64_t;
-    std::mutex static_guard_mtx{};
-
-    extern "C" int __cxa_guard_acquire(guard_t* guard)
-    {
-        static_guard_mtx.lock();
-
-        return !*((std::uint8_t*)guard);
-    }
-
-    extern "C" void __cxa_guard_release(guard_t* guard)
-    {
-        *((std::uint8_t*)guard) = 1;
-
-        static_guard_mtx.unlock();
-    }
-
-    extern "C" void __cxa_guard_abort(guard_t* guard)
-    {
-        static_guard_mtx.unlock();
-    }
-
-    __fundamental_type_info::~__fundamental_type_info()
-    { /* DUMMY BODY */ }
-
-    __array_type_info::~__array_type_info()
-    { /* DUMMY BODY */ }
-
-    __function_type_info::~__function_type_info()
-    { /* DUMMY BODY */ }
-
-    __enum_type_info::~__enum_type_info()
-    { /* DUMMY BODY */ }
-
-    __class_type_info::~__class_type_info()
-    { /* DUMMY BODY */ }
-
-    __si_class_type_info::~__si_class_type_info()
-    { /* DUMMY BODY */ }
-
-    __vmi_class_type_info::~__vmi_class_type_info()
-    { /* DUMMY BODY */ }
-
-    __pbase_type_info::~__pbase_type_info()
-    { /* DUMMY BODY */ }
-
-    __pointer_type_info::~__pointer_type_info()
-    { /* DUMMY BODY */ }
-
-    __pointer_to_member_type_info::~__pointer_to_member_type_info()
-    { /* DUMMY BODY */ }
-
-    /**
-     * This structure represents part of the vtable segment
-     * that contains data related to dynamic_cast.
-     */
-    struct vtable
-    {
-        // Unimportant to us.
-
-        std::ptrdiff_t offset_to_top;
-        std::type_info* tinfo;
-
-        // Actual vtable.
-    };
-    extern "C" void* __dynamic_cast(const void* sub, const __class_type_info* src,
-                                    const __class_type_info* dst, std::ptrdiff_t offset)
-    {
-        // TODO: implement
-        // NOTE: as far as I understand it, we get vtable prefix from sub, get the type_info
-        //       ptr from that and then climb the inheritance hierarchy upwards till we either
-        //       fint dst or fail and return nullptr
-        return nullptr;
-    }
-}
Index: pace/lib/cpp/src/internal/test/adaptors.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/adaptors.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,195 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <cstdlib>
-#include <deque>
-#include <functional>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <iterator>
-#include <queue>
-#include <stack>
-#include <vector>
-
-namespace std::test
-{
-    namespace aux
-    {
-        template<class T, class Comp = std::less<T>>
-        class priority_queue_iterator
-        {
-            public:
-                using value_type      = T;
-                using reference       = const T&;
-                using size_type       = size_t;
-                using pointer         = value_type*;
-                using difference_type = size_t;
-
-                using iterator_category = forward_iterator_tag;
-
-                priority_queue_iterator(
-                    priority_queue<value_type, std::vector<value_type>, Comp> q,
-                    bool end = false
-                )
-                    : queue_{q}, end_{end}
-                { /* DUMMY BODY */ }
-
-                priority_queue_iterator(const priority_queue_iterator& other)
-                    : queue_{other.queue_}, end_{other.end_}
-                { /* DUMMY BODY */ }
-
-                reference operator*()
-                {
-                    return queue_.top();
-                }
-
-                priority_queue_iterator& operator++()
-                {
-                    queue_.pop();
-
-                    if (queue_.empty())
-                        end_ = true;
-
-                    return *this;
-                }
-
-                priority_queue_iterator operator++(int)
-                {
-                    auto old = *this;
-                    ++(*this);
-
-                    return old;
-                }
-
-                bool operator==(const priority_queue_iterator& rhs) const
-                {
-                    return end_ == rhs.end_;
-                }
-
-                bool operator!=(const priority_queue_iterator& rhs) const
-                {
-                    return !(*this == rhs);
-                }
-
-            private:
-                priority_queue<value_type, std::vector<value_type>, Comp> queue_;
-                bool end_;
-        };
-    }
-
-    bool adaptors_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_queue();
-        test_priority_queue();
-        test_stack();
-
-        return end();
-    }
-
-    const char* adaptors_test::name()
-    {
-        return "adaptors";
-    }
-
-    void adaptors_test::test_queue()
-    {
-        std::queue<int> q{std::deque<int>{1}};
-
-        test_eq("queue initialized from deque not empty", q.empty(), false);
-        test_eq("queue initialized form queue size", q.size(), 1U);
-        test_eq("single element queue front == back", q.front(), q.back());
-
-        q.push(2);
-        test_eq("queue push", q.back(), 2);
-        test_eq("queue size", q.size(), 2U);
-
-        q.pop();
-        test_eq("queue pop", q.front(), 2);
-
-        q.emplace(4);
-        test_eq("queue emplace", q.back(), 4);
-    }
-
-    void adaptors_test::test_priority_queue()
-    {
-        auto check1 = {9, 8, 5, 4, 2, 1};
-        std::vector<int> data{5, 4, 2, 8, 1};
-        std::priority_queue<int> q1{data.begin(), data.end()};
-
-        test_eq("priority_queue initialized from iterator range not empty", q1.empty(), false);
-        test_eq("priority_queue initialized from iterator range size", q1.size(), 5U);
-
-        q1.push(9);
-        test_eq("priority_queue push pt1", q1.size(), 6U);
-        test_eq("priority_queue push pt2", q1.top(), 9);
-
-        test_eq(
-            "priority_queue initialized from iterator range ops",
-            check1.begin(), check1.end(),
-            aux::priority_queue_iterator<int>{q1},
-            aux::priority_queue_iterator<int>{q1, true}
-        );
-
-        auto check2 = {1, 2, 3, 4, 5, 8};
-        std::priority_queue<int, std::vector<int>, std::greater<int>> q2{std::greater<int>{}, data};
-
-        test_eq("priority_queue initialized from vector and compare not empty", q2.empty(), false);
-        test_eq("priority_queue initialized from vector and compare size", q2.size(), 5U);
-
-        q2.push(3);
-        test_eq("priority_queue push pt1", q2.size(), 6U);
-        test_eq("priority_queue push pt2", q2.top(), 1);
-
-        test_eq(
-            "priority_queue initialized from vector and compare ops",
-            check2.begin(), check2.end(),
-            aux::priority_queue_iterator<int, std::greater<int>>{q2},
-            aux::priority_queue_iterator<int, std::greater<int>>{q2, true}
-        );
-    }
-
-    void adaptors_test::test_stack()
-    {
-        std::stack<int> s{std::deque<int>{1}};
-
-        test_eq("stack initialized from deque top", s.top(), 1);
-        test_eq("stack initialized from deque size", s.size(), 1U);
-        test_eq("stack initialized from deque not empty", s.empty(), false);
-
-        s.push(2);
-        test_eq("stack push top", s.top(), 2);
-        test_eq("stack push size", s.size(), 2U);
-
-        s.pop();
-        test_eq("stack pop top", s.top(), 1);
-        test_eq("stack pop size", s.size(), 1U);
-    }
-}
Index: pace/lib/cpp/src/internal/test/array.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/array.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <algorithm>
-#include <array>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-
-namespace std::test
-{
-    bool array_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        auto check1 = {1, 2, 3, 4};
-        auto check2 = {4, 3, 2, 1};
-        auto check3 = {5, 5, 5, 5};
-
-        std::array<int, 4> arr1{1, 2, 3, 4};
-        test_eq(
-            "initializer list construction",
-            arr1.begin(), arr1.end(),
-            check1.begin(), check1.end()
-        );
-
-        auto it = arr1.begin();
-        test_eq(
-            "iterator increment",
-            *(++it), arr1[1]
-        );
-        test_eq(
-            "iterator decrement",
-            *(--it), arr1[0]
-        );
-
-        std::array<int, 4> arr2{arr1};
-        test_eq(
-            "copy construction",
-            arr1.begin(), arr1.end(),
-            arr2.begin(), arr2.end()
-        );
-
-        std::reverse(arr2.begin(), arr2.end());
-        test_eq(
-            "reverse",
-            arr2.begin(), arr2.end(),
-            check2.begin(), check2.end()
-        );
-        test_eq(
-            "reverse iterator",
-            arr1.rbegin(), arr1.rend(),
-            arr2.begin(), arr2.end()
-        );
-
-
-        std::array<int, 4> arr3{};
-        arr3.fill(5);
-        test_eq(
-            "fill",
-            arr3.begin(), arr3.end(),
-            check3.begin(), check3.end()
-        );
-
-        arr2.swap(arr3);
-        test_eq(
-            "swap part 1",
-            arr2.begin(), arr2.end(),
-            check3.begin(), check3.end()
-        );
-        test_eq(
-            "swap part 2",
-            arr3.begin(), arr3.end(),
-            check2.begin(), check2.end()
-        );
-
-        // TODO: test bound checking of at when implemented
-
-        std::array<int, 3> arr4{1, 2, 3};
-        auto [a, b, c] = arr4;
-        test_eq("structured binding part 1", a, 1);
-        test_eq("structured binding part 2", b, 2);
-        test_eq("structured binding part 3", c, 3);
-
-        return end();
-    }
-
-    const char* array_test::name()
-    {
-        return "array";
-    }
-}
Index: pace/lib/cpp/src/internal/test/bitset.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/bitset.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,199 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <bitset>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <sstream>
-#include <string>
-
-namespace std::test
-{
-    bool bitset_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_constructors_and_assignment();
-        test_strings();
-        test_operations();
-
-        return end();
-    }
-
-    const char* bitset_test::name()
-    {
-        return "bitset";
-    }
-
-    void bitset_test::test_constructors_and_assignment()
-    {
-        // 00101010bin == 42dec (note that the bits are reversed in bitset)
-        auto check1 = {false, true, false, true, false, true, false, false};
-        std::bitset<8> b1{42};
-        test_eq(
-            "from number to number equivalence",
-            b1.to_ulong(), 42UL
-        );
-
-        auto it = check1.begin();
-        size_t i{};
-        for (; i < 8U; ++i)
-        {
-            if (*it++ != b1[i])
-                break;
-        }
-        test_eq("from number iterating over bits", i, 8U);
-
-        std::bitset<8> b2{"00101010"};
-        test_eq(
-            "from string to number equivalence",
-            b2.to_ulong(), 42UL
-        );
-
-        it = check1.begin();
-        i = size_t{};
-        for (; i < 8U; ++i)
-        {
-            if (*it++ != b2[i])
-                break;
-        }
-        test_eq("from string iterating over bits", i, 8U);
-
-        std::bitset<16> b3{0b1111'1101'1011'1010};
-        test_eq(
-            "from binary to number equivalence",
-            b3.to_ulong(), 0b1111'1101'1011'1010UL
-        );
-
-        std::bitset<64> b4{0xABCD'DCBA'DEAD'BEEF};
-        test_eq(
-            "from hex to number equivalence",
-            b4.to_ulong(), 0xABCD'DCBA'DEAD'BEEF
-        );
-
-        std::bitset<8> b5{"XXYXYXYX", 8U, 'X', 'Y'};
-        test_eq(
-            "from string with different 0/1 values equivalence",
-            b5.to_ulong(), 42U
-        );
-
-        std::bitset<8> b6{"XXYXYXYXXXX IGNORED", 8U, 'X', 'Y'};
-        test_eq(
-            "from prefix string with different 0/1 values equivalence",
-            b6.to_ulong(), 42U
-        );
-
-        std::bitset<8> b7{std::string{"XXXXYXYXYX"}, 2U, 8U, 'X', 'Y'};
-        test_eq(
-            "from substring with different 0/1 values equivalence",
-            b7.to_ulong(), 42U
-        );
-    }
-
-    void bitset_test::test_strings()
-    {
-        std::bitset<8> b1{42};
-        auto s1 = b1.to_string();
-        test_eq(
-            "to string",
-            s1, "00101010"
-        );
-
-        auto s2 = b1.to_string('X', 'Y');
-        test_eq(
-            "to string string with different 0/1 values",
-            s2, "XXYXYXYX"
-        );
-
-        std::istringstream iss{"00101010"};
-        std::bitset<8> b2{};
-        iss >> b2;
-        test_eq(
-            "istream operator>>",
-            b2.to_ulong(), 42UL
-        );
-
-        std::ostringstream oss{};
-        oss << b2;
-        std::string s3{oss.str()};
-        std::string s4{"00101010"};
-        test_eq(
-            "ostream operator<<",
-            s3, s4
-        );
-    }
-
-    void bitset_test::test_operations()
-    {
-        std::bitset<8> b1{};
-
-        b1.set(3);
-        test_eq("set", b1[3], true);
-
-        b1.reset(3);
-        test_eq("reset", b1[3], false);
-
-        b1.flip(3);
-        test_eq("flip", b1[3], true);
-
-        b1 >>= 1;
-        test_eq("lshift new", b1[2], true);
-        test_eq("lshift old", b1[3], false);
-
-        b1 <<= 1;
-        test_eq("rshift new", b1[2], false);
-        test_eq("rshift old", b1[3], true);
-
-        test_eq("any1", b1.any(), true);
-        test_eq("none1", b1.none(), false);
-        test_eq("all1", b1.all(), false);
-
-        b1 <<= 7;
-        test_eq("any2", b1.any(), false);
-        test_eq("none2", b1.none(), true);
-        test_eq("all2", b1.all(), false);
-
-        b1.set();
-        test_eq("set + all", b1.all(), true);
-
-        b1.reset();
-        test_eq("reset + none", b1.none(), true);
-
-        std::bitset<8> b2{0b0101'0101};
-        std::bitset<8> b3{0b1010'1010};
-        b2.flip();
-        test_eq("flip all", b2, b3);
-
-        std::bitset<8> b4{0b0011'0101};
-        std::bitset<8> b5{0b1010'1100};
-        test_eq("and", (b4 & b5), std::bitset<8>{0b0010'0100});
-        test_eq("or", (b4 | b5), std::bitset<8>{0b1011'1101});
-        test_eq("count", b4.count(), 4U);
-    }
-}
Index: pace/lib/cpp/src/internal/test/deque.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/deque.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,295 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <deque>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <utility>
-
-namespace std::test
-{
-    bool deque_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_constructors_and_assignment();
-        test_resizing();
-        test_push_pop();
-        test_operations();
-
-        return end();
-    }
-
-    const char* deque_test::name()
-    {
-        return "deque";
-    }
-
-    void deque_test::test_constructors_and_assignment()
-    {
-        auto check1 = {0, 0, 0, 0, 0};
-        std::deque<int> d1(5U);
-        test_eq(
-            "size construction",
-            check1.begin(), check1.end(),
-            d1.begin(), d1.end()
-        );
-
-        auto check2 = {1, 1, 1, 1, 1};
-        std::deque<int> d2(5U, 1);
-        test_eq(
-            "value construction",
-            check2.begin(), check2.end(),
-            d2.begin(), d2.end()
-        );
-
-        auto check3 = {1, 2, 3, 4, 5};
-        std::deque<int> d3{check3.begin(), check3.end()};
-        test_eq(
-            "iterator range construction",
-            check3.begin(), check3.end(),
-            d3.begin(), d3.end()
-        );
-
-        std::deque<int> d4{d3};
-        test_eq(
-            "copy construction",
-            check3.begin(), check3.end(),
-            d4.begin(), d4.end()
-        );
-
-        std::deque<int> d5{std::move(d4)};
-        test_eq(
-            "move construction",
-            check3.begin(), check3.end(),
-            d5.begin(), d5.end()
-        );
-        test_eq("move construction - origin empty", d4.empty(), true);
-
-        std::deque<int> d6{check3};
-        test_eq(
-            "inializer list construction",
-            check3.begin(), check3.end(),
-            d6.begin(), d6.end()
-        );
-
-        d4 = d6;
-        test_eq(
-            "copy assignment",
-            check3.begin(), check3.end(),
-            d4.begin(), d4.end()
-        );
-
-        d6 = std::move(d4);
-        test_eq(
-            "move assignment",
-            check3.begin(), check3.end(),
-            d6.begin(), d6.end()
-        );
-        test_eq("move assignment - origin empty", d4.empty(), true);
-
-        d4 = check3;
-        test_eq(
-            "initializer list assignment",
-            check3.begin(), check3.end(),
-            d4.begin(), d4.end()
-        );
-
-        std::deque<int> d7{};
-        d7.assign(check3.begin(), check3.end());
-        test_eq(
-            "iterator range assign()",
-            check3.begin(), check3.end(),
-            d7.begin(), d7.end()
-        );
-
-        d7.assign(5U, 1);
-        test_eq(
-            "value assign()",
-            check2.begin(), check2.end(),
-            d7.begin(), d7.end()
-        );
-
-        d7.assign(check3);
-        test_eq(
-            "initializer list assign()",
-            check3.begin(), check3.end(),
-            d7.begin(), d7.end()
-        );
-    }
-
-    void deque_test::test_resizing()
-    {
-        auto check1 = {1, 2, 3};
-        auto check2 = {1, 2, 3, 0, 0};
-        std::deque<int> d1{1, 2, 3, 4, 5};
-
-        d1.resize(3U);
-        test_eq(
-            "downsize",
-            check1.begin(), check1.end(),
-            d1.begin(), d1.end()
-        );
-
-        d1.resize(5U);
-        test_eq(
-            "upsize",
-            check2.begin(), check2.end(),
-            d1.begin(), d1.end()
-        );
-
-        auto check3 = {1, 2, 3, 9, 9};
-        std::deque<int> d2{1, 2, 3, 4, 5};
-
-        d2.resize(3U, 9);
-        test_eq(
-            "downsize with default value",
-            check1.begin(), check1.end(),
-            d2.begin(), d2.end()
-        );
-
-        d2.resize(5U, 9);
-        test_eq(
-            "upsize with default value",
-            check3.begin(), check3.end(),
-            d2.begin(), d2.end()
-        );
-
-        d2.resize(0U);
-        test_eq("resize to 0", d2.empty(), true);
-    }
-
-    void deque_test::test_push_pop()
-    {
-        std::deque<int> d1{};
-
-        d1.push_back(42);
-        test_eq("push_back to empty equivalence", d1[0], 42);
-        test_eq("push_back to empty size", d1.size(), 1U);
-
-        d1.push_front(21);
-        test_eq("push_front after push_back equivalence", d1[0], 21);
-        test_eq("push_front after push_back size", d1.size(), 2U);
-
-        for (int i = 0; i <= 100; ++i)
-            d1.push_back(i);
-        test_eq("back after bucket test", d1.back(), 100);
-
-        d1.pop_back();
-        test_eq("back after pop_back", d1.back(), 99);
-        d1.pop_front();
-        test_eq("front after pop_front", d1.back(), 99);
-
-
-        for (int i = 0; i <= 100; ++i)
-            d1.push_front(i);
-        test_eq("front after bucket test", d1.front(), 100);
-
-        std::deque<int> d2{};
-
-        d2.push_front(42);
-        test_eq("push_front to empty equivalence", d2[0], 42);
-        test_eq("push_front to empty size", d2.size(), 1U);
-
-        d2.push_back(21);
-        test_eq("push_back after push_front equivalence", d2[1], 21);
-        test_eq("push_back after push_front size", d2.size(), 2U);
-
-        d2.clear();
-        test_eq("clear() - empty()", d2.empty(), true);
-        test_eq("clear() - iterators", d2.begin(), d2.end());
-    }
-
-    void deque_test::test_operations()
-    {
-        auto check1 = {
-            1, 2, 3, 4, 11, 22, 33, 44, 55, 66, 77, 88,
-            5, 6, 7, 8, 9, 10, 11, 12
-        };
-        auto to_insert = {11, 22, 33, 44, 55, 66, 77, 88};
-
-        std::deque<int> d1{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
-        std::deque<int> d2{d1};
-        std::deque<int> d3{d1};
-        std::deque<int> d4{d1};
-
-        d1.insert(d1.begin() + 5, to_insert.begin(), to_insert.end());
-        test_eq(
-            "insert iterator range",
-            check1.begin(), check1.end(),
-            d1.begin(), d1.end()
-        );
-
-        d2.insert(d2.begin() + 5, to_insert);
-        test_eq(
-            "insert initializer list",
-            check1.begin(), check1.end(),
-            d2.begin(), d2.end()
-        );
-
-        auto check2 = {
-            1, 2, 3, 4, 99, 99, 99, 99, 99, 99, 99, 99,
-            5, 6, 7, 8, 9, 10, 11, 12
-        };
-        d3.insert(d3.begin() + 5, 8U, 99);
-        test_eq(
-            "insert value n times",
-            check2.begin(), check2.end(),
-            d3.begin(), d3.end()
-        );
-
-        auto check3 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
-        d3.erase(d3.begin() + 4, d3.begin() + 12);
-        test_eq(
-            "erase iterator range",
-            check3.begin(), check3.end(),
-            d3.begin(), d3.end()
-        );
-
-        auto check4 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12};
-        d3.erase(d3.begin() + 10);
-        test_eq(
-            "erase",
-            check4.begin(), check4.end(),
-            d3.begin(), d3.end()
-        );
-
-        d2.swap(d3);
-        test_eq(
-            "swap1",
-            check1.begin(), check1.end(),
-            d3.begin(), d3.end()
-        );
-        test_eq(
-            "swap2",
-            check4.begin(), check4.end(),
-            d2.begin(), d2.end()
-        );
-    }
-}
Index: pace/lib/cpp/src/internal/test/map.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/map.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,434 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <map>
-#include <string>
-#include <sstream>
-#include <utility>
-
-namespace std::test
-{
-    bool map_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_constructors_and_assignment();
-        test_histogram();
-        test_emplace_insert();
-        test_bounds_and_ranges();
-        test_multi();
-        test_reverse_iterators();
-        test_multi_bounds_and_ranges();
-
-        return end();
-    }
-
-    const char* map_test::name()
-    {
-        return "map";
-    }
-
-    void map_test::test_constructors_and_assignment()
-    {
-        auto check1 = {
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{4, 4},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{7, 7}
-        };
-        auto src1 = {
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{4, 4}
-        };
-
-        std::map<int, int> m1{src1};
-        test_eq(
-            "initializer list initialization",
-            check1.begin(), check1.end(),
-            m1.begin(), m1.end()
-        );
-        test_eq("size", m1.size(), 7U);
-
-        std::map<int, int> m2{src1.begin(), src1.end()};
-        test_eq(
-            "iterator range initialization",
-            check1.begin(), check1.end(),
-            m2.begin(), m2.end()
-        );
-
-        std::map<int, int> m3{m1};
-        test_eq(
-            "copy initialization",
-            check1.begin(), check1.end(),
-            m3.begin(), m3.end()
-        );
-
-        std::map<int, int> m4{std::move(m1)};
-        test_eq(
-            "move initialization",
-            check1.begin(), check1.end(),
-            m4.begin(), m4.end()
-        );
-        test_eq("move initialization - origin empty", m1.size(), 0U);
-        test_eq("empty", m1.empty(), true);
-
-        m1 = m4;
-        test_eq(
-            "copy assignment",
-            check1.begin(), check1.end(),
-            m1.begin(), m1.end()
-        );
-
-        m4 = std::move(m1);
-        test_eq(
-            "move assignment",
-            check1.begin(), check1.end(),
-            m4.begin(), m4.end()
-        );
-        test_eq("move assignment - origin empty", m1.size(), 0U);
-
-        m1 = src1;
-        test_eq(
-            "initializer list assignment",
-            check1.begin(), check1.end(),
-            m1.begin(), m1.end()
-        );
-    }
-
-    void map_test::test_histogram()
-    {
-        std::string str{"a b a a c d b e a b b e d c a e"};
-        std::map<std::string, std::size_t> map{};
-        std::istringstream iss{str};
-        std::string word{};
-
-        while (iss >> word)
-            ++map[word];
-
-        test_eq("histogram pt1", map["a"], 5U);
-        test_eq("histogram pt2", map["b"], 4U);
-        test_eq("histogram pt3", map["c"], 2U);
-        test_eq("histogram pt4", map["d"], 2U);
-        test_eq("histogram pt5", map["e"], 3U);
-        test_eq("histogram pt6", map["f"], 0U);
-        test_eq("at", map.at("a"), 5U);
-    }
-
-    void map_test::test_emplace_insert()
-    {
-        std::map<int, int> map1{};
-
-        auto res1 = map1.emplace(1, 2);
-        test_eq("first emplace succession", res1.second, true);
-        test_eq("first emplace equivalence pt1", res1.first->first, 1);
-        test_eq("first emplace equivalence pt2", res1.first->second, 2);
-
-        auto res2 = map1.emplace(1, 3);
-        test_eq("second emplace failure", res2.second, false);
-        test_eq("second emplace equivalence pt1", res2.first->first, 1);
-        test_eq("second emplace equivalence pt2", res2.first->second, 2);
-
-        auto res3 = map1.emplace_hint(map1.begin(), 2, 4);
-        test_eq("first emplace_hint succession", (res3 != map1.end()), true);
-        test_eq("first emplace_hint equivalence pt1", res3->first, 2);
-        test_eq("first emplace_hint equivalence pt2", res3->second, 4);
-
-        auto res4 = map1.emplace_hint(map1.begin(), 2, 5);
-        test_eq("second emplace_hint failure", (res4 != map1.end()), true);
-        test_eq("second emplace_hint equivalence pt1", res4->first, 2);
-        test_eq("second emplace_hint equivalence pt2", res4->second, 4);
-
-        std::map<int, std::string> map2{};
-        auto res5 = map2.insert(std::pair<const int, const char*>{5, "A"});
-        test_eq("conversion insert succession", res5.second, true);
-        test_eq("conversion insert equivalence pt1", res5.first->first, 5);
-        test_eq("conversion insert equivalence pt2", res5.first->second, std::string{"A"});
-
-        auto res6 = map2.insert(std::pair<const int, std::string>{6, "B"});
-        test_eq("first insert succession", res6.second, true);
-        test_eq("first insert equivalence pt1", res6.first->first, 6);
-        test_eq("first insert equivalence pt2", res6.first->second, std::string{"B"});
-
-        auto res7 = map2.insert(std::pair<const int, std::string>{6, "C"});
-        test_eq("second insert failure", res7.second, false);
-        test_eq("second insert equivalence pt1", res7.first->first, 6);
-        test_eq("second insert equivalence pt2", res7.first->second, std::string{"B"});
-
-        auto res8 = map2.insert_or_assign(6, std::string{"D"});
-        test_eq("insert_or_*assign* result", res8.second, false);
-        test_eq("insert_or_*assign* equivalence pt1", res8.first->first, 6);
-        test_eq("insert_or_*assign* equivalence pt2", res8.first->second, std::string{"D"});
-
-        auto res9 = map2.insert_or_assign(7, std::string{"E"});
-        test_eq("*insert*_or_assign result", res9.second, true);
-        test_eq("*insert*_or_assign equivalence pt1", res9.first->first, 7);
-        test_eq("*insert*_or_assign equivalence pt2", res9.first->second, std::string{"E"});
-
-        auto res10 = map2.erase(map2.find(7));
-        test_eq("erase", map2.find(7), map2.end());
-        test_eq("highest erased", res10, map2.end());
-
-        auto res11 = map2.erase(6);
-        test_eq("erase by key pt1", res11, 1U);
-        auto res12 = map2.erase(6);
-        test_eq("erase by key pt2", res12, 0U);
-
-        std::map<int, int> map3{};
-        map3[1] = 1;
-        auto res13 = map3.erase(1);
-        test_eq("erase root by key pt1", res13, 1U);
-        test_eq("erase root by key pt2", map3.empty(), true);
-
-        map3[2] = 2;
-        auto res14 = map3.erase(map3.begin());
-        test_eq("erase root by iterator pt1", res14, map3.end());
-        test_eq("erase root by iterator pt2", map3.empty(), true);
-
-        map2.clear();
-        test_eq("clear", map2.empty(), true);
-
-        map3[1] = 1;
-        auto res15 = map3.count(1);
-        test_eq("count", res15, 1U);
-    }
-
-    void map_test::test_bounds_and_ranges()
-    {
-        std::map<int, int> map{};
-        for (int i = 0; i < 10; ++i)
-            map[i] = i;
-        for (int i = 15; i < 20; ++i)
-            map[i] = i;
-
-        auto res1 = map.lower_bound(5);
-        test_eq("lower_bound of present key", res1->first, 5);
-
-        auto res2 = map.lower_bound(13);
-        test_eq("lower_bound of absent key", res2->first, 9);
-
-        auto res3 = map.upper_bound(7);
-        test_eq("upper_bound of present key", res3->first, 8);
-
-        auto res4 = map.upper_bound(12);
-        test_eq("upper_bound of absent key", res4->first, 15);
-
-        auto res5 = map.equal_range(4);
-        test_eq("equal_range of present key pt1", res5.first->first, 4);
-        test_eq("equal_range of present key pt2", res5.second->first, 5);
-
-        auto res6 = map.equal_range(14);
-        test_eq("equal_range of absent key pt1", res6.first->first, 9);
-        test_eq("equal_range of absent key pt2", res6.second->first, 15);
-    }
-
-    void map_test::test_multi()
-    {
-        auto check1 = {
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{4, 4},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{7, 7}
-        };
-        auto src1 = {
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{4, 4}
-        };
-
-        std::multimap<int, int> mmap{src1};
-        test_eq(
-            "multi construction",
-            check1.begin(), check1.end(),
-            mmap.begin(), mmap.end()
-        );
-
-        auto res1 = mmap.count(6);
-        test_eq("multi count", res1, 3U);
-
-        auto res2 = mmap.emplace(7, 2);
-        test_eq("multi duplicit emplace pt1", res2->first, 7);
-        test_eq("multi duplicit emplace pt2", res2->second, 2);
-        test_eq("multi duplicit emplace pt3", mmap.count(7), 2U);
-
-        auto res3 = mmap.emplace(8, 5);
-        test_eq("multi unique emplace pt1", res3->first, 8);
-        test_eq("multi unique emplace pt2", res3->second, 5);
-        test_eq("multi unique emplace pt3", mmap.count(8), 1U);
-
-        auto res4 = mmap.insert(std::pair<const int, int>{8, 6});
-        test_eq("multi duplicit insert pt1", res4->first, 8);
-        test_eq("multi duplicit insert pt2", res4->second, 6);
-        test_eq("multi duplicit insert pt3", mmap.count(8), 2U);
-
-        auto res5 = mmap.insert(std::pair<const int, int>{9, 8});
-        test_eq("multi unique insert pt1", res5->first, 9);
-        test_eq("multi unique insert pt2", res5->second, 8);
-        test_eq("multi unique insert pt3", mmap.count(9), 1U);
-
-        auto res6 = mmap.erase(8);
-        test_eq("multi erase by key pt1", res6, 2U);
-        test_eq("multi erase by key pt2", mmap.count(8), 0U);
-
-        auto res7 = mmap.erase(mmap.find(7));
-        test_eq("multi erase by iterator pt1", res7->first, 7);
-        test_eq("multi erase by iterator pt2", mmap.count(7), 1U);
-    }
-
-    void map_test::test_reverse_iterators()
-    {
-        auto check1 = {
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{4, 4},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{1, 1}
-        };
-        auto src1 = {
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{4, 4}
-        };
-
-        std::multimap<int, int> mmap{src1};
-        test_eq(
-            "multi reverse iterators",
-            check1.begin(), check1.end(),
-            mmap.rbegin(), mmap.rend()
-        );
-
-        auto check2 = {
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{4, 4},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{1, 1}
-        };
-        auto src2 = {
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{4, 4}
-        };
-
-        std::map<int, int> map{src2};
-        test_eq(
-            "reverse iterators",
-            check2.begin(), check2.end(),
-            map.rbegin(), map.rend()
-        );
-    }
-
-    void map_test::test_multi_bounds_and_ranges()
-    {
-        auto check1 = {
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{1, 2}
-        };
-        auto check2 = {
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{5, 6},
-            std::pair<const int, int>{5, 7}
-        };
-        auto check3 = {
-            std::pair<const int, int>{6, 6}
-        };
-        auto src = {
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{1, 2},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{5, 6},
-            std::pair<const int, int>{5, 7},
-            std::pair<const int, int>{6, 6}
-        };
-
-        std::multimap<int, int> mmap{src};
-        auto res1 = mmap.equal_range(1);
-        test_eq(
-            "multi equal_range at the start",
-            check1.begin(), check1.end(),
-            res1.first, res1.second
-        );
-
-        auto res2 = mmap.equal_range(5);
-        test_eq(
-            "multi equal_range in the middle",
-            check2.begin(), check2.end(),
-            res2.first, res2.second
-        );
-
-        auto res3 = mmap.equal_range(6);
-        test_eq(
-            "multi equal_range at the end + single element range",
-            check3.begin(), check3.end(),
-            res3.first, res3.second
-        );
-    }
-}
Index: pace/lib/cpp/src/internal/test/memory.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/memory.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,265 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <initializer_list>
-#include <internal/test/mock.hpp>
-#include <internal/test/tests.hpp>
-#include <memory>
-#include <type_traits>
-#include <utility>
-
-namespace std::test
-{
-    namespace aux
-    {
-        struct dummy_pointer1
-        {
-            using element_type    = int;
-            using difference_type = bool;
-
-            template<class U>
-            using rebind = unsigned;
-
-            int tag{};
-
-            static dummy_pointer1 pointer_to(element_type& x)
-            {
-                dummy_pointer1 res;
-                res.tag = x;
-                return res;
-            }
-        };
-
-        template<class T, class... Args>
-        struct dummy_pointer2
-        {
-            using element_type    = signed char;
-            using difference_type = unsigned char;
-        };
-
-        struct dummy_allocator1
-        {
-            using value_type = int;
-        };
-
-        struct dummy_allocator2
-        {
-            using value_type         = int;
-            using pointer            = char*;
-            using const_pointer      = const void*;
-            using void_pointer       = bool*;
-            using const_void_pointer = volatile bool*;
-            using difference_type    = short;
-            using size_type          = long;
-
-            using propagate_on_container_copy_assignment = std::true_type;
-            using propagate_on_container_move_assignment = std::true_type;
-            using propagate_on_container_swap            = std::true_type;
-            using is_always_equal                        = std::true_type;
-        };
-    }
-
-    bool memory_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_unique_ptr();
-        test_shared_ptr();
-        test_weak_ptr();
-        test_allocators();
-        test_pointers();
-
-        return end();
-    }
-
-    const char* memory_test::name()
-    {
-        return "memory";
-    }
-
-    void memory_test::test_unique_ptr()
-    {
-        mock::clear();
-        {
-            auto ptr = std::make_unique<mock>();
-            test_eq("unique_ptr get() when non-null", (ptr.get() != nullptr), true);
-            test_eq("unique_ptr operator bool when non-null", (bool)ptr, true);
-        }
-        test_eq("unique_ptr make_unique", mock::constructor_calls, 1U);
-        test_eq("unique_ptr out of scope", mock::destructor_calls, 1U);
-
-        mock::clear();
-        {
-            auto ptr = std::make_unique<mock>();
-            delete ptr.release();
-        }
-        test_eq("unique_ptr release", mock::destructor_calls, 1U);
-
-        mock::clear();
-        {
-            auto ptr = std::make_unique<mock>();
-            ptr.reset(new mock{});
-        }
-        test_eq("unique_ptr reset", mock::destructor_calls, 2U);
-
-        mock::clear();
-        {
-            std::unique_ptr<mock> ptr1{};
-            test_eq("unique_ptr get() when null", ptr1.get(), nullptr);
-            test_eq("unique_ptr operator bool when null", (bool)ptr1, false);
-            {
-                auto ptr2 = std::make_unique<mock>();
-                ptr1 = std::move(ptr2);
-            }
-            test_eq("unique_ptr move pt1", mock::destructor_calls, 0U);
-        }
-        test_eq("unique_ptr move pt2", mock::destructor_calls, 1U);
-
-        mock::clear();
-        {
-            auto ptr = std::make_unique<mock[]>(10U);
-            test_eq("unique_ptr make_unique array version", mock::constructor_calls, 10U);
-
-            new(&ptr[5]) mock{};
-            test_eq("placement new into the array", mock::constructor_calls, 11U);
-            test_eq("original not destroyed during placement new", mock::destructor_calls, 0U);
-        }
-        test_eq("unique_ptr array out of scope", mock::destructor_calls, 10U);
-    }
-
-    void memory_test::test_shared_ptr()
-    {
-        mock::clear();
-        {
-            auto ptr1 = std::make_shared<mock>();
-            test_eq("shared_ptr make_shared", mock::constructor_calls, 1U);
-            test_eq("shared_ptr unique", ptr1.unique(), true);
-            {
-                auto ptr2 = ptr1;
-                test_eq("shared_ptr copy pt1", ptr1.use_count(), 2L);
-                test_eq("shared_ptr copy pt2", ptr2.use_count(), 2L);
-                test_eq("shared_ptr copy no constructor call", mock::copy_constructor_calls, 0U);
-                test_eq("shared_ptr not unique", ptr1.unique(), false);
-
-                auto ptr3 = std::move(ptr2);
-                test_eq("shared_ptr move pt1", ptr1.use_count(), 2L);
-                test_eq("shared_ptr move pt2", ptr3.use_count(), 2L);
-                test_eq("shared_ptr move pt3", ptr2.use_count(), 0L);
-
-                test_eq("shared_ptr move origin empty", (bool)ptr2, false);
-            }
-            test_eq("shared_ptr copy out of scope", mock::destructor_calls, 0U);
-        }
-        test_eq("shared_ptr original out of scope", mock::destructor_calls, 1U);
-    }
-
-    void memory_test::test_weak_ptr()
-    {
-        mock::clear();
-        {
-            std::weak_ptr<mock> wptr1{};
-            {
-                auto ptr1 = std::make_shared<mock>();
-                wptr1 = ptr1;
-                {
-                    std::weak_ptr<mock> wptr2 = ptr1;
-                    test_eq("weak_ptr shares use count", wptr2.use_count(), 1L);
-                    test_eq("weak_ptr not expired", wptr2.expired(), false);
-
-                    auto ptr2 = wptr2.lock();
-                    test_eq("locked ptr increases use count", ptr1.use_count(), 2L);
-                }
-            }
-            test_eq("weak_ptr expired after all shared_ptrs die", wptr1.expired(), true);
-            test_eq("shared object destroyed while weak_ptr exists", mock::destructor_calls, 1U);
-        }
-    }
-
-    void memory_test::test_allocators()
-    {
-        using dummy_traits1 = std::allocator_traits<aux::dummy_allocator1>;
-        using dummy_traits2 = std::allocator_traits<aux::dummy_allocator2>;
-
-        /**
-         * First dummy allocator doesn't provide
-         * anything except for the mandatory value_type,
-         * so we get all the defaults here.
-         */
-        static_assert(std::is_same_v<typename dummy_traits1::pointer, int*>);
-        static_assert(std::is_same_v<typename dummy_traits1::const_pointer, const int*>);
-        static_assert(std::is_same_v<typename dummy_traits1::void_pointer, void*>);
-        static_assert(std::is_same_v<typename dummy_traits1::const_void_pointer, const void*>);
-        static_assert(std::is_same_v<typename dummy_traits1::difference_type, ptrdiff_t>);
-        static_assert(std::is_same_v<typename dummy_traits1::size_type, std::make_unsigned_t<ptrdiff_t>>);
-        static_assert(std::is_same_v<typename dummy_traits1::propagate_on_container_copy_assignment, std::false_type>);
-        static_assert(std::is_same_v<typename dummy_traits1::propagate_on_container_move_assignment, std::false_type>);
-        static_assert(std::is_same_v<typename dummy_traits1::propagate_on_container_swap, std::false_type>);
-        static_assert(std::is_same_v<typename dummy_traits1::is_always_equal, typename std::is_empty<aux::dummy_allocator1>::type>);
-
-        /**
-         * Second dummy allocator provides all typedefs, so
-         * the the traits just use identity.
-         */
-        static_assert(std::is_same_v<typename dummy_traits2::pointer, char*>);
-        static_assert(std::is_same_v<typename dummy_traits2::const_pointer, const void*>);
-        static_assert(std::is_same_v<typename dummy_traits2::void_pointer, bool*>);
-        static_assert(std::is_same_v<typename dummy_traits2::const_void_pointer, volatile bool*>);
-        static_assert(std::is_same_v<typename dummy_traits2::difference_type, short>);
-        static_assert(std::is_same_v<typename dummy_traits2::size_type, long>);
-        static_assert(std::is_same_v<typename dummy_traits2::propagate_on_container_copy_assignment, std::true_type>);
-        static_assert(std::is_same_v<typename dummy_traits2::propagate_on_container_move_assignment, std::true_type>);
-        static_assert(std::is_same_v<typename dummy_traits2::propagate_on_container_swap, std::true_type>);
-        static_assert(std::is_same_v<typename dummy_traits2::is_always_equal, std::true_type>);
-    }
-
-    void memory_test::test_pointers()
-    {
-        using dummy_traits1 = std::pointer_traits<aux::dummy_pointer1>;
-        using dummy_traits2 = std::pointer_traits<aux::dummy_pointer2<int, char>>;
-        using int_traits    = std::pointer_traits<int*>;
-
-        static_assert(std::is_same_v<typename dummy_traits1::pointer, aux::dummy_pointer1>);
-        static_assert(std::is_same_v<typename dummy_traits1::element_type, int>);
-        static_assert(std::is_same_v<typename dummy_traits1::difference_type, bool>);
-        static_assert(std::is_same_v<typename dummy_traits1::template rebind<long>, unsigned>);
-
-        int x{10};
-        test_eq("pointer_traits<Ptr>::pointer_to", dummy_traits1::pointer_to(x).tag, 10);
-        test_eq("pointer_traits<T*>::pointer_to", int_traits::pointer_to(x), &x);
-
-        static_assert(std::is_same_v<typename dummy_traits2::pointer, aux::dummy_pointer2<int, char>>);
-        static_assert(std::is_same_v<typename dummy_traits2::element_type, signed char>);
-        static_assert(std::is_same_v<typename dummy_traits2::difference_type, unsigned char>);
-
-        static_assert(std::is_same_v<typename int_traits::pointer, int*>);
-        static_assert(std::is_same_v<typename int_traits::element_type, int>);
-        static_assert(std::is_same_v<typename int_traits::difference_type, ptrdiff_t>);
-        static_assert(std::is_same_v<typename int_traits::rebind<char>, char*>);
-    }
-}
Index: pace/lib/cpp/src/internal/test/mock.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/mock.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,37 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <internal/test/mock.hpp>
-
-namespace std::test
-{
-    size_t mock::constructor_calls{};
-    size_t mock::copy_constructor_calls{};
-    size_t mock::destructor_calls{};
-    size_t mock::move_constructor_calls{};
-}
Index: pace/lib/cpp/src/internal/test/numeric.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/numeric.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,180 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <array>
-#include <complex>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <numeric>
-#include <utility>
-
-using namespace std::literals;
-using namespace complex_literals;
-
-namespace std::test
-{
-    bool numeric_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_algorithms();
-        test_complex();
-
-        return end();
-    }
-
-    const char* numeric_test::name()
-    {
-        return "numeric";
-    }
-
-    void numeric_test::test_algorithms()
-    {
-        auto data1 = {1, 2, 3, 4, 5};
-
-        auto res1 = std::accumulate(data1.begin(), data1.end(), 5);
-        test_eq("accumulate pt1", res1, 20);
-
-        auto res2 = std::accumulate(
-            data1.begin(), data1.end(), 2,
-            [](const auto& lhs, const auto& rhs){
-                return lhs * rhs;
-            }
-        );
-        test_eq("accumulate pt2", res2, 240);
-
-        auto res3 = std::accumulate(data1.begin(), data1.begin(), 10);
-        test_eq("accumulate pt3", res3, 10);
-
-        auto data2 = {3, 5, 2, 8, 7};
-        auto data3 = {4, 6, 1, 0, 5};
-
-        auto res4 = std::inner_product(
-            data2.begin(), data2.end(), data3.begin(), 0
-        );
-        test_eq("inner_product pt1", res4, 79);
-
-        auto res5 = std::inner_product(
-            data2.begin(), data2.end(), data3.begin(), 10,
-            [](const auto& lhs, const auto& rhs){
-                return lhs + rhs;
-            },
-            [](const auto& lhs, const auto& rhs){
-                return 2 * (lhs + rhs);
-            }
-        );
-        test_eq("inner_product pt2", res5, 92);
-
-        auto data4 = {1, 3, 2, 4, 5};
-        auto check1 = {1, 4, 6, 10, 15};
-        std::array<int, 5> result{};
-
-        auto res6 = std::partial_sum(
-            data4.begin(), data4.end(), result.begin()
-        );
-        test_eq(
-            "partial sum pt1",
-            check1.begin(), check1.end(),
-            result.begin(), result.end()
-        );
-        test_eq("partial sum pt2", res6, result.end());
-
-        auto check2 = {1, 3, 6, 24, 120};
-        auto res7 = std::partial_sum(
-            data4.begin(), data4.end(), result.begin(),
-            [](const auto& lhs, const auto& rhs){
-                return lhs * rhs;
-            }
-        );
-        test_eq(
-            "partial sum pt3",
-            check2.begin(), check2.end(),
-            result.begin(), result.end()
-        );
-        test_eq("partial sum pt4", res7, result.end());
-
-        auto check3 = {1, 2, -1, 2, 1};
-        auto res8 = std::adjacent_difference(
-            data4.begin(), data4.end(), result.begin()
-        );
-        test_eq(
-            "adjacent_difference pt1",
-            check3.begin(), check3.end(),
-            result.begin(), result.end()
-        );
-        test_eq("adjacent_difference pt2", res8, result.end());
-
-        auto check4 = {1, 3, 6, 8, 20};
-        auto res9 = std::adjacent_difference(
-            data4.begin(), data4.end(), result.begin(),
-            [](const auto& lhs, const auto& rhs){
-                return lhs * rhs;
-            }
-        );
-        test_eq(
-            "adjacent_difference pt3",
-            check4.begin(), check4.end(),
-            result.begin(), result.end()
-        );
-        test_eq("adjacent_difference pt4", res9, result.end());
-
-        auto check5 = {4, 5, 6, 7, 8};
-        std::iota(result.begin(), result.end(), 4);
-        test_eq(
-            "iota", check5.begin(), check5.end(),
-            result.begin(), result.end()
-        );
-    }
-
-    void numeric_test::test_complex()
-    {
-        auto c1 = 1.f + 2.5if;
-        test_eq("complex literals pt1", c1.real(), 1.f);
-        test_eq("complex literals pt2", c1.imag(), 2.5f);
-
-        std::complex<double> c2{2.0, 0.5};
-        test_eq("complex value initialization", c2, (2.0 + 0.5i));
-
-        std::complex<double> c3{c2};
-        test_eq("complex copy initialization", c3, (2.0 + 0.5i));
-
-        std::complex<double> c4{c1};
-        test_eq("complex conversion initialization", c4, (1.0 + 2.5i));
-
-        test_eq("complex sum", ((1.0 + 2.5i) + (3.0 + 0.5i)), (4.0 + 3.0i));
-        test_eq("complex sub", ((2.0 + 3.0i) - (1.0 + 5.0i)), (1.0 - 2.0i));
-        test_eq("complex mul", ((2.0 + 2.0i) * (2.0 + 3.0i)), (-2.0 + 10.0i));
-        test_eq("complex div", ((2.0 - 1.0i) / (3.0 + 4.0i)), (0.08 - 0.44i));
-        test_eq("complex unary minus", -(1.0 + 1.0i), (-1.0 - 1.0i));
-        test_eq("complex abs", std::abs(2.0 - 4.0i), 20.0);
-        test_eq("complex real", std::real(2.0 + 3.0i), 2.0);
-        test_eq("complex imag", std::imag(2.0 + 3.0i), 3.0);
-    }
-}
-
Index: pace/lib/cpp/src/internal/test/set.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/set.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,301 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <set>
-#include <string>
-#include <utility>
-
-namespace std::test
-{
-    bool set_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_constructors_and_assignment();
-        test_emplace_insert();
-        test_bounds_and_ranges();
-        test_multi();
-        test_reverse_iterators();
-        test_multi_bounds_and_ranges();
-
-        return end();
-    }
-
-    const char* set_test::name()
-    {
-        return "set";
-    }
-
-    void set_test::test_constructors_and_assignment()
-    {
-        auto check1 = {1, 2, 3, 4, 5, 6, 7};
-        auto src1 = {3, 1, 5, 2, 7, 6, 4};
-
-        std::set<int> s1{src1};
-        test_eq(
-            "initializer list initialization",
-            check1.begin(), check1.end(),
-            s1.begin(), s1.end()
-        );
-        test_eq("size", s1.size(), 7U);
-
-        std::set<int> s2{src1.begin(), src1.end()};
-        test_eq(
-            "iterator range initialization",
-            check1.begin(), check1.end(),
-            s2.begin(), s2.end()
-        );
-
-        std::set<int> s3{s1};
-        test_eq(
-            "copy initialization",
-            check1.begin(), check1.end(),
-            s3.begin(), s3.end()
-        );
-
-        std::set<int> s4{std::move(s1)};
-        test_eq(
-            "move initialization",
-            check1.begin(), check1.end(),
-            s4.begin(), s4.end()
-        );
-        test_eq("move initialization - origin empty", s1.size(), 0U);
-        test_eq("empty", s1.empty(), true);
-
-        s1 = s4;
-        test_eq(
-            "copy assignment",
-            check1.begin(), check1.end(),
-            s1.begin(), s1.end()
-        );
-
-        s4 = std::move(s1);
-        test_eq(
-            "move assignment",
-            check1.begin(), check1.end(),
-            s4.begin(), s4.end()
-        );
-        test_eq("move assignment - origin empty", s1.size(), 0U);
-
-        s1 = src1;
-        test_eq(
-            "initializer list assignment",
-            check1.begin(), check1.end(),
-            s1.begin(), s1.end()
-        );
-    }
-
-    void set_test::test_emplace_insert()
-    {
-        std::set<int> set1{};
-
-        auto res1 = set1.emplace(1);
-        test_eq("first emplace succession", res1.second, true);
-        test_eq("first emplace equivalence", *res1.first, 1);
-
-        auto res2 = set1.emplace(1);
-        test_eq("second emplace failure", res2.second, false);
-        test_eq("second emplace equivalence", *res2.first, 1);
-
-        auto res3 = set1.emplace_hint(set1.begin(), 2);
-        test_eq("first emplace_hint succession", (res3 != set1.end()), true);
-        test_eq("first emplace_hint equivalence", *res3, 2);
-
-        auto res4 = set1.emplace_hint(set1.begin(), 2);
-        test_eq("second emplace_hint failure", (res4 != set1.end()), true);
-        test_eq("second emplace_hint equivalence", *res4, 2);
-
-        std::set<std::string> set2{};
-        auto res5 = set2.insert("A");
-        test_eq("conversion insert succession", res5.second, true);
-        test_eq("conversion insert equivalence", *res5.first, std::string{"A"});
-
-        auto res6 = set2.insert(std::string{"B"});
-        test_eq("first insert succession", res6.second, true);
-        test_eq("first insert equivalence", *res6.first, std::string{"B"});
-
-        auto res7 = set2.insert(std::string{"B"});
-        test_eq("second insert failure", res7.second, false);
-        test_eq("second insert equivalence", *res7.first, std::string{"B"});
-
-        auto res10 = set1.erase(set1.find(2));
-        test_eq("erase", set1.find(2), set1.end());
-        test_eq("highest erased", res10, set1.end());
-
-        set2.insert(std::string{"G"});
-        set2.insert(std::string{"H"});
-        set2.insert(std::string{"K"});
-        auto res11 = set2.erase(std::string{"G"});
-        test_eq("erase by key pt1", res11, 1U);
-        auto res12 = set2.erase(std::string{"M"});
-        test_eq("erase by key pt2", res12, 0U);
-
-        std::set<int> set3{};
-        set3.insert(1);
-        auto res13 = set3.erase(1);
-        test_eq("erase root by key pt1", res13, 1U);
-        test_eq("erase root by key pt2", set3.empty(), true);
-
-        set3.insert(3);
-        auto res14 = set3.erase(set3.begin());
-        test_eq("erase root by iterator pt1", res14, set3.end());
-        test_eq("erase root by iterator pt2", set3.empty(), true);
-
-        set2.clear();
-        test_eq("clear", set2.empty(), true);
-
-        set3.insert(1);
-        auto res15 = set3.count(1);
-        test_eq("count", res15, 1U);
-    }
-
-    void set_test::test_bounds_and_ranges()
-    {
-        std::set<int> set{};
-        for (int i = 0; i < 10; ++i)
-            set.insert(i);
-        for (int i = 15; i < 20; ++i)
-            set.insert(i);
-
-        auto res1 = set.lower_bound(5);
-        test_eq("lower_bound of present key", *res1, 5);
-
-        auto res2 = set.lower_bound(13);
-        test_eq("lower_bound of absent key", *res2, 9);
-
-        auto res3 = set.upper_bound(7);
-        test_eq("upper_bound of present key", *res3, 8);
-
-        auto res4 = set.upper_bound(12);
-        test_eq("upper_bound of absent key", *res4, 15);
-
-        auto res5 = set.equal_range(4);
-        test_eq("equal_range of present key pt1", *res5.first, 4);
-        test_eq("equal_range of present key pt2", *res5.second, 5);
-
-        auto res6 = set.equal_range(14);
-        test_eq("equal_range of absent key pt1", *res6.first, 9);
-        test_eq("equal_range of absent key pt2", *res6.second, 15);
-    }
-
-    void set_test::test_multi()
-    {
-        auto check1 = {1, 2, 3, 3, 4, 5, 6, 6, 6, 7};
-        auto src1 = {3, 6, 1, 5, 6, 3, 2, 7, 6, 4};
-
-        std::multiset<int> mset{src1};
-        test_eq(
-            "multi construction",
-            check1.begin(), check1.end(),
-            mset.begin(), mset.end()
-        );
-
-        auto res1 = mset.count(6);
-        test_eq("multi count", res1, 3U);
-
-        auto res2 = mset.emplace(7);
-        test_eq("multi duplicit emplace pt1", *res2, 7);
-        test_eq("multi duplicit emplace pt2", mset.count(7), 2U);
-
-        auto res3 = mset.emplace(8);
-        test_eq("multi unique emplace pt1", *res3, 8);
-        test_eq("multi unique emplace pt2", mset.count(8), 1U);
-
-        auto res4 = mset.insert(8);
-        test_eq("multi duplicit insert pt1", *res4, 8);
-        test_eq("multi duplicit insert pt2", mset.count(8), 2U);
-
-        auto res5 = mset.insert(9);
-        test_eq("multi unique insert pt1", *res5, 9);
-        test_eq("multi unique insert pt2", mset.count(9), 1U);
-
-        auto res6 = mset.erase(8);
-        test_eq("multi erase by key pt1", res6, 2U);
-        test_eq("multi erase by key pt2", mset.count(8), 0U);
-
-        auto res7 = mset.erase(mset.find(7));
-        test_eq("multi erase by iterator pt1", *res7, 7);
-        test_eq("multi erase by iterator pt2", mset.count(7), 1U);
-    }
-
-    void set_test::test_reverse_iterators()
-    {
-        auto check1 = {7, 6, 6, 6, 5, 4, 3, 3, 2, 1};
-        auto src1 = {3, 6, 1, 5, 6, 3, 2, 7, 6, 4};
-
-        std::multiset<int> mset{src1};
-        test_eq(
-            "multi reverse iterators",
-            check1.begin(), check1.end(),
-            mset.rbegin(), mset.rend()
-        );
-
-        auto check2 = {7, 6, 5, 4, 3, 2, 1};
-        auto src2 = {3, 1, 5, 2, 7, 6, 4};
-
-        std::set<int> set{src2};
-        test_eq(
-            "reverse iterators",
-            check2.begin(), check2.end(),
-            set.rbegin(), set.rend()
-        );
-    }
-
-    void set_test::test_multi_bounds_and_ranges()
-    {
-        auto check1 = {1, 1};
-        auto check2 = {5, 5, 5};
-        auto check3 = {6};
-        auto src = {1, 1, 2, 3, 5, 5, 5, 6};
-
-        std::multiset<int> mset{src};
-        auto res1 = mset.equal_range(1);
-        test_eq(
-            "multi equal_range at the start",
-            check1.begin(), check1.end(),
-            res1.first, res1.second
-        );
-
-        auto res2 = mset.equal_range(5);
-        test_eq(
-            "multi equal_range in the middle",
-            check2.begin(), check2.end(),
-            res2.first, res2.second
-        );
-
-        auto res3 = mset.equal_range(6);
-        test_eq(
-            "multi equal_range at the end + single element range",
-            check3.begin(), check3.end(),
-            res3.first, res3.second
-        );
-    }
-}
Index: pace/lib/cpp/src/internal/test/string.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/string.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,706 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <string>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <cstdio>
-
-namespace std::test
-{
-    bool string_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_construction_and_assignment();
-        test_append();
-        test_insert();
-        test_erase();
-        test_replace();
-        test_copy();
-        test_find();
-        test_substr();
-        test_compare();
-
-        return end();
-    }
-
-    const char* string_test::name()
-    {
-        return "string";
-    }
-
-    void string_test::test_construction_and_assignment()
-    {
-        const char* check1 = "hello";
-
-        std::string str1{"hello"};
-        test_eq(
-            "size of string",
-            str1.size(), 5ul
-        );
-        test_eq(
-            "initialization from a cstring literal",
-            str1.begin(), str1.end(),
-            check1, check1 + 5
-        );
-
-        std::string str2{str1};
-        test_eq(
-            "copy constructor",
-            str1.begin(), str1.end(),
-            str2.begin(), str2.end()
-        );
-
-        std::string str3{std::move(str1)};
-        test_eq(
-            "move constructor equality",
-            str2.begin(), str2.end(),
-            str3.begin(), str3.end()
-        );
-        test_eq(
-            "move constructor source empty",
-            str1.size(), 0ul
-        );
-
-        std::string str4{};
-        test_eq(
-            "default constructor empty",
-            str4.size(), 0ul
-        );
-
-        str4.assign(str3, 2ul, 2ul);
-        test_eq(
-            "assign substring to an empty string",
-            str4.begin(), str4.end(),
-            str3.begin() + 2, str3.begin() + 4
-        );
-
-        std::string str5{str3.begin() + 2, str3.begin() + 4};
-        test_eq(
-            "constructor from a pair of iterators",
-            str5.begin(), str5.end(),
-            str3.begin() + 2, str3.begin() + 4
-        );
-    }
-
-    void string_test::test_append()
-    {
-        std::string check{"hello, world"};
-
-        std::string str1{"hello, "};
-        str1.append("world");
-        test_eq(
-            "append cstring",
-            str1.begin(), str1.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str2{"hello, "};
-        str2.append(std::string{"world"});
-        test_eq(
-            "append rvalue string",
-            str2.begin(), str2.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str3{"hello, "};
-        std::string apendee{"world"};
-        str3.append(apendee);
-        test_eq(
-            "append lvalue string",
-            str3.begin(), str3.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str4{"hello, "};
-        str4.append(apendee.begin(), apendee.end());
-        test_eq(
-            "append iterator range",
-            str4.begin(), str4.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str5{"hello, "};
-        str5.append({'w', 'o', 'r', 'l', 'd'});
-        test_eq(
-            "append initializer list",
-            str5.begin(), str5.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str6{"hello, "};
-        str6 += "world";
-        test_eq(
-            "append using +=",
-            str6.begin(), str6.end(),
-            check.begin(), check.end()
-        );
-    }
-
-    void string_test::test_insert()
-    {
-        std::string check{"hello, world"};
-
-        std::string str1{", world"};
-        str1.insert(0, "hello");
-        test_eq(
-            "insert at the beggining",
-            str1.begin(), str1.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str2{"hello,world"};
-        str2.insert(str2.begin() + 6, ' ');
-        test_eq(
-            "insert char in the middle",
-            str2.begin(), str2.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str3{"heo, world"};
-        str3.insert(str3.begin() + 2, 2ul, 'l');
-        test_eq(
-            "insert n chars",
-            str3.begin(), str3.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str4{"h, world"};
-        std::string insertee{"ello"};
-        str4.insert(str4.begin() + 1, insertee.begin(),
-                    insertee.end());
-        test_eq(
-            "insert iterator range",
-            str4.begin(), str4.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str5{"hel, world"};
-        std::initializer_list<char> init{'l', 'o'};
-        str5.insert(str5.begin() + 3, init);
-        test_eq(
-            "insert initializer list",
-            str5.begin(), str5.end(),
-            check.begin(), check.end()
-        );
-    }
-
-    void string_test::test_erase()
-    {
-        std::string check{"hello"};
-
-        std::string str1{"heXllo"};
-        str1.erase(str1.begin() + 2);
-        test_eq(
-            "erase single char in the middle",
-            str1.begin(), str1.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str2{"Xhello"};
-        str2.erase(str2.begin());
-        test_eq(
-            "erase single char at the beginning",
-            str2.begin(), str2.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str3{"helloX"};
-        str3.erase(str3.begin() + 5);
-        test_eq(
-            "erase single char at the end",
-            str3.begin(), str3.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str4{"XXXhello"};
-        str4.erase(0, 3);
-        test_eq(
-            "erase string at the beginning",
-            str4.begin(), str4.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str5{"heXXXllo"};
-        str5.erase(2, 3);
-        test_eq(
-            "erase string in the middle",
-            str5.begin(), str5.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str6{"helloXXX"};
-        str6.erase(5);
-        test_eq(
-            "erase string at the end",
-            str6.begin(), str6.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str7{"hellXXXo"};
-        str7.erase(str7.begin() + 4, str7.begin() + 7);
-        test_eq(
-            "erase iterator range",
-            str7.begin(), str7.end(),
-            check.begin(), check.end()
-        );
-    }
-
-    void string_test::test_replace()
-    {
-        std::string check{"hello, world"};
-
-        std::string str1{"helXXX world"};
-        str1.replace(3, 3, "lo,", 3);
-        test_eq(
-            "replace with full string",
-            str1.begin(), str1.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str2{"helXXX world"};
-        str2.replace(3, 3, "lo,YYY", 3);
-        test_eq(
-            "replace with prefix of a string",
-            str2.begin(), str2.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str3{"helXXX world"};
-        str3.replace(3, 3, "YYlo,YYY", 2, 3);
-        test_eq(
-            "replace with substring of a string",
-            str3.begin(), str3.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str4{"heXXo, world"};
-        str4.replace(2, 2, 2, 'l');
-        test_eq(
-            "replace with repeated characters",
-            str4.begin(), str4.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str5{"heXXXXo, world"};
-        str5.replace(2, 4, 2, 'l');
-        test_eq(
-            "replace with repeated characters (shrinking)",
-            str5.begin(), str5.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str6{"helXXXXX world"};
-        str6.replace(3, 5, "YYlo,YYY", 2, 3);
-        test_eq(
-            "replace with substring of a string (shrinking)",
-            str6.begin(), str6.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str7{"helXXXXX world"};
-        std::string replacer{"YYlo,YYY"};
-        str7.replace(3, 5, replacer, 2, 3);
-        test_eq(
-            "replace with substring of a string (shrinking, std::string)",
-            str7.begin(), str7.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str8{"helXXXXX world"};
-        str8.replace(str8.begin() + 3, str8.begin() + 8, "lo,");
-        test_eq(
-            "replace with a string (iterators)",
-            str8.begin(), str8.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str9{"heXXXXo, world"};
-        str9.replace(str9.begin() + 2, str9.begin() + 6, 2, 'l');
-        test_eq(
-            "replace with repeated characters (shrinking, iterators)",
-            str9.begin(), str9.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str10{"helXXXXX world"};
-        str10.replace(str10.begin() + 3, str10.begin() + 8,
-                      replacer.begin() + 2, replacer.begin() + 5);
-        test_eq(
-            "replace with substring of a string (shrinking, iterators x2)",
-            str10.begin(), str10.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str11{"helXXXXX world"};
-        str11.replace(str11.begin() + 3, str11.begin() + 8,
-                      {'l', 'o', ','});
-        test_eq(
-            "replace with an initializer list (shrinking, iterators)",
-            str11.begin(), str11.end(),
-            check.begin(), check.end()
-        );
-
-        std::string str12{"helXXX world"};
-        str12.replace(str12.begin() + 3, str12.begin() + 6,
-                      {'l', 'o', ','});
-        test_eq(
-            "replace with an initializer list (iterators)",
-            str12.begin(), str12.end(),
-            check.begin(), check.end()
-        );
-    }
-
-    void string_test::test_copy()
-    {
-        std::string check{"CCABB"};
-
-        std::string str1{"ACCCA"};
-        std::string str2{"BBBBB"};
-
-        str1.copy(const_cast<char*>(str2.c_str()), 3, 2);
-        test_eq(
-            "copy",
-            str2.begin(), str2.end(),
-            check.begin(), check.end()
-        );
-    }
-
-    void string_test::test_find()
-    {
-        std::string target{"ABC"};
-        auto miss = std::string::npos;
-
-        std::string str1{"xxABCxx"};
-
-        auto idx = str1.find(target, 0);
-        test_eq(
-            "find from start (success)",
-            idx, 2ul
-        );
-
-        idx = str1.find(target, 3);
-        test_eq(
-            "find from start (fail, late start)",
-            idx, miss
-        );
-
-        idx = str1.rfind(target, miss);
-        test_eq(
-            "rfind from end (success)",
-            idx, 2ul
-        );
-
-        idx = str1.rfind(target, 1);
-        test_eq(
-            "rfind from start (fail, late start)",
-            idx, miss
-        );
-
-        idx = str1.find('B', 2);
-        test_eq(
-            "find char from middle (success)",
-            idx, 3ul
-        );
-
-        idx = str1.rfind('B', 2);
-        test_eq(
-            "rfind char from middle (success)",
-            idx, 3ul
-        );
-
-        std::string str2{"xxABCxxABCxx"};
-
-        idx = str2.find(target, 0);
-        test_eq(
-            "find from start (success, multiple)",
-            idx, 2ul
-        );
-
-        idx = str2.find(target, 5);
-        test_eq(
-            "find from middle (success, multiple)",
-            idx, 7ul
-        );
-
-        idx = str2.rfind(target, miss);
-        test_eq(
-            "rfind from end (success, multiple)",
-            idx, 7ul
-        );
-
-        idx = str2.rfind(target, 6);
-        test_eq(
-            "rfind from mid (success, multiple)",
-            idx, 2ul
-        );
-
-        std::string str3{"xxBxxAxxCxx"};
-
-        idx = str3.find_first_of(target);
-        test_eq(
-            "find first of from start (success)",
-            idx, 2ul
-        );
-
-        idx = str3.find_first_of(target, 6);
-        test_eq(
-            "find first of from middle (success)",
-            idx, 8ul
-        );
-
-        idx = str3.find_first_of("DEF", 3);
-        test_eq(
-            "find first of from middle (fail, not in string)",
-            idx, miss
-        );
-
-        idx = str3.find_first_of(target, 9);
-        test_eq(
-            "find first of from middle (fail, late start)",
-            idx, miss
-        );
-
-        idx = str3.find_first_of("");
-        test_eq(
-            "find first of from start (fail, no target)",
-            idx, miss
-        );
-
-        idx = str3.find_first_of('A', 1);
-        test_eq(
-            "find first of char (success)",
-            idx, 5ul
-        );
-
-        idx = str3.find_first_of('A', 6);
-        test_eq(
-            "find first of char (fail)",
-            idx, miss
-        );
-
-        idx = str3.find_last_of(target);
-        test_eq(
-            "find last of from start (success)",
-            idx, 8ul
-        );
-
-        idx = str3.find_last_of(target, 6);
-        test_eq(
-            "find last of from middle (success)",
-            idx, 5ul
-        );
-
-        idx = str3.find_last_of("DEF", 3);
-        test_eq(
-            "find last of from middle (fail, not in string)",
-            idx, miss
-        );
-
-        idx = str3.find_last_of(target, 1);
-        test_eq(
-            "find last of from middle (fail, late start)",
-            idx, miss
-        );
-
-        idx = str3.find_last_of("");
-        test_eq(
-            "find last of from start (fail, no target)",
-            idx, miss
-        );
-
-        idx = str3.find_last_of('A', str3.size() - 1);
-        test_eq(
-            "find last of char (success)",
-            idx, 5ul
-        );
-
-        idx = str3.find_last_of('A', 3);
-        test_eq(
-            "find last of char (fail)",
-            idx, miss
-        );
-
-        std::string not_target{"xB"};
-
-        idx = str3.find_first_not_of(not_target);
-        test_eq(
-            "find first not of from start (success)",
-            idx, 5ul
-        );
-
-        idx = str3.find_first_not_of(not_target, 6);
-        test_eq(
-            "find first not of from middle (success)",
-            idx, 8ul
-        );
-
-        idx = str3.find_first_not_of("xABC", 3);
-        test_eq(
-            "find first not of from middle (fail, not in string)",
-            idx, miss
-        );
-
-        idx = str3.find_first_not_of(not_target, 9);
-        test_eq(
-            "find first not of from middle (fail, late start)",
-            idx, miss
-        );
-
-        idx = str3.find_first_not_of("");
-        test_eq(
-            "find first not of from start (success, no target)",
-            idx, 0ul
-        );
-
-        idx = str3.find_first_not_of('x', 3);
-        test_eq(
-            "find first not of char (success)",
-            idx, 5ul
-        );
-
-        idx = str3.find_first_of('a', 9);
-        test_eq(
-            "find first not of char (fail)",
-            idx, miss
-        );
-
-        std::string not_last_target{"xC"};
-
-        idx = str3.find_last_not_of(not_last_target);
-        test_eq(
-            "find last not of from start (success)",
-            idx, 5ul
-        );
-
-        idx = str3.find_last_not_of(not_last_target, 4);
-        test_eq(
-            "find last not of from middle (success)",
-            idx, 2ul
-        );
-
-        idx = str3.find_last_not_of("xABC");
-        test_eq(
-            "find last not of from middle (fail, not in string)",
-            idx, miss
-        );
-
-        idx = str3.find_last_not_of(not_last_target, 1);
-        test_eq(
-            "find last not of from middle (fail, late start)",
-            idx, miss
-        );
-
-        idx = str3.find_last_not_of("");
-        test_eq(
-            "find last not of from start (success, no target)",
-            idx, str3.size() - 1
-        );
-
-        idx = str3.find_last_not_of('x', str3.size() - 1);
-        test_eq(
-            "find last not of char (success)",
-            idx, 8ul
-        );
-
-        idx = str3.find_last_not_of('x', 1);
-        test_eq(
-            "find last not of char (fail)",
-            idx, miss
-        );
-    }
-
-    void string_test::test_substr()
-    {
-        std::string check1{"abcd"};
-        std::string check2{"bcd"};
-        std::string check3{"def"};
-
-        std::string str{"abcdef"};
-        auto substr1 = str.substr(0, 4);
-        auto substr2 = str.substr(1, 3);
-        auto substr3 = str.substr(3);
-
-        test_eq(
-            "prefix substring",
-            substr1.begin(), substr1.end(),
-            check1.begin(), check1.end()
-        );
-
-        test_eq(
-            "substring",
-            substr2.begin(), substr2.end(),
-            check2.begin(), check2.end()
-        );
-
-        test_eq(
-            "suffix substring",
-            substr3.begin(), substr3.end(),
-            check3.begin(), check3.end()
-        );
-    }
-
-    void string_test::test_compare()
-    {
-        std::string str1{"aabbb"};
-        std::string str2{"bbbaa"};
-        std::string str3{"bbb"};
-
-        auto res = str1.compare(str1);
-        test_eq(
-            "compare equal",
-            res, 0
-        );
-
-        res = str1.compare(str2.c_str());
-        test_eq(
-            "compare less",
-            res, -1
-        );
-
-        res = str2.compare(str1);
-        test_eq(
-            "compare greater",
-            res, 1
-        );
-
-        res = str1.compare(2, 3, str2);
-        test_eq(
-            "compare substring less",
-            res, -1
-        );
-
-        res = str1.compare(2, 3, str3);
-        test_eq(
-            "compare substring equal",
-            res, 0
-        );
-    }
-}
Index: pace/lib/cpp/src/internal/test/test.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/test.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,68 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <cstdio>
-#include <internal/test/test.hpp>
-
-namespace std::test
-{
-    void test_suite::report(bool result, const char* tname)
-    {
-        if (!report_)
-            return;
-
-        if (result)
-            std::printf("[%s][%s] ... OK\n", name(), tname);
-        else
-            std::printf("[%s][%s] ... FAIL\n", name(), tname);
-    }
-
-    void test_suite::start()
-    {
-        if (report_)
-            std::printf("\n[TEST START][%s]\n", name());
-    }
-
-    bool test_suite::end()
-    {
-        if (report_)
-            std::printf("[TEST END][%s][%u OK][%u FAIL]\n",
-                        name(), succeeded_, failed_);
-        return ok_;
-    }
-
-    unsigned int test_suite::get_failed() const noexcept
-    {
-        return failed_;
-    }
-
-    unsigned int test_suite::get_succeeded() const noexcept
-    {
-        return succeeded_;
-    }
-}
Index: pace/lib/cpp/src/internal/test/tuple.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/tuple.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,158 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <functional>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <string>
-#include <tuple>
-#include <type_traits>
-#include <utility>
-
-namespace std::test
-{
-    bool tuple_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_constructors_and_assignment();
-        test_creation();
-        test_tie_and_structured_bindings();
-        test_tuple_ops();
-
-        return end();
-    }
-
-    const char* tuple_test::name()
-    {
-        return "tuple";
-    }
-
-    void tuple_test::test_constructors_and_assignment()
-    {
-        std::tuple<int, float> tpl1{1, .5f};
-        test_eq("value initialization pt1", std::get<0>(tpl1), 1);
-        test_eq("value initialization pt2", std::get<1>(tpl1), .5f);
-
-        auto p = std::make_pair(2, 1.f);
-        std::tuple<int, float> tpl2{p};
-        test_eq("pair initialization pt1", std::get<0>(tpl2), 2);
-        test_eq("pair initialization pt2", std::get<1>(tpl2), 1.f);
-
-        tpl1 = p;
-        test_eq("pair assignment pt1", std::get<0>(tpl1), 2);
-        test_eq("pair assignment pt2", std::get<1>(tpl1), 1.f);
-
-        auto tpl3 = std::make_tuple(std::string{"A"}, std::string{"B"});
-        auto tpl4 = std::make_tuple(std::string{"C"}, std::string{"D"});
-        tpl3 = std::move(tpl4);
-        test_eq("move assignment pt1", std::get<0>(tpl3), std::string{"C"});
-        test_eq("move assignment pt2", std::get<1>(tpl3), std::string{"D"});
-
-        auto tpl5 = std::make_tuple(1, .5f);
-        auto tpl6{std::move(tpl5)};
-        test_eq("move initialization pt1", std::get<0>(tpl6), 1);
-        test_eq("move initialization pt2", std::get<1>(tpl6), .5f);
-    }
-
-    void tuple_test::test_creation()
-    {
-        auto tpl1 = std::make_tuple(1, .5f, std::string{"test"}, true);
-        static_assert(std::is_same_v<std::tuple_element_t<0, decltype(tpl1)>, int>);
-        static_assert(std::is_same_v<std::tuple_element_t<1, decltype(tpl1)>, float>);
-        static_assert(std::is_same_v<std::tuple_element_t<2, decltype(tpl1)>, std::string>);
-        static_assert(std::is_same_v<std::tuple_element_t<3, decltype(tpl1)>, bool>);
-
-        test_eq("make_tuple pt1", std::get<0>(tpl1), 1);
-        test_eq("make_tuple pt2", std::get<1>(tpl1), .5f);
-        test_eq("make_tuple pt3", std::get<2>(tpl1), std::string{"test"});
-        test_eq("make_tuple pt4", std::get<3>(tpl1), true);
-
-        static_assert(std::tuple_size_v<decltype(tpl1)> == 4);
-
-        int i{};
-        float f{};
-        auto tpl2 = std::make_tuple(std::ref(i), std::cref(f));
-        static_assert(std::is_same_v<std::tuple_element_t<0, decltype(tpl2)>, int&>);
-        static_assert(std::is_same_v<std::tuple_element_t<1, decltype(tpl2)>, const float&>);
-
-        std::get<0>(tpl2) = 3;
-        test_eq("modify reference in tuple", i, 3);
-
-        auto tpl3 = std::forward_as_tuple(i, f);
-        static_assert(std::is_same_v<std::tuple_element_t<0, decltype(tpl3)>, int&>);
-        static_assert(std::is_same_v<std::tuple_element_t<1, decltype(tpl3)>, float&>);
-
-        std::get<1>(tpl3) = 1.5f;
-        test_eq("modify reference in forward_as_tuple", f, 1.5f);
-    }
-
-    void tuple_test::test_tie_and_structured_bindings()
-    {
-        int i1{};
-        float f1{};
-        auto tpl = std::make_tuple(1, .5f);
-        std::tie(i1, f1) = tpl;
-
-        test_eq("tie unpack pt1", i1, 1);
-        test_eq("tie unpack pt2", f1, .5f);
-
-        std::get<0>(tpl) = 2;
-        std::tie(i1, std::ignore) = tpl;
-
-        test_eq("tie unpack with ignore", i1, 2);
-
-        auto [i2, f2] = tpl;
-        test_eq("structured bindings pt1", i2, 2);
-        test_eq("structured bindings pt2", f2, .5f);
-    }
-
-    void tuple_test::test_tuple_ops()
-    {
-        auto tpl1 = std::make_tuple(1, .5f);
-        auto tpl2 = std::make_tuple(1, .5f);
-        auto tpl3 = std::make_tuple(1, 1.f);
-        auto tpl4 = std::make_tuple(2, .5f);
-        auto tpl5 = std::make_tuple(2, 1.f);
-
-        test_eq("tuple == pt1", (tpl1 == tpl2), true);
-        test_eq("tuple == pt2", (tpl1 == tpl3), false);
-        test_eq("tuple == pt3", (tpl1 == tpl4), false);
-        test_eq("tuple < pt1", (tpl1 < tpl2), false);
-        test_eq("tuple < pt2", (tpl1 < tpl3), true);
-        test_eq("tuple < pt3", (tpl1 < tpl4), true);
-        test_eq("tuple < pt4", (tpl1 < tpl5), true);
-
-        tpl1.swap(tpl5);
-        test_eq("tuple swap pt1", std::get<0>(tpl1), 2);
-        test_eq("tuple swap pt2", std::get<1>(tpl1), 1.f);
-        test_eq("tuple swap pt3", std::get<0>(tpl5), 1);
-        test_eq("tuple swap pt4", std::get<1>(tpl5), .5f);
-    }
-}
Index: pace/lib/cpp/src/internal/test/unordered_map.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/unordered_map.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,267 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <unordered_map>
-#include <string>
-#include <sstream>
-#include <utility>
-
-namespace std::test
-{
-    bool unordered_map_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_constructors_and_assignment();
-        test_histogram();
-        test_emplace_insert();
-        test_multi();
-
-        return end();
-    }
-
-    const char* unordered_map_test::name()
-    {
-        return "unordered_map";
-    }
-
-    void unordered_map_test::test_constructors_and_assignment()
-    {
-        auto check1 = {1, 2, 3, 4, 5, 6, 7};
-        auto src1 = {
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{4, 4}
-        };
-
-        std::unordered_map<int, int> m1{src1};
-        test_contains(
-            "initializer list initialization",
-            check1.begin(), check1.end(), m1
-        );
-        test_eq("size", m1.size(), 7U);
-
-        std::unordered_map<int, int> m2{src1.begin(), src1.end()};
-        test_contains(
-            "iterator range initialization",
-            check1.begin(), check1.end(), m2
-        );
-
-        std::unordered_map<int, int> m3{m1};
-        test_contains(
-            "copy initialization",
-            check1.begin(), check1.end(), m3
-        );
-
-        std::unordered_map<int, int> m4{std::move(m1)};
-        test_contains(
-            "move initialization",
-            check1.begin(), check1.end(), m4
-        );
-        test_eq("move initialization - origin empty", m1.size(), 0U);
-        test_eq("empty", m1.empty(), true);
-
-        m1 = m4;
-        test_contains(
-            "copy assignment",
-            check1.begin(), check1.end(), m1
-        );
-
-        m4 = std::move(m1);
-        test_contains(
-            "move assignment",
-            check1.begin(), check1.end(), m4
-        );
-        test_eq("move assignment - origin empty", m1.size(), 0U);
-
-        m1 = src1;
-        test_contains(
-            "initializer list assignment",
-            check1.begin(), check1.end(), m1
-        );
-    }
-
-    void unordered_map_test::test_histogram()
-    {
-        std::string str{"a b a a c d b e a b b e d c a e"};
-        std::unordered_map<std::string, std::size_t> unordered_map{};
-        std::istringstream iss{str};
-        std::string word{};
-
-        while (iss >> word)
-            ++unordered_map[word];
-
-        test_eq("histogram pt1", unordered_map["a"], 5U);
-        test_eq("histogram pt2", unordered_map["b"], 4U);
-        test_eq("histogram pt3", unordered_map["c"], 2U);
-        test_eq("histogram pt4", unordered_map["d"], 2U);
-        test_eq("histogram pt5", unordered_map["e"], 3U);
-        test_eq("histogram pt6", unordered_map["f"], 0U);
-        test_eq("at", unordered_map.at("a"), 5U);
-    }
-
-    void unordered_map_test::test_emplace_insert()
-    {
-        std::unordered_map<int, int> map1{};
-
-        auto res1 = map1.emplace(1, 2);
-        test_eq("first emplace succession", res1.second, true);
-        test_eq("first emplace equivalence pt1", res1.first->first, 1);
-        test_eq("first emplace equivalence pt2", res1.first->second, 2);
-
-        auto res2 = map1.emplace(1, 3);
-        test_eq("second emplace failure", res2.second, false);
-        test_eq("second emplace equivalence pt1", res2.first->first, 1);
-        test_eq("second emplace equivalence pt2", res2.first->second, 2);
-
-        auto res3 = map1.emplace_hint(map1.begin(), 2, 4);
-        test_eq("first emplace_hint succession", (res3 != map1.end()), true);
-        test_eq("first emplace_hint equivalence pt1", res3->first, 2);
-        test_eq("first emplace_hint equivalence pt2", res3->second, 4);
-
-        auto res4 = map1.emplace_hint(map1.begin(), 2, 5);
-        test_eq("second emplace_hint failure", (res4 != map1.end()), true);
-        test_eq("second emplace_hint equivalence pt1", res4->first, 2);
-        test_eq("second emplace_hint equivalence pt2", res4->second, 4);
-
-        std::unordered_map<int, std::string> map2{};
-        auto res5 = map2.insert(std::pair<const int, const char*>{5, "A"});
-        test_eq("conversion insert succession", res5.second, true);
-        test_eq("conversion insert equivalence pt1", res5.first->first, 5);
-        test_eq("conversion insert equivalence pt2", res5.first->second, std::string{"A"});
-
-        auto res6 = map2.insert(std::pair<const int, std::string>{6, "B"});
-        test_eq("first insert succession", res6.second, true);
-        test_eq("first insert equivalence pt1", res6.first->first, 6);
-        test_eq("first insert equivalence pt2", res6.first->second, std::string{"B"});
-
-        auto res7 = map2.insert(std::pair<const int, std::string>{6, "C"});
-        test_eq("second insert failure", res7.second, false);
-        test_eq("second insert equivalence pt1", res7.first->first, 6);
-        test_eq("second insert equivalence pt2", res7.first->second, std::string{"B"});
-
-        auto res8 = map2.insert_or_assign(6, std::string{"D"});
-        test_eq("insert_or_*assign* result", res8.second, false);
-        test_eq("insert_or_*assign* equivalence pt1", res8.first->first, 6);
-        test_eq("insert_or_*assign* equivalence pt2", res8.first->second, std::string{"D"});
-
-        auto res9 = map2.insert_or_assign(7, std::string{"E"});
-        test_eq("*insert*_or_assign result", res9.second, true);
-        test_eq("*insert*_or_assign equivalence pt1", res9.first->first, 7);
-        test_eq("*insert*_or_assign equivalence pt2", res9.first->second, std::string{"E"});
-
-        auto res10 = map2.erase(map2.find(7));
-        test_eq("erase", map2.find(7), map2.end());
-        test_eq("highest erased", res10, map2.end());
-
-        auto res11 = map2.erase(6);
-        test_eq("erase by key pt1", res11, 1U);
-        auto res12 = map2.erase(6);
-        test_eq("erase by key pt2", res12, 0U);
-
-        auto res13 = map2.insert(std::pair<const int, const char*>{11, "test"});
-        test_eq("insert with constructible argument pt1", res13.second, true);
-        test_eq("insert with constructible argument pt2", res13.first->first, 11);
-        test_eq("insert with constructible argument pt3", res13.first->second, std::string{"test"});
-
-        std::unordered_map<int, int> map3{};
-        map3[1] = 1;
-        auto res15 = map3.count(1);
-        test_eq("count", res15, 1U);
-
-        map2.clear();
-        test_eq("clear", map2.empty(), true);
-    }
-
-    void unordered_map_test::test_multi()
-    {
-        auto check_keys = {1, 2, 3, 4, 5, 6, 7};
-        auto check_counts = {1U, 1U, 2U, 1U, 1U, 3U, 1U};
-        auto src = {
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{1, 1},
-            std::pair<const int, int>{5, 5},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{3, 3},
-            std::pair<const int, int>{2, 2},
-            std::pair<const int, int>{7, 7},
-            std::pair<const int, int>{6, 6},
-            std::pair<const int, int>{4, 4}
-        };
-
-        std::unordered_multimap<int, int> mmap{src};
-        test_contains_multi(
-            "multi construction",
-            check_keys.begin(), check_keys.end(),
-            check_counts.begin(), mmap
-        );
-
-        auto res1 = mmap.count(6);
-        test_eq("multi count", res1, 3U);
-
-        auto res2 = mmap.emplace(7, 2);
-        test_eq("multi duplicit emplace pt1", res2->first, 7);
-        test_eq("multi duplicit emplace pt2", res2->second, 2);
-        test_eq("multi duplicit emplace pt3", mmap.count(7), 2U);
-
-        auto res3 = mmap.emplace(8, 5);
-        test_eq("multi unique emplace pt1", res3->first, 8);
-        test_eq("multi unique emplace pt2", res3->second, 5);
-        test_eq("multi unique emplace pt3", mmap.count(8), 1U);
-
-        auto res4 = mmap.insert(std::pair<const int, int>{8, 6});
-        test_eq("multi duplicit insert pt1", res4->first, 8);
-        test_eq("multi duplicit insert pt2", res4->second, 6);
-        test_eq("multi duplicit insert pt3", mmap.count(8), 2U);
-
-        auto res5 = mmap.insert(std::pair<const int, int>{9, 8});
-        test_eq("multi unique insert pt1", res5->first, 9);
-        test_eq("multi unique insert pt2", res5->second, 8);
-        test_eq("multi unique insert pt3", mmap.count(9), 1U);
-
-        auto res6 = mmap.erase(8);
-        test_eq("multi erase by key pt1", res6, 2U);
-        test_eq("multi erase by key pt2", mmap.count(8), 0U);
-
-        // To check that the bucket still works.
-        mmap.insert(std::pair<const int, int>{8, 8});
-        test_eq("multi erase keeps bucket intact", (mmap.find(8) != mmap.end()), true);
-
-        auto res7 = mmap.erase(mmap.find(7));
-        test_eq("multi erase by iterator pt1", res7->first, 7);
-        test_eq("multi erase by iterator pt2", mmap.count(7), 1U);
-    }
-}
Index: pace/lib/cpp/src/internal/test/unordered_set.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/unordered_set.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,214 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <unordered_set>
-#include <string>
-#include <utility>
-
-namespace std::test
-{
-    bool unordered_set_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_constructors_and_assignment();
-        test_emplace_insert();
-        test_multi();
-
-        return end();
-    }
-
-    const char* unordered_set_test::name()
-    {
-        return "unordered_set";
-    }
-
-    void unordered_set_test::test_constructors_and_assignment()
-    {
-        auto check1 = {1, 2, 3, 4, 5, 6, 7};
-        auto src1 = {3, 1, 5, 2, 7, 6, 4};
-
-        std::unordered_set<int> s1{src1};
-        test_contains(
-            "initializer list initialization",
-            check1.begin(), check1.end(), s1
-        );
-        test_eq("size", s1.size(), 7U);
-
-        std::unordered_set<int> s2{src1.begin(), src1.end()};
-        test_contains(
-            "iterator range initialization",
-            check1.begin(), check1.end(), s2
-        );
-
-        std::unordered_set<int> s3{s1};
-        test_contains(
-            "copy initialization",
-            check1.begin(), check1.end(), s3
-        );
-
-        std::unordered_set<int> s4{std::move(s1)};
-        test_contains(
-            "move initialization",
-            check1.begin(), check1.end(), s4
-        );
-        test_eq("move initialization - origin empty", s1.size(), 0U);
-        test_eq("empty", s1.empty(), true);
-
-        s1 = s4;
-        test_contains(
-            "copy assignment",
-            check1.begin(), check1.end(), s1
-        );
-
-        s4 = std::move(s1);
-        test_contains(
-            "move assignment",
-            check1.begin(), check1.end(), s4
-        );
-        test_eq("move assignment - origin empty", s1.size(), 0U);
-
-        s1 = src1;
-        test_contains(
-            "initializer list assignment",
-            check1.begin(), check1.end(), s1
-        );
-    }
-
-    void unordered_set_test::test_emplace_insert()
-    {
-        std::unordered_set<int> set1{};
-
-        auto res1 = set1.emplace(1);
-        test_eq("first emplace succession", res1.second, true);
-        test_eq("first emplace equivalence", *res1.first, 1);
-
-        auto res2 = set1.emplace(1);
-        test_eq("second emplace failure", res2.second, false);
-        test_eq("second emplace equivalence", *res2.first, 1);
-
-        auto res3 = set1.emplace_hint(set1.begin(), 2);
-        test_eq("first emplace_hint succession", (res3 != set1.end()), true);
-        test_eq("first emplace_hint equivalence", *res3, 2);
-
-        auto res4 = set1.emplace_hint(set1.begin(), 2);
-        test_eq("second emplace_hint failure", (res4 != set1.end()), true);
-        test_eq("second emplace_hint equivalence", *res4, 2);
-
-        std::unordered_set<std::string> set2{};
-        auto res5 = set2.insert("A");
-        test_eq("conversion insert succession", res5.second, true);
-        test_eq("conversion insert equivalence", *res5.first, std::string{"A"});
-
-        auto res6 = set2.insert(std::string{"B"});
-        test_eq("first insert succession", res6.second, true);
-        test_eq("first insert equivalence", *res6.first, std::string{"B"});
-
-        auto res7 = set2.insert(std::string{"B"});
-        test_eq("second insert failure", res7.second, false);
-        test_eq("second insert equivalence", *res7.first, std::string{"B"});
-
-        auto res10 = set1.erase(set1.find(2));
-        test_eq("erase", set1.find(2), set1.end());
-        test_eq("highest erased", res10, set1.end());
-
-        set2.insert(std::string{"G"});
-        set2.insert(std::string{"H"});
-        set2.insert(std::string{"K"});
-        auto res11 = set2.erase(std::string{"G"});
-        test_eq("erase by key pt1", res11, 1U);
-        auto res12 = set2.erase(std::string{"M"});
-        test_eq("erase by key pt2", res12, 0U);
-
-        std::unordered_set<int> set3{};
-        set3.insert(1);
-        auto res13 = set3.erase(1);
-        test_eq("erase only element by key pt1", res13, 1U);
-        test_eq("erase only element by key pt2", set3.empty(), true);
-
-        set3.insert(3);
-        auto res14 = set3.erase(set3.begin());
-        test_eq("erase only element by iterator pt1", res14, set3.end());
-        test_eq("erase only element by iterator pt2", set3.empty(), true);
-
-        set2.clear();
-        test_eq("clear", set2.empty(), true);
-
-        set3.insert(1);
-        auto res15 = set3.count(1);
-        test_eq("count", res15, 1U);
-
-        set3.insert(15);
-        auto res16 = set3.find(15);
-        test_eq("find", *res16, 15);
-    }
-
-    void unordered_set_test::test_multi()
-    {
-        auto check_keys = {1, 2, 3, 4, 5, 6, 7};
-        auto check_counts = {1U, 1U, 2U, 1U, 1U, 3U, 1U};
-        auto src1 = {3, 6, 1, 5, 6, 3, 2, 7, 6, 4};
-
-        std::unordered_multiset<int> mset{src1};
-        test_contains_multi(
-            "multi construction",
-            check_keys.begin(), check_keys.end(),
-            check_counts.begin(), mset
-        );
-
-        auto res1 = mset.count(6);
-        test_eq("multi count", res1, 3U);
-
-        auto res2 = mset.emplace(7);
-        test_eq("multi duplicit emplace pt1", *res2, 7);
-        test_eq("multi duplicit emplace pt2", mset.count(7), 2U);
-
-        auto res3 = mset.emplace(8);
-        test_eq("multi unique emplace pt1", *res3, 8);
-        test_eq("multi unique emplace pt2", mset.count(8), 1U);
-
-        auto res4 = mset.insert(8);
-        test_eq("multi duplicit insert pt1", *res4, 8);
-        test_eq("multi duplicit insert pt2", mset.count(8), 2U);
-
-        auto res5 = mset.insert(9);
-        test_eq("multi unique insert pt1", *res5, 9);
-        test_eq("multi unique insert pt2", mset.count(9), 1U);
-
-        auto res6 = mset.erase(8);
-        test_eq("multi erase by key pt1", res6, 2U);
-        test_eq("multi erase by key pt2", mset.count(8), 0U);
-
-        auto res7 = mset.erase(mset.find(7));
-        test_eq("multi erase by iterator pt1", *res7, 7);
-        test_eq("multi erase by iterator pt2", mset.count(7), 1U);
-    }
-}
Index: pace/lib/cpp/src/internal/test/vector.cpp
===================================================================
--- uspace/lib/cpp/src/internal/test/vector.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,230 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <algorithm>
-#include <initializer_list>
-#include <internal/test/tests.hpp>
-#include <utility>
-#include <vector>
-
-namespace std::test
-{
-    bool vector_test::run(bool report)
-    {
-        report_ = report;
-        start();
-
-        test_construction_and_assignment();
-        test_insert();
-        test_erase();
-
-        return end();
-    }
-
-    const char* vector_test::name()
-    {
-        return "vector";
-    }
-
-    void vector_test::test_construction_and_assignment()
-    {
-        auto check1 = {1, 2, 3, 4};
-        auto check2 = {4, 3, 2, 1};
-        auto check3 = {5, 5, 5, 5};
-
-        std::vector<int> vec1{};
-        vec1.push_back(1);
-        vec1.push_back(2);
-        vec1.push_back(3);
-        vec1.push_back(4);
-        test_eq(
-            "default constructor + push_back",
-            vec1.begin(), vec1.end(),
-            check1.begin(), check1.end()
-        );
-
-        std::vector<int> vec2{4, 3, 2, 1};
-        test_eq(
-            "initializer list constructor",
-            vec2.begin(), vec2.end(),
-            check2.begin(), check2.end()
-        );
-
-        std::vector<int> vec3(11);
-        test_eq("capacity constructor", 11ul, vec3.capacity());
-
-        std::vector<int> vec4(4ul, 5);
-        test_eq(
-            "replication constructor",
-            vec4.begin(), vec4.end(),
-            check3.begin(), check3.end()
-        );
-
-        // TODO: iterator constructor when implemented
-
-        std::vector<int> vec6{vec4};
-        test_eq(
-            "copy constructor",
-            vec6.begin(), vec6.end(),
-            vec4.begin(), vec4.end()
-        );
-
-        std::vector<int> vec7{std::move(vec6)};
-        test_eq(
-            "move constructor equality",
-            vec7.begin(), vec7.end(),
-            vec4.begin(), vec4.end()
-        );
-        test_eq(
-            "move constructor source empty",
-            vec6.size(), 0ul
-        );
-
-        std::vector<int> vec8{check1};
-        test_eq(
-            "explicit initializer list constructor",
-            vec8.begin(), vec8.end(),
-            check1.begin(), check1.end()
-        );
-
-        std::vector<int> vec9{};
-        vec9 = vec8;
-        test_eq(
-            "copy assignment",
-            vec9.begin(), vec9.end(),
-            vec8.begin(), vec8.end()
-        );
-
-        // TODO: move assignment when implemented
-        std::vector<int> vec10{};
-        vec10 = std::move(vec9);
-        test_eq(
-            "move assignment",
-            vec10.begin(), vec10.end(),
-            vec8.begin(), vec8.end()
-        );
-
-        test_eq("move assignment origin empty", vec9.size(), 0U);
-    }
-
-    void vector_test::test_insert()
-    {
-        auto check1 = {1, 2, 3, 99, 4, 5};
-        auto check2 = {1, 2, 3, 99, 99, 99, 99, 99, 4, 5};
-        auto check3 = {1, 2, 3, 1, 2, 3, 99, 4, 5, 4, 5};
-
-        std::vector<int> vec1{1, 2, 3, 4, 5};
-        auto it = vec1.insert(vec1.begin() + 3, 99);
-        test_eq(
-            "single element insert",
-            vec1.begin(), vec1.end(),
-            check1.begin(), check1.end()
-        );
-        test_eq(
-            "iterator returned from insert",
-            *it, 99
-        );
-
-        std::vector<int> vec2{1, 2, 3, 4, 5};
-        vec2.insert(vec2.begin() + 3, 5ul, 99);
-        test_eq(
-            "multiple element insert",
-            vec2.begin(), vec2.end(),
-            check2.begin(), check2.end()
-        );
-
-        std::vector<int> vec3{1, 2, 3, 4, 5};
-        vec3.insert(vec3.begin() + 3, vec2.begin() + 3, vec2.begin() + 8);
-        test_eq(
-            "iterator insert",
-            vec3.begin(), vec3.end(),
-            check2.begin(), check2.end()
-        );
-
-        std::vector<int> vec4{1, 2, 3, 4, 5};
-        vec4.insert(vec4.begin() + 3, check1);
-        test_eq(
-            "initializer list insert",
-            vec4.begin(), vec4.end(),
-            check3.begin(), check3.end()
-        );
-
-        std::vector<int> vec5{1, 2, 3, 4, 5};
-        vec5.insert(vec5.begin() + 3, {1, 2, 3, 99, 4, 5});
-        test_eq(
-            "implicit initializer list insert",
-            vec5.begin(), vec5.end(),
-            check3.begin(), check3.end()
-        );
-
-        std::vector<int> vec6{};
-        vec6.insert(vec6.begin(), check3);
-        test_eq(
-            "insert to empty vector",
-            vec6.begin(), vec6.end(),
-            check3.begin(), check3.end()
-        );
-    }
-
-    void vector_test::test_erase()
-    {
-        auto check1 = {1, 2, 3, 5};
-        auto check2 = {1, 5};
-        auto check3 = {1, 3, 5};
-
-        std::vector<int> vec1{1, 2, 3, 4, 5};
-        vec1.erase(vec1.begin() + 3);
-        test_eq(
-            "single element erase",
-            vec1.begin(), vec1.end(),
-            check1.begin(), check1.end()
-        );
-
-        std::vector<int> vec2{1, 2, 3, 4, 5};
-        vec2.erase(vec2.begin() + 1, vec2.begin() + 4);
-        test_eq(
-            "range erase",
-            vec2.begin(), vec2.end(),
-            check2.begin(), check2.end()
-        );
-
-        std::vector<int> vec3{1, 2, 3, 4, 5};
-        for (auto it = vec3.begin(); it != vec3.end();)
-        {
-            if (*it % 2 == 0)
-                it = vec3.erase(it);
-            else
-                ++it;
-        }
-        test_eq(
-            "erase all even numbers",
-            vec3.begin(), vec3.end(),
-            check3.begin(), check3.end()
-        );
-    }
-}
Index: pace/lib/cpp/src/internal/trycatch.cpp
===================================================================
--- uspace/lib/cpp/src/internal/trycatch.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,31 +1,0 @@
-/*
- * Copyright (c) 2018 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <internal/trycatch.hpp>
-
-bool ::std::aux::exception_thrown{false};
Index: pace/lib/cpp/src/internal/unwind.cpp
===================================================================
--- uspace/lib/cpp/src/internal/unwind.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ 	(revision )
@@ -1,226 +1,0 @@
-/*
- * Copyright (c) 2017 Jaroslav Jindrak
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <cstdint>
-#include <cstdlib>
-
-namespace __cxxabiv1
-{
-    /**
-     * Stack unwinding functionality - Level 1.
-     */
-
-    enum _Unwind_Reason_Code
-    {
-        _URC_NO_REASON                = 0,
-        _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
-        _URC_FATAL_PHASE2_ERROR       = 2,
-        _URC_FATAL_PHASE1_ERROR       = 3,
-        _URC_NORMAL_STOP              = 4,
-        _URC_END_OF_STACK             = 5,
-        _URC_HANDLER_FOUND            = 6,
-        _URC_INSTALL_CONTEXT          = 7,
-        _URC_CONTINUE_UNWIND          = 8
-    };
-
-    struct _Unwind_Exception;
-    using _Unwind_Exception_Cleanup_Fn = void (*)(_Unwind_Reason_Code, _Unwind_Exception*);
-
-    struct _Unwind_Exception
-    {
-        std::uint64_t exception_class;
-        _Unwind_Exception_Cleanup_Fn exception_cleanup;
-        std::uint64_t private_1;
-        std::uint64_t private_2;
-    };
-
-    /* Opaque structure. */
-    struct _Unwind_Context;
-
-    using _Unwind_Action = int;
-    namespace
-    {
-        const _Unwind_Action _UA_SEARCH_PHASE  = 1;
-        const _Unwind_Action _UA_CLEANUP_PHASE = 2;
-        const _Unwind_Action _UA_HANDLER_FRAME = 4;
-        const _Unwind_Action _UA_FORCE_HANDLER = 8;
-    }
-
-    /**
-     * TODO: Explain parameter semantics.
-     */
-    using _Unwind_Stop_Fn = _Unwind_Reason_Code(*)(
-        int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
-        _Unwind_Context*, void*
-    );
-
-    extern "C" _Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception*, _Unwind_Stop_Fn, void*)
-    {
-        // TODO: implement
-        return _URC_NO_REASON;
-    }
-
-    extern "C" void _Unwind_Resume(_Unwind_Exception*)
-    {
-        // TODO: implement
-    }
-
-    extern "C" void _Unwind_DeleteException(_Unwind_Exception*)
-    {
-        // TODO: implement
-    }
-
-    extern "C" std::uint64_t _Unwind_GetGR(_Unwind_Context*, int)
-    {
-        // TODO: implement
-        return 0;
-    }
-
-    extern "C" void _Unwind_SetGR(_Unwind_Context*, int, std::uint64_t)
-    {
-        // TODO: implement
-    }
-
-    extern "C" std::uint64_t _Unwind_GetIP(_Unwind_Context*)
-    {
-        // TODO: implement
-        return 0;
-    }
-
-    extern "C" void _Unwind_SetIP(_Unwind_Context*, std::uint64_t)
-    {
-        // TODO: implement
-    }
-
-    extern "C" std::uint64_t _Unwind_GetLanguageSpecificData(_Unwind_Context*)
-    {
-        // TODO: implement
-        return 0;
-    }
-
-    extern "C" std::uint64_t _Unwind_GetRegionStart(_Unwind_Context*)
-    {
-        // TODO: implement
-        return 0;
-    }
-
-    /**
-     * TODO: Explain parameter semantics.
-     */
-    using __personality_routine = _Unwind_Reason_Code(*)(
-        int, _Unwind_Action, std::uint64_t, _Unwind_Exception*,
-        _Unwind_Context*, void*
-    );
-
-    /**
-     * Stack unwinding functionality - Level 2.
-     */
-    struct __cxa_exception
-    {
-        std::type_info* exceptionType;
-        void (*exceptionDestructor)(void*);
-        // TODO: Add handler types to <exception>.
-        /* std::unexpected_handler unexpectedHandler; */
-        void (*unexpectedHandler)();
-        /* std::terminate_handler terminateHandler; */
-        void (*terminateHandler)();
-        __cxa_exception* nextException;
-
-        int handlerCount;
-        int handlerSwitchValue;
-        const char* actionRecord;
-        const char* languageSpecificData;
-        void* catchTemp;
-        void* adjujstedPtr;
-
-        _Unwind_Exception unwindHeader;
-    };
-
-    struct __cxa_eh_globals
-    {
-        __cxa_exception* caughtExceptions;
-        unsigned int uncaughtExceptions;
-    };
-
-    extern "C" __cxa_eh_globals* __cxa_get_globals();
-
-    extern "C" __cxa_eh_globals* __cxa_get_globals_fast();
-
-    extern "C" void* __cxa_allocate_exception(std::size_t thrown_size)
-    {
-        // TODO: implement
-        return nullptr;
-    }
-
-    extern "C" void __cxa_free_exception(void* thrown_exception)
-    {
-        // TODO: implement
-    }
-
-    extern "C" void __cxa_throw(void* thrown_exception, std::type_info* tinfo, void (*dest)(void*))
-    {
-        // TODO: implement
-    }
-
-    extern "C" void* __cxa_get_exception_ptr(void*  exception_object)
-    {
-        // TODO: implement
-        return nullptr;
-    }
-
-    extern "C" void* __cxa_begin_catch(void* exception_object)
-    {
-        // TODO: implement
-        return nullptr;
-    }
-
-    extern "C" void __cxa_end_catch()
-    {
-        // TODO: implement
-    }
-
-    extern "C" void __cxa_rethrow()
-    {
-        // TODO: implement
-    }
-
-    extern "C" void __cxa_bad_cast()
-    {
-        // TODO: implement
-    }
-
-    extern "C" void __cxa_bad_typeid()
-    {
-        // TODO: implement
-    }
-
-    extern "C" void __cxa_throw_bad_array_new_length()
-    {
-        // TODO: implement
-    }
-}
Index: uspace/lib/cpp/src/iomanip.cpp
===================================================================
--- uspace/lib/cpp/src/iomanip.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/src/iomanip.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -27,5 +27,5 @@
  */
 
-#include <internal/iomanip.hpp>
+#include <__bits/iomanip.hpp>
 #include <iomanip>
 
Index: uspace/lib/cpp/src/iostream.cpp
===================================================================
--- uspace/lib/cpp/src/iostream.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/src/iostream.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -29,5 +29,5 @@
 #include <ios>
 #include <iostream>
-#include <internal/streambufs.hpp>
+#include <__bits/streambufs.hpp>
 #include <new>
 
Index: uspace/lib/cpp/src/new.cpp
===================================================================
--- uspace/lib/cpp/src/new.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/src/new.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -31,5 +31,5 @@
 namespace std
 {
-    const char* bad_alloc::what() const
+    const char* bad_alloc::what() const noexcept
     {
         return "std::bad_alloc";
Index: uspace/lib/cpp/src/typeinfo.cpp
===================================================================
--- uspace/lib/cpp/src/typeinfo.cpp	(revision fc151209d08902a2b7441325eb2ead039cd1da62)
+++ uspace/lib/cpp/src/typeinfo.cpp	(revision 7bbf91e6ed519996e55429154b0d7d21549dcf14)
@@ -39,5 +39,5 @@
     {
         return (this == &other) ||
-               std::str_cmp(name(), other.name());
+               std::hel::str_cmp(name(), other.name());
     }
 
