diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 2c22718870..58fd47c080 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -2798,11 +2798,11 @@ class binary_reader static void byte_swap(NumberType& number) { constexpr std::size_t sz = sizeof(number); - if (sz == 1) +#ifdef __cpp_lib_byteswap + if constexpr (sz == 1) { return; } -#ifdef __cpp_lib_byteswap // convert float types to int types of the same size using swap_t = std::conditional::type>::type; swap_t& number_ref = reinterpret_cast(number); diff --git a/include/nlohmann/detail/input/input_adapters.hpp b/include/nlohmann/detail/input/input_adapters.hpp index 97566dce32..fdbdc3f7be 100644 --- a/include/nlohmann/detail/input/input_adapters.hpp +++ b/include/nlohmann/detail/input/input_adapters.hpp @@ -141,7 +141,7 @@ class input_stream_adapter { is->clear(is->rdstate() | std::ios::eofbit); } - return res; + return static_cast(res); } private: @@ -179,7 +179,6 @@ class iterator_input_adapter template std::size_t get_elements(T* dest, std::size_t count = 1) { - size_t successful_read_chars = 0; auto ptr = reinterpret_cast(dest); for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index) { @@ -363,6 +362,7 @@ class wide_string_input_adapter std::size_t get_elements(T* dest, std::size_t count = 1) { JSON_THROW(other_error::create(500, "Unexpected get_elements call to wchar input adapter", nullptr)); + return 0; } private: diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 94a27aceed..dfa1d30056 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6286,7 +6286,7 @@ class input_stream_adapter { is->clear(is->rdstate() | std::ios::eofbit); } - return res; + return static_cast(res); } private: @@ -6324,7 +6324,6 @@ class iterator_input_adapter template std::size_t get_elements(T* dest, std::size_t count = 1) { - size_t successful_read_chars = 0; auto ptr = reinterpret_cast(dest); for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index) { @@ -6508,6 +6507,7 @@ class wide_string_input_adapter std::size_t get_elements(T* dest, std::size_t count = 1) { JSON_THROW(other_error::create(500, "Unexpected get_elements call to wchar input adapter", nullptr)); + return 0; } private: @@ -11989,11 +11989,11 @@ class binary_reader static void byte_swap(NumberType& number) { constexpr std::size_t sz = sizeof(number); - if (sz == 1) +#ifdef __cpp_lib_byteswap + if constexpr (sz == 1) { return; } -#ifdef __cpp_lib_byteswap // convert float types to int types of the same size using swap_t = std::conditional::type>::type; swap_t& number_ref = reinterpret_cast(number);