File tree Expand file tree Collapse file tree
include/boost/safe_numbers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,14 +70,13 @@ BOOST_SAFE_NUMBERS_EXPORT constexpr auto operator ""_u128(const char* str) -> u1
7070 int128::uint128_t result;
7171 const auto r {int128::detail::from_chars (str, str + int128::detail::strlen (str), result)};
7272
73- switch (r)
73+ if (r == EDOM )
7474 {
75- case EDOM :
76- BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::overflow_error, " Overflow detected in literal construction" );
77- case EINVAL :
78- BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::invalid_argument, " Invalid conversion from literal" );
79- default :
80- static_cast <void >(r);
75+ BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::overflow_error, " Overflow detected in literal construction" );
76+ }
77+ else if (r == EINVAL )
78+ {
79+ BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::invalid_argument, " Invalid conversion from literal" );
8180 }
8281
8382 return u128 {result};
@@ -128,14 +127,13 @@ BOOST_SAFE_NUMBERS_EXPORT constexpr auto operator ""_i128(const char* str) -> i1
128127 int128::int128_t result;
129128 const auto r {int128::detail::from_chars (str, str + int128::detail::strlen (str), result)};
130129
131- switch (r)
130+ if (r == EDOM )
131+ {
132+ BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::overflow_error, " Overflow detected in literal construction" );
133+ }
134+ else if (r == EINVAL )
132135 {
133- case EDOM :
134- BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::overflow_error, " Overflow detected in literal construction" );
135- case EINVAL :
136- BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::invalid_argument, " Invalid conversion from literal" );
137- default :
138- static_cast <void >(r);
136+ BOOST_SAFE_NUMBERS_THROW_EXCEPTION (std::invalid_argument, " Invalid conversion from literal" );
139137 }
140138
141139 return i128 {result};
You can’t perform that action at this time.
0 commit comments