Skip to content

Commit

Permalink
address warning
Browse files Browse the repository at this point in the history
  • Loading branch information
TianyiChen committed Jun 7, 2024
1 parent 28b08d9 commit b25a53f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/nlohmann/detail/input/binary_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sz == 2, std::uint16_t, typename std::conditional<sz == 4, std::uint32_t, std::uint64_t>::type>::type;
swap_t& number_ref = reinterpret_cast<swap_t&>(number);
Expand Down
4 changes: 2 additions & 2 deletions include/nlohmann/detail/input/input_adapters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class input_stream_adapter
{
is->clear(is->rdstate() | std::ios::eofbit);
}
return res;
return static_cast<std::size_t>(res);
}

private:
Expand Down Expand Up @@ -179,7 +179,6 @@ class iterator_input_adapter
template<class T>
std::size_t get_elements(T* dest, std::size_t count = 1)
{
size_t successful_read_chars = 0;
auto ptr = reinterpret_cast<char*>(dest);
for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index)
{
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6286,7 +6286,7 @@ class input_stream_adapter
{
is->clear(is->rdstate() | std::ios::eofbit);
}
return res;
return static_cast<std::size_t>(res);
}

private:
Expand Down Expand Up @@ -6324,7 +6324,6 @@ class iterator_input_adapter
template<class T>
std::size_t get_elements(T* dest, std::size_t count = 1)
{
size_t successful_read_chars = 0;
auto ptr = reinterpret_cast<char*>(dest);
for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index)
{
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<sz == 2, std::uint16_t, typename std::conditional<sz == 4, std::uint32_t, std::uint64_t>::type>::type;
swap_t& number_ref = reinterpret_cast<swap_t&>(number);
Expand Down

0 comments on commit b25a53f

Please sign in to comment.