diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-05 23:15:37 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2021-02-05 23:15:37 +0200 |
commit | 919ad9d1022edec7fdd97f74ef50de26dde6aebb (patch) | |
tree | 2787aa63255b0ba6c682e4547a2030e591a6a55e /libk/type_traits.h | |
parent | Rewrite boot.s to use clang instead of nasm (diff) | |
download | kernel.cpp-919ad9d1022edec7fdd97f74ef50de26dde6aebb.tar.xz |
Add IntegerView
Diffstat (limited to 'libk/type_traits.h')
-rw-r--r-- | libk/type_traits.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libk/type_traits.h b/libk/type_traits.h index cef30c1..dc70339 100644 --- a/libk/type_traits.h +++ b/libk/type_traits.h @@ -1,10 +1,16 @@ #pragma once -template <class T, T v> struct integral_constant { +template <class T, T v> +struct integral_constant { constexpr T operator()() const { return v; } constexpr operator T() const { return v; } }; -template <class T, class U> struct is_same : integral_constant<bool, false> {}; +template <class T, class U> +struct is_same : integral_constant<bool, false> {}; -template <class T> struct is_same<T, T> : integral_constant<bool, true> {}; +template <class T> +struct is_same<T, T> : integral_constant<bool, true> {}; + +template <typename T> +struct is_unsigned : integral_constant<bool, (T{0} < static_cast<T>(-1))> {}; |