diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 3acf66c54..0775ed442 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -1186,17 +1186,26 @@ other iterator can be mistaken for one. (std::basic_string is only matched for char: other character types need std::char_traits specializations that the standard library need not have.) */ -template < typename IteratorType, typename CharType, bool IsByte = sizeof(CharType) == 1 && std::is_integral::value && !std::is_same::value > +template +struct is_byte_char_type +{ + // a member, not an integral_constant argument, which astyle misformats + static constexpr bool value = sizeof(CharType) == 1 && std::is_integral::value && !std::is_same::value; +}; + +template::value> struct is_std_contiguous_byte_iterator_impl : std::false_type {}; // (the containers are only named for byte types) template struct is_std_contiguous_byte_iterator_impl - : std::integral_constant < bool, !std::is_pointer::value - && (std::is_same::iterator>::value - || std::is_same::const_iterator>::value - || std::is_same::value - || std::is_same::value) > {}; +{ + static constexpr bool value = !std::is_pointer::value + && (std::is_same::iterator>::value + || std::is_same::const_iterator>::value + || std::is_same::value + || std::is_same::value); +}; template struct is_std_contiguous_byte_iterator diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a4da8f409..4ed4bede1 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -10295,17 +10295,26 @@ other iterator can be mistaken for one. (std::basic_string is only matched for char: other character types need std::char_traits specializations that the standard library need not have.) */ -template < typename IteratorType, typename CharType, bool IsByte = sizeof(CharType) == 1 && std::is_integral::value && !std::is_same::value > +template +struct is_byte_char_type +{ + // a member, not an integral_constant argument, which astyle misformats + static constexpr bool value = sizeof(CharType) == 1 && std::is_integral::value && !std::is_same::value; +}; + +template::value> struct is_std_contiguous_byte_iterator_impl : std::false_type {}; // (the containers are only named for byte types) template struct is_std_contiguous_byte_iterator_impl - : std::integral_constant < bool, !std::is_pointer::value - && (std::is_same::iterator>::value - || std::is_same::const_iterator>::value - || std::is_same::value - || std::is_same::value) > {}; +{ + static constexpr bool value = !std::is_pointer::value + && (std::is_same::iterator>::value + || std::is_same::const_iterator>::value + || std::is_same::value + || std::is_same::value); +}; template struct is_std_contiguous_byte_iterator diff --git a/tests/src/unit-deserialization.cpp b/tests/src/unit-deserialization.cpp index ec94678c0..858597cdc 100644 --- a/tests/src/unit-deserialization.cpp +++ b/tests/src/unit-deserialization.cpp @@ -1433,6 +1433,7 @@ template std::vector bytes_as(const std::string& text) { std::vector result; + result.reserve(text.size()); for (const char c : text) { result.push_back(static_cast(c));