diff --git a/BAN/include/BAN/Traits.h b/BAN/include/BAN/Traits.h index c72704dd2f..5902978235 100644 --- a/BAN/include/BAN/Traits.h +++ b/BAN/include/BAN/Traits.h @@ -106,6 +106,36 @@ namespace BAN template inline constexpr bool is_unsigned_v = is_unsigned::value; template concept unsigned_integral = is_unsigned_v && is_integral_v; +#define __BAN_TRAITS_MAKE_UNSIGNED_CV(__type) \ + template<> struct make_unsigned<__type> { using type = unsigned __type; }; \ + template<> struct make_unsigned { using type = unsigned const __type; }; \ + template<> struct make_unsigned { using type = unsigned volatile __type; }; \ + template<> struct make_unsigned { using type = unsigned const volatile __type; }; + + template requires is_arithmetic_v struct make_unsigned { using type = T; }; + __BAN_TRAITS_MAKE_UNSIGNED_CV(char) + __BAN_TRAITS_MAKE_UNSIGNED_CV(short) + __BAN_TRAITS_MAKE_UNSIGNED_CV(int) + __BAN_TRAITS_MAKE_UNSIGNED_CV(long) + __BAN_TRAITS_MAKE_UNSIGNED_CV(long long) + template using make_unsigned_t = typename make_unsigned::type; +#undef __BAN_TRAITS_MAKE_UNSIGNED_CV + +#define __BAN_TRAITS_MAKE_SIGNED_CV(__type) \ + template<> struct make_signed { using type = __type; }; \ + template<> struct make_signed { using type = const __type; }; \ + template<> struct make_signed { using type = volatile __type; }; \ + template<> struct make_signed { using type = const volatile __type; }; + + template requires is_arithmetic_v struct make_signed { using type = T; }; + __BAN_TRAITS_MAKE_SIGNED_CV(char) + __BAN_TRAITS_MAKE_SIGNED_CV(short) + __BAN_TRAITS_MAKE_SIGNED_CV(int) + __BAN_TRAITS_MAKE_SIGNED_CV(long) + __BAN_TRAITS_MAKE_SIGNED_CV(long long) + template using make_signed_t = typename make_signed::type; +#undef __BAN_TRAITS_MAKE_SIGNED_CV + template struct less { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs < rhs; } }; template struct equal { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs == rhs; } }; template struct greater { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs > rhs; } };