@@ -60,22 +60,27 @@ struct NumericAttributeTraits
60
60
static constexpr WorkingType StorageToWorking (StorageType storageValue) { return storageValue; }
61
61
62
62
private:
63
+ // Ensure that this generic NumericAttributeTraits implementation is being used for some type for which it
64
+ // actually works.
65
+ static_assert (std::is_floating_point_v<T> || std::is_integral_v<T> || std::is_enum_v<T>,
66
+ " NumericAttributeTraits specialization needed for this type" );
67
+
63
68
// We need to make sure we never look like we are assigning NaN to an
64
69
// integer, even in a not-reached branch. Without "if constexpr", the best
65
70
// we can do is these functions using enable_if.
66
- template <typename U = T, typename std::enable_if_t <std::is_floating_point <U>::value , int > = 0 >
71
+ template <typename U = T, typename std::enable_if_t <std::is_floating_point_v <U>, int > = 0 >
67
72
static constexpr StorageType GetNullValue ()
68
73
{
69
74
return std::numeric_limits<T>::quiet_NaN ();
70
75
}
71
76
72
- template <typename U = T, typename std::enable_if_t <std::is_integral <U>::value , int > = 0 >
77
+ template <typename U = T, typename std::enable_if_t <std::is_integral_v <U>, int > = 0 >
73
78
static constexpr StorageType GetNullValue ()
74
79
{
75
80
return std::is_signed<T>::value ? std::numeric_limits<T>::min () : std::numeric_limits<T>::max ();
76
81
}
77
82
78
- template <typename U = T, typename std::enable_if_t <std::is_enum <U>::value , int > = 0 >
83
+ template <typename U = T, typename std::enable_if_t <std::is_enum_v <U>, int > = 0 >
79
84
static constexpr StorageType GetNullValue ()
80
85
{
81
86
static_assert (!std::is_signed<std::underlying_type_t <T>>::value, " Enums must be unsigned" );
0 commit comments