diff --git a/const_fmt/stdlib.h b/const_fmt/stdlib.h index 7c249ca..5444b7a 100644 --- a/const_fmt/stdlib.h +++ b/const_fmt/stdlib.h @@ -36,28 +36,71 @@ using size_t = uint16_t; */ +struct true_type { + constexpr static bool value = true; +}; + +struct false_type { + constexpr static bool value = false; +}; + + // clang-format off -template struct remove_reference { using type = T; }; -template struct remove_reference {using type = T; }; -template struct remove_reference { using type = T; }; +template struct remove_cv { typedef type_t type; }; +template struct remove_cv { typedef type_t type; }; +template struct remove_cv { typedef type_t type; }; +template struct remove_cv { typedef type_t type; }; -template -using remove_reference_t = typename std::remove_reference::type; +template struct remove_const { typedef type_t type; }; +template struct remove_const { typedef type_t type; }; + +template struct remove_volatile { typedef type_t type; }; +template struct remove_volatile { typedef type_t type; }; + +template struct remove_reference { using type = type_t; }; +template struct remove_reference { using type = type_t; }; +template struct remove_reference { using type = type_t; }; + +template using remove_reference_t = typename std::remove_reference::type; +template using remove_cv_t = typename std::remove_cv::type; +template using remove_const_t = typename std::remove_const::type; +template using remove_volatile_t = typename std::remove_volatile::type; -template struct remove_cv { typedef T type; }; -template struct remove_cv { typedef T type; }; -template struct remove_cv { typedef T type; }; -template struct remove_cv { typedef T type; }; +template struct is_integral_helper : public false_type {}; -template struct remove_const { typedef T type; }; -template struct remove_const { typedef T type; }; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; +template <> struct is_integral_helper : public true_type {}; -template struct remove_volatile { typedef T type; }; -template struct remove_volatile { typedef T type; }; +template +struct is_integral + : public is_integral_helper> {}; + + +template struct is_floating_point_helper : public false_type {}; + +template<> struct is_floating_point_helper : public true_type {}; +template<> struct is_floating_point_helper : public true_type {}; +template<> struct is_floating_point_helper : public true_type {}; + +template +struct is_floating_point + : public is_floating_point_helper>::type {}; -// clang-format on constexpr inline bool is_constant_evaluated() noexcept { @@ -65,8 +108,6 @@ constexpr inline bool is_constant_evaluated() noexcept { } -// clang-format off - template struct make_unsigned { using type = type_t; }; template <> struct make_unsigned { using type = char; };