35 template <
typename T,
typename S>
36 constexpr
bool is_cast_safe(S value) {
37 if (
static_cast<S
>(
static_cast<T
>(value)) != value) {
42 if constexpr (std::numeric_limits<T>::is_signed != std::numeric_limits<S>::is_signed) {
44 if constexpr (std::numeric_limits<S>::is_signed) {
49 return static_cast<unsigned long long>(value) <=
50 static_cast<unsigned long long>(std::numeric_limits<T>::max());
67 static const constexpr
char* name =
"unknown";
71 template <>
struct typeinfo<bool> {
static const constexpr
char* name =
"bool"; };
72 template <>
struct typeinfo<int8_t> {
static const constexpr
char* name =
"int8_t"; };
73 template <>
struct typeinfo<int16_t> {
static const constexpr
char* name =
"int16_t"; };
74 template <>
struct typeinfo<int32_t> {
static const constexpr
char* name =
"int32_t"; };
75 template <>
struct typeinfo<int64_t> {
static const constexpr
char* name =
"int64_t"; };
76 template <>
struct typeinfo<uint8_t> {
static const constexpr
char* name =
"uint8_t"; };
77 template <>
struct typeinfo<uint16_t> {
static const constexpr
char* name =
"uint16_t"; };
78 template <>
struct typeinfo<uint32_t> {
static const constexpr
char* name =
"uint32_t"; };
79 template <>
struct typeinfo<uint64_t> {
static const constexpr
char* name =
"uint64_t"; };
Definition: templates.hpp:66