File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1313namespace boost {
1414namespace decimal {
1515
16+ namespace detail {
17+
18+ template <typename DecimalType>
19+ auto from_string_impl (const std::string& str, std::size_t * idx = nullptr )
20+ BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, DecimalType)
21+ {
22+ DecimalType val;
23+ const auto r {from_chars (str, val)};
24+
25+ if (r.ec == std::errc::result_out_of_range)
26+ {
27+ val = std::numeric_limits<DecimalType>::signaling_NaN ();
28+ BOOST_DECIMAL_THROW_EXCEPTION (std::out_of_range (" Conversion is outside the range of the type" ));
29+ }
30+ else if (r.ec != std::errc{})
31+ {
32+ val = std::numeric_limits<DecimalType>::signaling_NaN ();
33+ BOOST_DECIMAL_THROW_EXCEPTION (std::invalid_argument (" Conversion could not be performed" ));
34+ }
35+ else
36+ {
37+ if (idx != nullptr )
38+ {
39+ *idx = static_cast <std::size_t >(r.ptr - str.data ());
40+ }
41+ }
42+
43+ return val;
44+ }
45+
46+ } // namespace detail
47+
1648BOOST_DECIMAL_EXPORT template <typename DecimalType>
1749auto to_string (const DecimalType value)
1850 BOOST_DECIMAL_REQUIRES_RETURN(detail::is_decimal_floating_point_v, DecimalType, std::string)
You can’t perform that action at this time.
0 commit comments