Implemented integral type checking
This commit is contained in:
parent
53b791cb05
commit
ecdefe40e7
38
utils.hpp
38
utils.hpp
@ -10,15 +10,37 @@
|
||||
namespace uart {
|
||||
namespace util {
|
||||
|
||||
template <typename...>
|
||||
struct always_false {
|
||||
static constexpr auto value = false;
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
static constexpr auto always_false_v = always_false<Ts...>::value;
|
||||
|
||||
// clang-format off
|
||||
template <bool Val> struct set_bool { static constexpr auto value = Val; };
|
||||
|
||||
struct true_type : set_bool<true> {};
|
||||
struct false_type : set_bool<false> {};
|
||||
|
||||
template <typename...> struct always_false : false_type {};
|
||||
|
||||
template <typename... Ts> static constexpr auto always_false_v = always_false<Ts...>::value;
|
||||
|
||||
template <typename T> struct is_integral : false_type {};
|
||||
template <> struct is_integral<bool> : true_type {};
|
||||
template <> struct is_integral<char> : true_type {};
|
||||
template <> struct is_integral<signed char> : true_type {};
|
||||
template <> struct is_integral<unsigned char> : true_type {};
|
||||
template <> struct is_integral<short> : true_type {};
|
||||
template <> struct is_integral<int> : true_type {};
|
||||
template <> struct is_integral<long int> : true_type {};
|
||||
template <> struct is_integral<long long int> : true_type {};
|
||||
template <> struct is_integral<unsigned short> : true_type {};
|
||||
template <> struct is_integral<unsigned int> : true_type {};
|
||||
template <> struct is_integral<unsigned long int> : true_type {};
|
||||
template <> struct is_integral<unsigned long long int> : true_type {};
|
||||
|
||||
template <typename T> static constexpr auto is_integral_v = is_integral<T>::value;
|
||||
|
||||
template <typename T, typename U> struct is_same : false_type {};
|
||||
template <typename T> struct is_same<T, T> : true_type {};
|
||||
|
||||
template <typename T, typename U> static constexpr auto is_same_v = is_same<T, U>::value;
|
||||
|
||||
template <typename T>
|
||||
struct NumericLimits {
|
||||
static constexpr T min() { return T(); }
|
||||
|
Loading…
Reference in New Issue
Block a user