Commit 207a908b authored by Alexander Lapshin's avatar Alexander Lapshin

json output fix

parent df3cb2db
...@@ -30,7 +30,37 @@ template <typename T> void hangle_to_chars_error(const std::to_chars_result& res ...@@ -30,7 +30,37 @@ template <typename T> void hangle_to_chars_error(const std::to_chars_result& res
throw Exp() << "failed to convert value [" << arg << "] to string"; throw Exp() << "failed to convert value [" << arg << "] to string";
} }
template <typename T> static std::string ToStr(const int arg) static std::string ToStr(const int arg)
{
std::array<char, 32> buf;
const auto res = std::to_chars(buf.data(), buf.data() + buf.size(), arg);
if (res.ec == std::errc()) {
return std::string(buf.data(), res.ptr - buf.data());
}
hangle_to_chars_error(res, arg);
return "";
}
static std::string ToStr(const double arg)
{
std::array<char, 32> buf;
const auto res = std::to_chars(buf.data(), buf.data() + buf.size(), arg);
if (res.ec == std::errc()) {
return std::string(buf.data(), res.ptr - buf.data());
}
hangle_to_chars_error(res, arg);
return "";
}
static std::string ToStr(const long long arg)
{ {
std::array<char, 32> buf; std::array<char, 32> buf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment