From 0408aa9bbcc017c87a37deed0039189ac6aac10f Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 25 Jan 2024 14:16:41 +0200 Subject: [PATCH] BAN: Implement is_unsigned* traits and (un)?signed_integral concepts --- BAN/include/BAN/Traits.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/BAN/include/BAN/Traits.h b/BAN/include/BAN/Traits.h index d9690ee5..c72704dd 100644 --- a/BAN/include/BAN/Traits.h +++ b/BAN/include/BAN/Traits.h @@ -94,9 +94,17 @@ namespace BAN { template> struct is_signed { static constexpr bool value = T(-1) < T(0); }; template struct is_signed : false_type {}; + + template> struct is_unsigned { static constexpr bool value = T(0) < T(-1); }; + template struct is_unsigned : false_type {}; } template struct is_signed : detail::is_signed {}; template inline constexpr bool is_signed_v = is_signed::value; + template concept signed_integral = is_signed_v && is_integral_v; + + template struct is_unsigned : detail::is_unsigned {}; + template inline constexpr bool is_unsigned_v = is_unsigned::value; + template concept unsigned_integral = is_unsigned_v && is_integral_v; 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; } };