31 std::size_t buffer_size = (std::numeric_limits<T>::digits10 + 2)) noexcept
32 ->
result<std::
string, std::errc>
34 std::string str(buffer_size,
'\0');
35 auto [ptr, ec] = std::to_chars(str.data(), str.data() + str.size(), value);
37 if (ec != std::errc()) {
41 str.resize(std::distance(str.data(), ptr));
64 auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), value);
66 if (ec != std::errc()) {
70 if (ptr != str.data() + str.size()) {
71 return std::errc::invalid_argument;
A class to represent the result of an operation.
Definition result.hpp:92
Definition algorithm.hpp:12
auto from_string(const std::string_view &str) noexcept -> result< T, std::errc >
Exceptionlessly convert a string to a number.
Definition charconv.hpp:61
auto to_string(const T &value, std::size_t buffer_size=(std::numeric_limits< T >::digits10+2)) noexcept -> result< std::string, std::errc >
Exceptionlessly convert a number to a string.
Definition charconv.hpp:30