9 template< typename T, std::enable_if_t< std::is_integral<T>::value,
bool > =
true >
33 template<
typename V,
typename... Dummy,
typename X = T,
34 std::enable_if_t< std::is_signed<X>::value,
bool > =
true,
35 std::enable_if_t< std::is_integral<V>::value,
bool > =
true,
36 std::enable_if_t< std::is_signed<V>::value,
bool > =
true >
39 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
40 if( v > std::numeric_limits<T>::max() )
42 if( v < std::numeric_limits<T>::min() )
44 return static_cast<T
>( v );
48 template<
typename V,
typename... Dummy,
typename X = T,
49 std::enable_if_t< std::is_unsigned<X>::value,
bool > =
true,
50 std::enable_if_t< std::is_integral<V>::value,
bool > =
true,
51 std::enable_if_t< std::is_unsigned<V>::value,
bool > =
true >
54 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
55 if( v > std::numeric_limits<T>::max() )
57 return static_cast<T
>( v );
61 template<
typename V,
typename... Dummy,
typename X = T,
62 std::enable_if_t< std::is_unsigned<X>::value,
bool > =
true,
63 std::enable_if_t< std::is_integral<V>::value,
bool > =
true,
64 std::enable_if_t< std::is_signed<V>::value,
bool > =
true >
67 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
70 if(
static_cast< typename std::make_unsigned_t<V>
>(v) > std::numeric_limits<T>::max() )
72 return static_cast<T
>( v );
76 template<
typename V,
typename... Dummy,
typename X = T,
77 std::enable_if_t< std::is_signed<X>::value,
bool > =
true,
78 std::enable_if_t< std::is_integral<V>::value,
bool > =
true,
79 std::enable_if_t< std::is_unsigned<V>::value,
bool > =
true >
82 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
83 if( v >
static_cast< typename std::make_unsigned_t<T>
>( std::numeric_limits<T>::max() ) )
85 return static_cast<T
>( v );
88 template<
typename V >
94 template<
typename V >
103 return std::numeric_limits<T>::min();
107 return std::numeric_limits<T>::max();
112 if( b.
value > 0 && a.
value > (std::numeric_limits<T>::max() - b.
value) )
114 if( b.
value < 0 && a.
value < (std::numeric_limits<T>::min() - b.
value) )
120 if( b.
value > 0 && a.
value < (std::numeric_limits<T>::min() + b.
value) )
122 if( b.
value < 0 && a.
value > (std::numeric_limits<T>::max() + b.
value) )
133 if( a.
value > (std::numeric_limits<T>::max() / b.
value) )
138 if( b.
value < (std::numeric_limits<T>::min() / a.
value) )
146 if( a.
value < (std::numeric_limits<T>::min() / b.
value) )
151 if( a.
value != 0 && b.
value < (std::numeric_limits<T>::max() / a.
value) )
160 template<
typename... Dummy,
typename X = T,
161 std::enable_if_t< std::is_signed<X>::value,
bool > =
true >
164 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
166 if( a.
value == std::numeric_limits<T>::min() && b.
value == -1 )
171 template<
typename... Dummy,
typename X = T,
172 std::enable_if_t< std::is_unsigned<X>::value,
bool > =
true >
175 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
181 template<
typename... Dummy,
typename X = T,
182 std::enable_if_t< std::is_signed<X>::value,
bool > =
true >
185 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
187 if( a.
value == std::numeric_limits<T>::min() && b.
value == -1 )
192 template<
typename... Dummy,
typename X = T,
193 std::enable_if_t< std::is_unsigned<X>::value,
bool > =
true >
196 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
202 template<
typename... Dummy,
typename X = T,
203 std::enable_if_t< std::is_signed<X>::value,
bool > =
true >
206 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );
211 template<
typename... Dummy,
typename X = T,
212 std::enable_if_t< std::is_unsigned<X>::value,
bool > =
true >
215 static_assert( 0 ==
sizeof...(Dummy),
"Unexpected template argument(s)" );