diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index b1e7022ab..82faf0de8 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -199,12 +199,17 @@ struct char_traits : std::char_traits using int_type = uint64_t; // Redefine to_int_type function - static int_type to_int_type(char_type c) + static int_type to_int_type(char_type c) noexcept { return static_cast(c); } - static constexpr int_type eof() + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept { return static_cast(EOF); } @@ -218,12 +223,17 @@ struct char_traits : std::char_traits using int_type = uint64_t; // Redefine to_int_type function - static int_type to_int_type(char_type c) + static int_type to_int_type(char_type c) noexcept { return static_cast(c); } - static constexpr int_type eof() + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept { return static_cast(EOF); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a930988ff..09db5f1dc 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3612,12 +3612,17 @@ struct char_traits : std::char_traits using int_type = uint64_t; // Redefine to_int_type function - static int_type to_int_type(char_type c) + static int_type to_int_type(char_type c) noexcept { return static_cast(c); } - static constexpr int_type eof() + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept { return static_cast(EOF); } @@ -3631,12 +3636,17 @@ struct char_traits : std::char_traits using int_type = uint64_t; // Redefine to_int_type function - static int_type to_int_type(char_type c) + static int_type to_int_type(char_type c) noexcept { return static_cast(c); } - static constexpr int_type eof() + static char_type to_char_type(int_type i) noexcept + { + return static_cast(i); + } + + static constexpr int_type eof() noexcept { return static_cast(EOF); }