diff options
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))> {}; |