1 #include "ConstexprIf.h"
8 // Ep 18: https://www.youtube.com/watch?v=qHgM5UdzPQU
13 constexpr bool is_integral_has_a_big_max_limit()
15 if constexpr (is_integral
<T
>::value
&& !is_same
<bool, T
>::value
) // Because 'bool' is an integral type.
17 // Here we can use a '&&' to put this condition in the first 'if' because template do not use short-cirtcuit boolean operators.
18 if constexpr (numeric_limits
<T
>::max() > numeric_limits
<int>::max())
26 auto print_type_info(const T
& v
)
28 if constexpr (is_integral_has_a_big_max_limit
<T
>())
30 else if constexpr (is_floating_point
<T
>::value
)
37 void ConstexprIf::tests()
39 cout
<< print_type_info(5) << endl
;
40 cout
<< print_type_info(5LL) << endl
;
41 cout
<< print_type_info(2.3) << endl
;
42 cout
<< print_type_info("hello") << endl
;
43 cout
<< print_type_info(true) << endl
;