Skip to content

Commit b25a53f

Browse files
committed
address warning
1 parent 28b08d9 commit b25a53f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/nlohmann/detail/input/binary_reader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,11 +2798,11 @@ class binary_reader
27982798
static void byte_swap(NumberType& number)
27992799
{
28002800
constexpr std::size_t sz = sizeof(number);
2801-
if (sz == 1)
2801+
#ifdef __cpp_lib_byteswap
2802+
if constexpr (sz == 1)
28022803
{
28032804
return;
28042805
}
2805-
#ifdef __cpp_lib_byteswap
28062806
// convert float types to int types of the same size
28072807
using swap_t = std::conditional<sz == 2, std::uint16_t, typename std::conditional<sz == 4, std::uint32_t, std::uint64_t>::type>::type;
28082808
swap_t& number_ref = reinterpret_cast<swap_t&>(number);

include/nlohmann/detail/input/input_adapters.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class input_stream_adapter
141141
{
142142
is->clear(is->rdstate() | std::ios::eofbit);
143143
}
144-
return res;
144+
return static_cast<std::size_t>(res);
145145
}
146146

147147
private:
@@ -179,7 +179,6 @@ class iterator_input_adapter
179179
template<class T>
180180
std::size_t get_elements(T* dest, std::size_t count = 1)
181181
{
182-
size_t successful_read_chars = 0;
183182
auto ptr = reinterpret_cast<char*>(dest);
184183
for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index)
185184
{
@@ -363,6 +362,7 @@ class wide_string_input_adapter
363362
std::size_t get_elements(T* dest, std::size_t count = 1)
364363
{
365364
JSON_THROW(other_error::create(500, "Unexpected get_elements call to wchar input adapter", nullptr));
365+
return 0;
366366
}
367367

368368
private:

single_include/nlohmann/json.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6286,7 +6286,7 @@ class input_stream_adapter
62866286
{
62876287
is->clear(is->rdstate() | std::ios::eofbit);
62886288
}
6289-
return res;
6289+
return static_cast<std::size_t>(res);
62906290
}
62916291

62926292
private:
@@ -6324,7 +6324,6 @@ class iterator_input_adapter
63246324
template<class T>
63256325
std::size_t get_elements(T* dest, std::size_t count = 1)
63266326
{
6327-
size_t successful_read_chars = 0;
63286327
auto ptr = reinterpret_cast<char*>(dest);
63296328
for (std::size_t read_index = 0; read_index < count * sizeof(T); ++read_index)
63306329
{
@@ -6508,6 +6507,7 @@ class wide_string_input_adapter
65086507
std::size_t get_elements(T* dest, std::size_t count = 1)
65096508
{
65106509
JSON_THROW(other_error::create(500, "Unexpected get_elements call to wchar input adapter", nullptr));
6510+
return 0;
65116511
}
65126512

65136513
private:
@@ -11989,11 +11989,11 @@ class binary_reader
1198911989
static void byte_swap(NumberType& number)
1199011990
{
1199111991
constexpr std::size_t sz = sizeof(number);
11992-
if (sz == 1)
11992+
#ifdef __cpp_lib_byteswap
11993+
if constexpr (sz == 1)
1199311994
{
1199411995
return;
1199511996
}
11996-
#ifdef __cpp_lib_byteswap
1199711997
// convert float types to int types of the same size
1199811998
using swap_t = std::conditional<sz == 2, std::uint16_t, typename std::conditional<sz == 4, std::uint32_t, std::uint64_t>::type>::type;
1199911999
swap_t& number_ref = reinterpret_cast<swap_t&>(number);

0 commit comments

Comments
 (0)