Explorar el Código

refactor(gblibstdc++): add type_traits and utility

greatbridf hace 1 año
padre
commit
727c3c936a

+ 212 - 0
gblibstdc++/include/type_traits

@@ -3,6 +3,9 @@
 
 namespace std {
 
+template <typename... Ts>
+using void_t = void;
+
 template <typename T>
 struct remove_reference { using type = T; };
 template <typename T>
@@ -13,6 +16,215 @@ struct remove_reference<T&&> { using type = T; };
 template <typename T>
 using remove_reference_t = typename remove_reference<T>::type;
 
+namespace __helpers {
+
+template <typename T, typename = void> // for cv-void
+struct add_rvalue_reference { using type = T; };
+template <typename T> // cv-void will fail in substitution
+struct add_rvalue_reference<T, void_t<T&&> > { using type = T&&; };
+
+template <typename T, typename = void> // for cv-void
+struct add_lvalue_reference { using type = T; };
+template <typename T> // cv-void will fail in substitution
+struct add_lvalue_reference<T, void_t<T&> > { using type = T&; };
+
+} // namespace __helpers
+
+template <typename T>
+struct add_rvalue_reference {
+    using type = typename __helpers::add_rvalue_reference<T>::type;
+};
+template <typename T>
+struct add_lvalue_reference {
+    using type = typename __helpers::add_lvalue_reference<T>::type;
+};
+
+template <typename T>
+using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
+template <typename T>
+using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
+
+template <typename T>
+struct remove_pointer { using type = T; };
+template <typename T>
+struct remove_pointer<T*> { using type = T; };
+template <typename T>
+struct remove_pointer<T* const> { using type = T; };
+template <typename T>
+struct remove_pointer<T* volatile> { using type = T; };
+template <typename T>
+struct remove_pointer<T* const volatile> { using type = T; };
+
+template <typename T>
+using remove_pointer_t = typename remove_pointer<T>::type;
+
+template <typename T>
+struct add_pointer { using type = remove_reference_t<T>*; };
+
+template <typename T>
+using add_pointer_t = typename add_pointer<T>::type;
+
+template <typename T>
+struct remove_cv { using type = T; };
+template <typename T>
+struct remove_cv<T const> { using type = T; };
+template <typename T>
+struct remove_cv<T volatile> { using type = T; };
+template <typename T>
+struct remove_cv<T const volatile> { using type = T; };
+
+template <typename T>
+using remove_cv_t = typename remove_cv<T>::type;
+
+template <typename T>
+struct add_const { using type = T const; };
+template <typename T>
+struct add_volatile { using type = T volatile; };
+template <typename T>
+struct add_cv { using type = T const volatile; };
+
+template <typename T>
+using add_const_t = typename add_const<T>::type;
+template <typename T>
+using add_volatile_t = typename add_volatile<T>::type;
+template <typename T>
+using add_cv_t = typename add_cv<T>::type;
+
+template <typename T>
+struct decay {
+private:
+    using U = remove_reference_t<T>;
+public:
+    using type = remove_cv_t<U>;
+};
+
+template <typename T>
+using decay_t = typename decay<T>::type;
+
+template <typename T, T _value>
+struct integral_constant {
+    using value_type = T;
+    using type = integral_constant;
+
+    static constexpr value_type value = _value;
+    constexpr operator value_type() const noexcept { return value; }
+    constexpr value_type operator()() const noexcept { return value; }
+};
+
+template <bool _value>
+using bool_constant = integral_constant<bool, _value>;
+
+using true_type = bool_constant<true>;
+using false_type = bool_constant<false>;
+
+namespace __helpers {
+
+template <typename>
+struct template_true_type : public true_type {};
+template <typename>
+struct template_false_type : public false_type {};
+
+} // namespace __helpers
+
+template <bool condition, typename T, typename F>
+struct conditional { using type = F; };
+template <typename T, typename F>
+struct conditional<true, T, F> { using type = T; };
+
+template <bool condition, typename T, typename F>
+using conditional_t = typename conditional<condition, T, F>::type;
+
+template <typename T, typename U>
+struct is_same : public false_type {};
+template <typename T>
+struct is_same<T, T> : public true_type {};
+
+template <typename T, typename U>
+inline constexpr bool is_same_v = is_same<T, U>::value;
+
+template <typename T>
+struct is_void : public is_same<remove_cv_t<T>, void> {};
+
+template <typename T>
+inline constexpr bool is_void_v = is_void<T>::value;
+
+template <typename T>
+struct is_pointer : public false_type {};
+template <typename T>
+struct is_pointer<T*> : public true_type {};
+template <typename T>
+struct is_pointer<T* const> : public true_type {};
+template <typename T>
+struct is_pointer<T* volatile> : public true_type {};
+template <typename T>
+struct is_pointer<T* const volatile> : public true_type {};
+
+template <typename T>
+inline constexpr bool is_pointer_v = is_pointer<T>::value;
+
+template <typename T>
+struct is_const : public false_type {};
+template <typename T>
+struct is_const<T const> : public true_type {};
+
+template <typename T>
+inline constexpr bool is_const_v = is_const<T>::value;
+
+template <bool B, typename T = void>
+struct enable_if {};
+template <typename T>
+struct enable_if<true, T> { using type = T; };
+
+template <bool B, typename T = void>
+using enable_if_t = typename enable_if<B, T>::type;
+
+template <typename T>
+add_rvalue_reference_t<T> declval(void) noexcept
+{
+    static_assert(__helpers::template_false_type<T>::value, "declval cannot be evaluated.");
+}
+
+namespace __helpers {
+
+template <typename From, typename To, typename = void>
+struct is_convertible : public false_type {};
+template <typename From, typename To>
+struct is_convertible<From, To,
+    decltype(declval<void(*)(To)>()(declval<From>()))
+> : public true_type {};
+template <typename Void1, typename Void2>
+struct is_convertible<Void1, Void2,
+    enable_if_t<is_void_v<Void1> && is_void_v<Void2> >
+> : public true_type {};
+
+} // namespace __helpers
+
+template <typename From, typename To>
+struct is_convertible : public __helpers::is_convertible<From, To> {};
+
+template <typename From, typename To>
+inline constexpr bool is_convertible_v = is_convertible<From, To>::value;
+
+#define __CPP_GREATBRIDF
+#ifdef __CPP_GREATBRIDF
+
+template <typename U, template <typename...> class T, typename...>
+struct is_template_instance : public false_type {
+};
+template <template <typename...> class T, typename... Ts>
+struct is_template_instance<T<Ts...>, T> : public true_type {
+};
+
+template <typename U, template <typename...> class T, typename... Ts>
+inline constexpr bool is_template_instance_v = is_template_instance<U, T, Ts...>::value;
+
+template <typename T>
+using template_false_type = __helpers::template_false_type<T>;
+template <typename T>
+using template_true_type = __helpers::template_true_type<T>;
+
+#endif
+
 } // namespace std
 
 #endif

