From 35b47c2793d1b005993d965cf7ca11d0867aae98 Mon Sep 17 00:00:00 2001 From: Thomas Braun Date: Wed, 16 Oct 2019 20:00:05 +0200 Subject: [PATCH] iteration_proxy: Fix integer truncation from std::size_t to int Bug introduced in 0f073e26 (Allow items() to be used with custom string, 2019-09-26). --- include/nlohmann/detail/iterators/iteration_proxy.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- test/src/unit-alt-string.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 8c54746f..c61d9629 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -13,7 +13,7 @@ namespace nlohmann namespace detail { template -void int_to_string( string_type& target, int value ) +void int_to_string( string_type& target, std::size_t value ) { target = std::to_string(value); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index c51f4f8b..bcbdf930 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3187,7 +3187,7 @@ namespace nlohmann namespace detail { template -void int_to_string( string_type& target, int value ) +void int_to_string( string_type& target, std::size_t value ) { target = std::to_string(value); } diff --git a/test/src/unit-alt-string.cpp b/test/src/unit-alt-string.cpp index 57ddc83a..51a88217 100644 --- a/test/src/unit-alt-string.cpp +++ b/test/src/unit-alt-string.cpp @@ -154,7 +154,7 @@ class alt_string friend bool ::operator<(const char*, const alt_string&); }; -void int_to_string( alt_string& target, int value ) +void int_to_string( alt_string& target, std::size_t value ) { target = std::to_string(value).c_str(); }