File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
tests/std/tests/GH_005816_numeric_limits_traps Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1111#pragma warning(disable : 4984) // warning C4984: 'if constexpr' is a C++17 language extension
1212#endif // __clang__
1313
14+ template <class T >
15+ constexpr bool traps_ = std::numeric_limits<T>::traps;
16+
17+ static_assert (!traps_<bool >, " bool does not trap for a moot reason" );
18+
19+ static_assert (!traps_<float > && !traps_<double > && !traps_<long double >,
20+ " floats don't trap because even if '/fp:except' is passed, it should be enabled at runtime" );
21+
22+ static_assert (traps_<char > == traps_<int > && traps_<signed char > == traps_<int > && traps_<unsigned char > == traps_<int >
23+ && traps_<short > == traps_<int > && traps_<unsigned short > == traps_<int >
24+ && traps_<unsigned int > == traps_<int > && traps_<long > == traps_<int >
25+ && traps_<unsigned long > == traps_<int > && traps_<long long > == traps_<int >
26+ && traps_<unsigned long long > == traps_<int >,
27+ " all integers should trap or not trap equally" );
28+
1429void trap_operation () {
1530 const volatile int op1 = 1 ;
1631 const volatile int op2 = 0 ;
@@ -19,7 +34,7 @@ void trap_operation() {
1934}
2035
2136int main (int argc, char * argv[]) {
22- if constexpr (std::numeric_limits <int >::traps ) {
37+ if constexpr (traps_ <int >) {
2338 std_testing::death_test_executive exec;
2439 const std_testing::death_function_t one_trap[] = {trap_operation};
2540 exec.add_death_tests (one_trap);
You can’t perform that action at this time.
0 commit comments