🚨 fixed more compiler warnings

This commit is contained in:
Niels Lohmann 2018-06-23 10:47:55 +02:00
parent 850922269d
commit 66dd1a846d
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
5 changed files with 8 additions and 12 deletions

View file

@ -247,7 +247,7 @@ void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
template<typename BasicJsonType, typename T, template<typename BasicJsonType, typename T,
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0> enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
void to_json(BasicJsonType& j, std::valarray<T> arr) void to_json(BasicJsonType& j, const std::valarray<T>& arr)
{ {
external_constructor<value_t::array>::construct(j, std::move(arr)); external_constructor<value_t::array>::construct(j, std::move(arr));
} }

View file

@ -405,11 +405,9 @@ class json_sax_dom_callback_parser : public json_sax<BasicJsonType>
bool end_object() override bool end_object() override
{ {
bool keep = true;
if (ref_stack.back()) if (ref_stack.back())
{ {
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()); if (not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
if (not keep)
{ {
// discard object // discard object
*ref_stack.back() = discarded; *ref_stack.back() = discarded;

View file

@ -1173,7 +1173,7 @@ scan_number_done:
{ {
// escape control characters // escape control characters
char cs[9]; char cs[9];
snprintf(cs, 9, "<U+%.4hhX>", c); snprintf(cs, 9, "<U+%.4hhX>", static_cast<unsigned char>(c));
result += cs; result += cs;
} }
else else

View file

@ -87,7 +87,7 @@ class primitive_iterator_t
primitive_iterator_t const operator++(int) noexcept primitive_iterator_t const operator++(int) noexcept
{ {
auto result = *this; auto result = *this;
m_it++; ++m_it;
return result; return result;
} }
@ -100,7 +100,7 @@ class primitive_iterator_t
primitive_iterator_t const operator--(int) noexcept primitive_iterator_t const operator--(int) noexcept
{ {
auto result = *this; auto result = *this;
m_it--; --m_it;
return result; return result;
} }

View file

@ -1520,7 +1520,7 @@ void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
template<typename BasicJsonType, typename T, template<typename BasicJsonType, typename T,
enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0> enable_if_t<std::is_convertible<T, BasicJsonType>::value, int> = 0>
void to_json(BasicJsonType& j, std::valarray<T> arr) void to_json(BasicJsonType& j, const std::valarray<T>& arr)
{ {
external_constructor<value_t::array>::construct(j, std::move(arr)); external_constructor<value_t::array>::construct(j, std::move(arr));
} }
@ -3165,7 +3165,7 @@ scan_number_done:
{ {
// escape control characters // escape control characters
char cs[9]; char cs[9];
snprintf(cs, 9, "<U+%.4hhX>", c); snprintf(cs, 9, "<U+%.4hhX>", static_cast<unsigned char>(c));
result += cs; result += cs;
} }
else else
@ -3746,11 +3746,9 @@ class json_sax_dom_callback_parser : public json_sax<BasicJsonType>
bool end_object() override bool end_object() override
{ {
bool keep = true;
if (ref_stack.back()) if (ref_stack.back())
{ {
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()); if (not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
if (not keep)
{ {
// discard object // discard object
*ref_stack.back() = discarded; *ref_stack.back() = discarded;