Add __float128 overload

This commit is contained in:
Matt Borland
2023-06-02 10:04:03 +02:00
parent 0f07bc11e3
commit 64dc9a4eff
2 changed files with 22 additions and 0 deletions

View File

@@ -778,6 +778,11 @@ BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, double val
BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, long double value,
chars_format fmt = chars_format::general, int precision = -1 ) noexcept;
#ifdef BOOST_HAS_FLOAT128
BOOST_CHARCONV_DECL to_chars_result to_chars(char* first, char* last, __float128 value,
chars_format fmt = chars_format::general, int precision = -1 ) noexcept;
#endif
} // namespace charconv
} // namespace boost

View File

@@ -616,4 +616,21 @@ boost::charconv::to_chars_result boost::charconv::to_chars( char* first, char* l
#endif
#ifdef BOOST_HAS_FLOAT128
boost::charconv::to_chars_result to_chars(char* first, char* last, __float128 value, boost::charconv::chars_format fmt, int precision) noexcept
{
if (first > last)
{
return {last, std::errc::invalid_argument};
}
(void)fmt;
(void)precision;
const auto fd128 = boost::charconv::detail::ryu::float128_to_fd128(value);
const auto num_chars = boost::charconv::detail::ryu::generic_to_chars(fd128, first);
return { first + num_chars, std::errc() };
}
#endif