+ 1 - 1
include/fs/fat.hpp

@@ -128,7 +128,7 @@ private:
         int ref;
         // bool dirty;
     };
-    types::hash_map<cluster_t, buf_object, types::linux_hasher<cluster_t>> buf;
+    types::hash_map<cluster_t, buf_object> buf;
 
     // buf MUST be larger than 512 bytes
     inline void _raw_read_sector(void* buf, uint32_t sector_no);

+ 7 - 7
include/kernel/hw/port.hpp

@@ -1,7 +1,7 @@
 #pragma once
 
 #include <stdint.h>
-#include <types/cplusplus.hpp>
+#include <type_traits>
 
 namespace hw {
 template <typename port_size_t, bool r = true, bool w = true>
@@ -18,15 +18,15 @@ public:
     port_size_t operator*(void) const
     {
         static_assert(
-            types::is_same<port_size_t, uint8_t>::value || types::is_same<port_size_t, uint16_t>::value,
+            std::is_same_v<port_size_t, uint8_t> || std::is_same_v<port_size_t, uint16_t>,
             "this type is not implemented yet.");
         port_size_t ret;
-        if constexpr (types::is_same<port_size_t, uint8_t>::value)
+        if constexpr (std::is_same_v<port_size_t, uint8_t>)
             asm volatile(
                 "inb %1, %0"
                 : "=a"(ret)
                 : "d"(mp));
-        if constexpr (types::is_same<port_size_t, uint16_t>::value)
+        if constexpr (std::is_same_v<port_size_t, uint16_t>)
             asm volatile(
                 "inw %1, %0"
                 : "=a"(ret)
@@ -37,14 +37,14 @@ public:
     port_size_t operator=(port_size_t n) const
     {
         static_assert(
-            types::is_same<port_size_t, uint8_t>::value || types::is_same<port_size_t, uint16_t>::value,
+            std::is_same_v<port_size_t, uint8_t> || std::is_same_v<port_size_t, uint16_t>,
             "this type is not implemented yet.");
-        if constexpr (types::is_same<port_size_t, uint8_t>::value)
+        if constexpr (std::is_same_v<port_size_t, uint8_t>)
             asm volatile(
                 "outb %1, %0"
                 :
                 : "d"(mp), "a"(n));
-        if constexpr (types::is_same<port_size_t, uint16_t>::value)
+        if constexpr (std::is_same_v<port_size_t, uint16_t>)
             asm volatile(
                 "outw %1, %0"
                 :

+ 1 - 1
include/kernel/process.hpp

@@ -387,7 +387,7 @@ private:
 class proclist final {
 public:
     using list_type = types::map<pid_t, process>;
-    using child_index_type = types::hash_map<pid_t, types::list<pid_t>, types::linux_hasher<pid_t>>;
+    using child_index_type = types::hash_map<pid_t, types::list<pid_t>>;
     using tty_index_type = types::map<pid_t, tty*>;
     using iterator_type = list_type::iterator_type;
     using const_iterator_type = list_type::const_iterator_type;

+ 2 - 2
include/kernel/vfs.hpp

@@ -108,7 +108,7 @@ public:
 
     private:
         types::list<dentry, allocator_type>* children = nullptr;
-        types::hash_map<name_type, dentry*, types::string_hasher<const name_type&>, allocator_type>* idx_children = nullptr;
+        types::hash_map<name_type, dentry*, types::linux_hasher, allocator_type>* idx_children = nullptr;
 
     public:
         dentry* parent;
@@ -152,7 +152,7 @@ private:
 
 private:
     inode_list _inodes;
-    types::hash_map<dentry*, dentry*, types::linux_hasher<dentry*>> _mount_recover_list;
+    types::hash_map<dentry*, dentry*> _mount_recover_list;
 
 protected:
     dentry _root;

+ 5 - 2
include/types/allocator.hpp

@@ -1,5 +1,6 @@
 #pragma once
 #include <utility>
+#include <type_traits>
 #include <assert.h>
 #include <stdint.h>
 #include <types/cplusplus.hpp>
@@ -172,10 +173,12 @@ concept Allocator = requires(size_t size, typename T::value_type* ptr)
     typename T::value_type;
     {
         T::allocate_memory(size)
-        } -> same_as<typename T::value_type*>;
+    };
     {
         T::deallocate_memory(ptr)
-        } -> same_as<void>;
+    };
+    std::is_same_v<typename T::value_type*, decltype(T::allocate_memory(size))>;
+    std::is_same_v<void, decltype(T::deallocate_memory(ptr))>;
 };
 
 template <Allocator T>

+ 2 - 155
include/types/cplusplus.hpp

@@ -1,166 +1,13 @@
 #pragma once
 
-#include <stdint.h>
-
 #ifdef __cplusplus
+#include <type_traits>
 
 namespace types {
 
-template <typename T, T _value>
-struct constant_value {
-    static constexpr T value = _value;
-};
-using true_type = constant_value<bool, true>;
-using false_type = constant_value<bool, false>;
-
-};
-
-namespace types::traits {
-
-template <bool Expression, typename TTrue, typename TFalse>
-struct condition {
-    using type = TFalse;
-};
-template <typename TTrue, typename TFalse>
-struct condition<true, TTrue, TFalse> {
-    using type = TTrue;
-};
-
-template <typename T>
-struct remove_pointer {
-    using type = T;
-};
-template <typename T>
-struct remove_pointer<T*> {
-    using type = T;
-};
-template <typename T>
-struct remove_reference {
-    using type = T;
-};
-template <typename T>
-struct remove_reference<T&> {
-    using type = T;
-};
-template <typename T>
-struct remove_reference<T&&> {
-    using type = T;
-};
-
-template <typename T>
-struct add_pointer {
-    using type = T*;
-};
-
-template <typename T>
-struct add_reference {
-    using type = T&;
-};
-
-template <typename T>
-struct remove_cv {
-    using type = T;
-};
-template <typename T>
-struct remove_cv<const T> {
-    using type = T;
-};
-template <typename T>
-struct remove_cv<volatile T> {
-    using type = T;
-};
-template <typename T>
-struct remove_cv<const volatile T> {
-    using type = T;
-};
-
-template <typename T>
-struct add_const {
-    using type = const T;
-};
-template <typename T>
-struct add_const<const T> {
-    using type = const T;
-};
-template <>
-struct add_const<void> {
-    using type = void;
-};
-
-template <typename T>
-struct is_pointer : false_type {
-};
-
-template <typename T>
-struct is_pointer<T*> : true_type {
-};
-
-template <typename T>
-struct is_const : public false_type {
-};
-template <typename T>
-struct is_const<const T> : public true_type {
-};
-
-template <typename U, template <typename...> class T, typename...>
-struct is_template_instance : public false_type {
-};
-template <template <typename...> class T, typename... Ts>
-struct is_template_instance<T<Ts...>, T> : public true_type {
-};
-
-template <typename T>
-struct decay {
-private:
-    using U = typename remove_reference<T>::type;
-
-public:
-    using type = typename remove_cv<U>::type;
-};
-
-} // namespace types::traits
-
-namespace types {
-template <typename>
-struct template_true_type : public true_type {
-};
-template <typename>
-struct template_false_type : public false_type {
-};
-
-template <typename, typename>
-struct is_same : false_type {
-};
-
-template <typename T>
-struct is_same<T, T> : true_type {
-};
-
-template <typename T>
-struct add_rvalue_reference {
-    using type = T&&;
-};
-template <>
-struct add_rvalue_reference<void> {
-    using type = void;
-};
-
-template <typename Src, typename Dst>
-concept convertible_to = (traits::is_pointer<Src>::value && is_same<Dst, uint32_t>::value)
-    || (traits::is_pointer<Dst>::value && is_same<Src, uint32_t>::value)
-    || requires(Src _src)
-{
-    { static_cast<Dst>(_src) };
-};
-
-template <typename T>
-concept PointerType = traits::is_pointer<T>::value;
-
-template <typename A, typename B>
-concept same_as = is_same<A, B>::value;
-
 class non_copyable {
 public:
+    virtual ~non_copyable() = default;
     non_copyable() = default;
     non_copyable(const non_copyable&) = delete;
     non_copyable& operator=(const non_copyable&) = delete;

+ 4 - 3
include/types/function.hpp

@@ -1,5 +1,6 @@
 #pragma once
-#include <types/cplusplus.hpp>
+#include <utility>
+#include <type_traits>
 
 namespace std {
 
@@ -57,8 +58,8 @@ public:
     template <typename FuncPtr>
     constexpr function(FuncPtr* funcPtr)
     {
-        new (_f()) __inner::_function<typename types::traits::decay<FuncPtr>::type, Ret, Args...>(
-            std::forward<typename types::traits::decay<FuncPtr>::type>(funcPtr));
+        new (_f()) __inner::_function<std::decay_t<FuncPtr>, Ret, Args...>(
+            std::forward<std::decay_t<FuncPtr>>(funcPtr));
     }
 
     constexpr ~function()

+ 43 - 38
include/types/hash_map.hpp

@@ -1,5 +1,6 @@
 #pragma once
 #include <utility>
+#include <type_traits>
 
 #include <stdint.h>
 #include <types/allocator.hpp>
@@ -29,31 +30,31 @@ static inline constexpr hash_t hash32(uint32_t val, uint32_t bits)
     return _hash32(val) >> (32 - bits);
 }
 
-template <convertible_to<uint32_t> T>
-struct linux_hasher {
+template <typename T, typename = void>
+struct linux_hasher {};
+
+template <typename T>
+inline constexpr bool is_c_string_v = std::is_same_v<std::decay_t<T>, char*>
+    || std::is_same_v<std::decay_t<T>, const char*>;
+
+template <typename T>
+struct linux_hasher<T, std::enable_if_t<std::is_convertible_v<T, uint32_t>>> {
     static inline constexpr hash_t hash(T val, uint32_t bits)
     {
         return hash32(static_cast<uint32_t>(val), bits);
     }
 };
 template <typename T>
-struct linux_hasher<T*> {
-    static inline constexpr hash_t hash(T* val, uint32_t bits)
+struct linux_hasher<T,
+    std::enable_if_t<std::is_pointer_v<T> && !is_c_string_v<T>>> {
+    static inline constexpr hash_t hash(T val, uint32_t bits)
     {
         return hash32(reinterpret_cast<uint32_t>(val), bits);
     }
 };
 
 template <typename T>
-struct string_hasher {
-    static inline constexpr hash_t hash(T, uint32_t)
-    {
-        static_assert(types::template_false_type<T>::value, "string hasher does not support this type");
-        return (hash_t)0;
-    }
-};
-template <>
-struct string_hasher<const char*> {
+struct linux_hasher<T, std::enable_if_t<is_c_string_v<T>>> {
     static inline constexpr hash_t hash(const char* str, uint32_t bits)
     {
         constexpr uint32_t seed = 131;
@@ -65,36 +66,38 @@ struct string_hasher<const char*> {
         return hash32(hash, bits);
     }
 };
-template <template <typename> class Allocator>
-struct string_hasher<const types::string<Allocator>&> {
-    static inline constexpr hash_t hash(const types::string<Allocator>& str, uint32_t bits)
+template <
+    template <template <typename> class> class String,
+    template <typename> class Allocator>
+struct linux_hasher<String<Allocator>,
+    std::enable_if_t<
+        std::is_same_v<
+            std::decay_t<String<Allocator>>, types::string<Allocator>
+        >
+    >
+> {
+    static inline constexpr hash_t hash(types::string<Allocator>&& str, uint32_t bits)
     {
-        return string_hasher<const char*>::hash(str.c_str(), bits);
+        return linux_hasher<const char*>::hash(str.c_str(), bits);
     }
-};
-template <template <typename> class Allocator>
-struct string_hasher<types::string<Allocator>&&> {
-    static inline constexpr uint32_t hash(types::string<Allocator>&& str, uint32_t bits)
+    static inline constexpr hash_t hash(const types::string<Allocator>& str, uint32_t bits)
     {
-        return string_hasher<const char*>::hash(str.c_str(), bits);
+        return linux_hasher<const char*>::hash(str.c_str(), bits);
     }
 };
 
-template <typename _Hasher, typename Value>
-concept Hasher = requires(Value&& val, uint32_t bits)
-{
-    {
-        _Hasher::hash(val, bits)
-        } -> convertible_to<size_t>;
-};
-
-template <typename Key, typename Value, Hasher<Key> _Hasher, template <typename _T> class Allocator = types::kernel_allocator>
+template <typename Key, typename Value,
+    template <typename _Key, typename...> class Hasher = types::linux_hasher,
+    template <typename _T> class Allocator = types::kernel_allocator,
+    std::enable_if_t<std::is_convertible_v<hash_t, decltype(
+        Hasher<Key>::hash(std::declval<Key>(), std::declval<uint32_t>())
+    )>, bool> = true>
 class hash_map {
 public:
     template <typename Pointer>
     class iterator;
 
-    using key_type = typename traits::add_const<Key>::type;
+    using key_type = std::add_const_t<Key>;
     using value_type = Value;
     using pair_type = pair<key_type, value_type>;
     using size_type = size_t;
@@ -105,14 +108,16 @@ public:
     using bucket_type = list<pair_type, Allocator>;
     using bucket_array_type = vector<bucket_type, Allocator>;
 
+    using hasher_type = Hasher<Key>;
+
     static constexpr size_type INITIAL_BUCKETS_ALLOCATED = 64;
 
 public:
     template <typename Pointer>
     class iterator {
     public:
-        using _Value = typename traits::remove_pointer<Pointer>::type;
-        using Reference = typename traits::add_reference<_Value>::type;
+        using _Value = std::remove_pointer_t<Pointer>;
+        using Reference = std::add_lvalue_reference_t<_Value>;
 
         friend class hash_map;
 
@@ -213,7 +218,7 @@ public:
 
     constexpr void emplace(pair_type&& p)
     {
-        auto hash_value = _Hasher::hash(p.key, hash_length());
+        auto hash_value = hasher_type::hash(p.key, hash_length());
         buckets.at(hash_value).push_back(std::move(p));
     }
 
@@ -225,7 +230,7 @@ public:
 
     constexpr void remove(const key_type& key)
     {
-        auto hash_value = _Hasher::hash(key, hash_length());
+        auto hash_value = hasher_type::hash(key, hash_length());
         auto& bucket = buckets.at(hash_value);
         for (auto iter = bucket.begin(); iter != bucket.end(); ++iter) {
             if (iter->key == key) {
@@ -248,7 +253,7 @@ public:
 
     constexpr iterator_type find(const key_type& key)
     {
-        auto hash_value = _Hasher::hash(key, hash_length());
+        auto hash_value = hasher_type::hash(key, hash_length());
         auto& bucket = buckets.at(hash_value);
         for (auto& item : bucket) {
             if (key == item.key)
@@ -259,7 +264,7 @@ public:
 
     constexpr const_iterator_type find(const key_type& key) const
     {
-        auto hash_value = _Hasher::hash(key, hash_length());
+        auto hash_value = hasher_type::hash(key, hash_length());
         const auto& bucket = buckets.at(hash_value);
         for (auto iter = bucket.cbegin(); iter != bucket.cend(); ++iter) {
             if (key == iter->key)

+ 4 - 3
include/types/list.hpp

@@ -1,7 +1,8 @@
 #pragma once
+#include <utility>
+#include <type_traits>
 
 #include <types/allocator.hpp>
-#include <types/cplusplus.hpp>
 #include <types/types.h>
 
 namespace types {
@@ -63,8 +64,8 @@ public:
     template <typename Pointer>
     class iterator {
     public:
-        using Value = typename types::traits::remove_pointer<Pointer>::type;
-        using Reference = typename types::traits::add_reference<Value>::type;
+        using Value = std::remove_pointer_t<Pointer>;
+        using Reference = std::add_lvalue_reference_t<Value>;
 
         friend class list;
 

+ 6 - 6
include/types/map.hpp

@@ -1,8 +1,8 @@
 #pragma once
 #include <utility>
+#include <type_traits>
 
 #include <types/allocator.hpp>
-#include <types/cplusplus.hpp>
 #include <types/pair.hpp>
 #include <types/types.h>
 
@@ -11,7 +11,7 @@ namespace types {
 template <typename Key, typename Value, template <typename _T> class _Allocator = kernel_allocator>
 class map {
 public:
-    using key_type = typename traits::add_const<Key>::type;
+    using key_type = std::add_const_t<Key>;
     using value_type = Value;
     using pair_type = pair<key_type, value_type>;
 
@@ -298,10 +298,10 @@ public:
     template <bool Const>
     class iterator {
     public:
-        using node_pointer_type = typename traits::condition<Const, const node*, node*>::type;
-        using value_type = typename traits::condition<Const, const pair_type, pair_type>::type;
-        using pointer_type = typename traits::add_pointer<value_type>::type;
-        using reference_type = typename traits::add_reference<value_type>::type;
+        using node_pointer_type = std::conditional_t<Const, const node*, node*>;
+        using value_type = std::conditional_t<Const, const pair_type, pair_type>;
+        using pointer_type = std::add_pointer_t<value_type>;
+        using reference_type = std::add_lvalue_reference_t<value_type>;
 
         friend class map;
 

+ 7 - 8
include/types/pair.hpp

@@ -1,7 +1,6 @@
 #pragma once
 #include <utility>
-
-#include <types/cplusplus.hpp>
+#include <type_traits>
 
 namespace types {
 
@@ -30,16 +29,16 @@ struct pair {
         : key(val.key)
         , value(val.value)
     {
-        static_assert(is_same<typename traits::decay<_key_type>::type, typename traits::decay<key_type>::type>::value);
-        static_assert(is_same<typename traits::decay<_value_type>::type, typename traits::decay<value_type>::type>::value);
+        static_assert(std::is_same_v<std::decay_t<_key_type>, std::decay_t<key_type>>);
+        static_assert(std::is_same_v<std::decay_t<_value_type>, std::decay_t<value_type>>);
     }
     template <typename _key_type, typename _value_type>
     constexpr pair(pair<_key_type, _value_type>&& val)
         : key(std::move(val.key))
         , value(std::move(val.value))
     {
-        static_assert(is_same<typename traits::decay<_key_type>::type, typename traits::decay<key_type>::type>::value);
-        static_assert(is_same<typename traits::decay<_value_type>::type, typename traits::decay<value_type>::type>::value);
+        static_assert(std::is_same_v<std::decay_t<_key_type>, std::decay_t<key_type>>);
+        static_assert(std::is_same_v<std::decay_t<_value_type>, std::decay_t<value_type>>);
     }
     constexpr pair(const pair& val)
         : key(val.key)
@@ -84,10 +83,10 @@ struct pair {
 };
 
 template <typename T1, typename T2>
-constexpr pair<typename traits::decay<T1>::type, typename traits::decay<T2>::type>
+constexpr pair<std::decay_t<T1>, std::decay_t<T2>>
 make_pair(T1&& t1, T2&& t2)
 {
-    return pair<typename traits::decay<T1>::type, typename traits::decay<T2>::type> { std::forward<T1>(t1), std::forward<T2>(t2) };
+    return pair<std::decay_t<T1>, std::decay_t<T2>> { std::forward<T1>(t1), std::forward<T2>(t2) };
 }
 
 } // namespace types

+ 5 - 0
include/types/path.hpp

@@ -0,0 +1,5 @@
+#pragma once
+
+namespace std {
+
+} // namespace std

+ 3 - 3
include/types/vector.hpp

@@ -1,9 +1,9 @@
 #pragma once
 #include <utility>
+#include <type_traits>
 
 #include <assert.h>
 #include <types/allocator.hpp>
-#include <types/cplusplus.hpp>
 #include <types/types.h>
 
 namespace types {
@@ -28,8 +28,8 @@ public:
     template <typename Pointer>
     class iterator {
     public:
-        using Value = typename types::traits::remove_pointer<Pointer>::type;
-        using Reference = typename types::traits::add_reference<Value>::type;
+        using Value = std::remove_pointer_t<Pointer>;
+        using Reference = std::add_lvalue_reference_t<Value>;
 
     public:
         constexpr iterator(const iterator& iter) noexcept

+ 1 - 1
src/kernel/mem.cpp

@@ -375,7 +375,7 @@ struct mapped_area {
 };
 
 static types::hash_map<page_t, mapped_area,
-    types::linux_hasher<page_t>, types::kernel_ident_allocator>
+    types::linux_hasher, types::kernel_ident_allocator>
     mapped;
 static uint8_t freebm[0x400 / 8];
 } // namespace __physmapper

+ 2 - 0
src/kernel/vfs.cpp

@@ -705,10 +705,12 @@ void init_vfs(void)
     vfs_mkfile(fs_root, "init");
 
     auto* init = vfs_open("/init");
+    assert(init);
     const char* str = "#/bin/sh\nexec /bin/sh\n";
     vfs_write(init->ind, str, 0, strlen(str));
 
     auto* dev = vfs_open("/dev");
+    assert(dev);
     vfs_mknode(dev, "null", { .in { .major = 0, .minor = 0 } });
     vfs_mknode(dev, "console", { .in { .major = 1, .minor = 0 } });
     vfs_mknode(dev, "hda", { .in { .major = 2, .minor = 0 } });