From 86930fd8b0fd93e8def5f85c446de84b9e8db483 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Thu, 24 Feb 2022 16:14:38 +0100 Subject: [PATCH] Added conepts; Fixed bug in const_fmt::std::true_type --- const_fmt/stdlib.h | 60 ++++++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/const_fmt/stdlib.h b/const_fmt/stdlib.h index 0e46a93..b963489 100644 --- a/const_fmt/stdlib.h +++ b/const_fmt/stdlib.h @@ -59,7 +59,7 @@ template struct is_same : public false_type {}; template -struct is_same : public false_type {}; +struct is_same : public true_type {}; // is_one_of @@ -110,23 +110,27 @@ template using remove_volatile_t = typename std::remove_volat template -struct is_integral { - constexpr static bool value = - is_one_of, bool, char, signed char, unsigned char, - wchar_t, char16_t, char32_t, short, unsigned short, int, - unsigned int, long, unsigned long, long long, - unsigned long long>::value; -}; +using is_integral = + is_one_of, bool, char, signed char, unsigned char, + wchar_t, char16_t, char32_t, short, unsigned short, int, + unsigned int, long, unsigned long, long long, unsigned long long>; + + +// is_signed + + +template +using is_signed_integer = is_one_of, signed char, signed short, + signed int, signed long, signed long long>; + // is_floating_point template -struct is_floating_point { - constexpr static bool value = - is_one_of, float, double, long double>::value; -}; +using is_floating_point = + is_one_of, float, double, long double>; // make_unsigned @@ -145,6 +149,16 @@ template <> struct make_unsigned { using type = unsigned long // clang-format on +// value definitions + +template +inline constexpr bool is_integral_v = is_integral::value; +template +inline constexpr bool is_signed_integer_v = is_signed_integer::value; +template +inline constexpr bool is_floating_point_v = is_floating_point::value; + + /* * * concepts @@ -152,17 +166,17 @@ template <> struct make_unsigned { using type = unsigned long */ -// template -// concept integral = is_integral_v<_Tp>; -// -// template -// concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; -// -// template -// concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; -// -// template -// concept floating_point = is_floating_point_v<_Tp>; +template +concept integral = is_integral_v; + +template +concept signed_integral = is_signed_integer_v; + +template +concept unsigned_integral = integral && !signed_integral; + +template +concept floating_point = is_floating_point_v; /*