Skip to content

Commit

Permalink
Merge pull request #453 from jupp0r/fix-std-tochars
Browse files Browse the repository at this point in the history
core: Fix usage of std::to_chars
  • Loading branch information
gjasny committed Feb 5, 2021
2 parents af84494 + 5814187 commit 38130ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW) # recognize CMAKE_MSVC_RUNTIME_LIBRARY
endif()

project(prometheus-cpp VERSION 0.12.0)
project(prometheus-cpp VERSION 0.12.1)

include(GenerateExportHeader)
include(GNUInstallDirs)
Expand Down
5 changes: 4 additions & 1 deletion core/src/text_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#if __cpp_lib_to_chars >= 201611L
#include <charconv>
#include <stdexcept>
#include <system_error>
#else
#include <cstdio>
#include <limits>
Expand All @@ -30,7 +32,8 @@ void WriteValue(std::ostream& out, double value) {
auto [ptr, ec] =
std::to_chars(buffer.data(), buffer.data() + buffer.size(), value);
if (ec != std::errc()) {
throw std::runtime_error("Could not convert double to string: " + ec);
throw std::runtime_error("Could not convert double to string: " +
std::make_error_code(ec).message());
}
out.write(buffer.data(), ptr - buffer.data());
#else
Expand Down

0 comments on commit 38130ae

Please sign in to comment.