🎨 replace alternative operators (and, not, or)

parent 4f04ea1b
...@@ -37,7 +37,7 @@ struct adl_serializer ...@@ -37,7 +37,7 @@ struct adl_serializer
@param[in,out] j JSON value to write to @param[in,out] j JSON value to write to
@param[in] val value to read from @param[in] val value to read from
*/ */
template <typename BasicJsonType, typename ValueType> template<typename BasicJsonType, typename ValueType>
static auto to_json(BasicJsonType& j, ValueType&& val) noexcept( static auto to_json(BasicJsonType& j, ValueType&& val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val)))) noexcept(::nlohmann::to_json(j, std::forward<ValueType>(val))))
-> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void()) -> decltype(::nlohmann::to_json(j, std::forward<ValueType>(val)), void())
......
...@@ -38,7 +38,7 @@ For a detailed description of the algorithm see: ...@@ -38,7 +38,7 @@ For a detailed description of the algorithm see:
namespace dtoa_impl namespace dtoa_impl
{ {
template <typename Target, typename Source> template<typename Target, typename Source>
Target reinterpret_bits(const Source source) Target reinterpret_bits(const Source source)
{ {
static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); static_assert(sizeof(Target) == sizeof(Source), "size mismatch");
...@@ -179,7 +179,7 @@ boundaries. ...@@ -179,7 +179,7 @@ boundaries.
@pre value must be finite and positive @pre value must be finite and positive
*/ */
template <typename FloatType> template<typename FloatType>
boundaries compute_boundaries(FloatType value) boundaries compute_boundaries(FloatType value)
{ {
assert(std::isfinite(value)); assert(std::isfinite(value));
...@@ -232,7 +232,7 @@ boundaries compute_boundaries(FloatType value) ...@@ -232,7 +232,7 @@ boundaries compute_boundaries(FloatType value)
// -----------------+------+------+-------------+-------------+--- (B) // -----------------+------+------+-------------+-------------+--- (B)
// v- m- v m+ v+ // v- m- v m+ v+
const bool lower_boundary_is_closer = F == 0 and E > 1; const bool lower_boundary_is_closer = F == 0 && E > 1;
const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
const diyfp m_minus = lower_boundary_is_closer const diyfp m_minus = lower_boundary_is_closer
? diyfp(4 * v.f - 1, v.e - 2) // (B) ? diyfp(4 * v.f - 1, v.e - 2) // (B)
...@@ -567,8 +567,8 @@ inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t d ...@@ -567,8 +567,8 @@ inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t d
// integer arithmetic. // integer arithmetic.
while (rest < dist while (rest < dist
and delta - rest >= ten_k && delta - rest >= ten_k
and (rest + ten_k < dist or dist - rest > rest + ten_k - dist)) && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
{ {
assert(buf[len - 1] != '0'); assert(buf[len - 1] != '0');
buf[len - 1]--; buf[len - 1]--;
...@@ -879,7 +879,7 @@ v = buf * 10^decimal_exponent ...@@ -879,7 +879,7 @@ v = buf * 10^decimal_exponent
len is the length of the buffer (number of decimal digits) len is the length of the buffer (number of decimal digits)
The buffer must be large enough, i.e. >= max_digits10. The buffer must be large enough, i.e. >= max_digits10.
*/ */
template <typename FloatType> template<typename FloatType>
JSON_HEDLEY_NON_NULL(1) JSON_HEDLEY_NON_NULL(1)
void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value)
{ {
...@@ -986,7 +986,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, ...@@ -986,7 +986,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
// k is the length of the buffer (number of decimal digits) // k is the length of the buffer (number of decimal digits)
// n is the position of the decimal point relative to the start of the buffer. // n is the position of the decimal point relative to the start of the buffer.
if (k <= n and n <= max_exp) if (k <= n && n <= max_exp)
{ {
// digits[000] // digits[000]
// len <= max_exp + 2 // len <= max_exp + 2
...@@ -998,7 +998,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, ...@@ -998,7 +998,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
return buf + (static_cast<size_t>(n) + 2); return buf + (static_cast<size_t>(n) + 2);
} }
if (0 < n and n <= max_exp) if (0 < n && n <= max_exp)
{ {
// dig.its // dig.its
// len <= max_digits10 + 1 // len <= max_digits10 + 1
...@@ -1010,7 +1010,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent, ...@@ -1010,7 +1010,7 @@ inline char* format_buffer(char* buf, int len, int decimal_exponent,
return buf + (static_cast<size_t>(k) + 1U); return buf + (static_cast<size_t>(k) + 1U);
} }
if (min_exp < n and n <= 0) if (min_exp < n && n <= 0)
{ {
// 0.[000]digits // 0.[000]digits
// len <= 2 + (-min_exp - 1) + max_digits10 // len <= 2 + (-min_exp - 1) + max_digits10
...@@ -1055,7 +1055,7 @@ format. Returns an iterator pointing past-the-end of the decimal representation. ...@@ -1055,7 +1055,7 @@ format. Returns an iterator pointing past-the-end of the decimal representation.
@note The buffer must be large enough. @note The buffer must be large enough.
@note The result is NOT null-terminated. @note The result is NOT null-terminated.
*/ */
template <typename FloatType> template<typename FloatType>
JSON_HEDLEY_NON_NULL(1, 2) JSON_HEDLEY_NON_NULL(1, 2)
JSON_HEDLEY_RETURNS_NON_NULL JSON_HEDLEY_RETURNS_NON_NULL
char* to_chars(char* first, const char* last, FloatType value) char* to_chars(char* first, const char* last, FloatType value)
......
...@@ -56,9 +56,9 @@ struct external_constructor<value_t::string> ...@@ -56,9 +56,9 @@ struct external_constructor<value_t::string>
j.assert_invariant(); j.assert_invariant();
} }
template<typename BasicJsonType, typename CompatibleStringType, template < typename BasicJsonType, typename CompatibleStringType,
enable_if_t<not std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value, enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
int> = 0> int > = 0 >
static void construct(BasicJsonType& j, const CompatibleStringType& str) static void construct(BasicJsonType& j, const CompatibleStringType& str)
{ {
j.m_type = value_t::string; j.m_type = value_t::string;
...@@ -144,9 +144,9 @@ struct external_constructor<value_t::array> ...@@ -144,9 +144,9 @@ struct external_constructor<value_t::array>
j.assert_invariant(); j.assert_invariant();
} }
template<typename BasicJsonType, typename CompatibleArrayType, template < typename BasicJsonType, typename CompatibleArrayType,
enable_if_t<not std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value, enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
int> = 0> int > = 0 >
static void construct(BasicJsonType& j, const CompatibleArrayType& arr) static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
{ {
using std::begin; using std::begin;
...@@ -203,8 +203,8 @@ struct external_constructor<value_t::object> ...@@ -203,8 +203,8 @@ struct external_constructor<value_t::object>
j.assert_invariant(); j.assert_invariant();
} }
template<typename BasicJsonType, typename CompatibleObjectType, template < typename BasicJsonType, typename CompatibleObjectType,
enable_if_t<not std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int> = 0> enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int > = 0 >
static void construct(BasicJsonType& j, const CompatibleObjectType& obj) static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
{ {
using std::begin; using std::begin;
...@@ -275,20 +275,20 @@ void to_json(BasicJsonType& j, const std::vector<bool>& e) ...@@ -275,20 +275,20 @@ void to_json(BasicJsonType& j, const std::vector<bool>& e)
external_constructor<value_t::array>::construct(j, e); external_constructor<value_t::array>::construct(j, e);
} }
template <typename BasicJsonType, typename CompatibleArrayType, template < typename BasicJsonType, typename CompatibleArrayType,
enable_if_t<is_compatible_array_type<BasicJsonType, enable_if_t < is_compatible_array_type<BasicJsonType,
CompatibleArrayType>::value and CompatibleArrayType>::value&&
not is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value and !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
not is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value and !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value&&
not std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value and !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
not is_basic_json<CompatibleArrayType>::value, !is_basic_json<CompatibleArrayType>::value,
int> = 0> int > = 0 >
void to_json(BasicJsonType& j, const CompatibleArrayType& arr) void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
{ {
external_constructor<value_t::array>::construct(j, arr); external_constructor<value_t::array>::construct(j, arr);
} }
template <typename BasicJsonType> template<typename BasicJsonType>
void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin)
{ {
external_constructor<value_t::binary>::construct(j, bin); external_constructor<value_t::binary>::construct(j, bin);
...@@ -307,8 +307,8 @@ void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) ...@@ -307,8 +307,8 @@ void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
external_constructor<value_t::array>::construct(j, std::move(arr)); external_constructor<value_t::array>::construct(j, std::move(arr));
} }
template<typename BasicJsonType, typename CompatibleObjectType, template < typename BasicJsonType, typename CompatibleObjectType,
enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value and not is_basic_json<CompatibleObjectType>::value, int> = 0> enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value, int > = 0 >
void to_json(BasicJsonType& j, const CompatibleObjectType& obj) void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
{ {
external_constructor<value_t::object>::construct(j, obj); external_constructor<value_t::object>::construct(j, obj);
...@@ -322,9 +322,9 @@ void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) ...@@ -322,9 +322,9 @@ void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
template < template <
typename BasicJsonType, typename T, std::size_t N, typename BasicJsonType, typename T, std::size_t N,
enable_if_t<not std::is_constructible<typename BasicJsonType::string_t, enable_if_t < !std::is_constructible<typename BasicJsonType::string_t,
const T(&)[N]>::value, const T(&)[N]>::value,
int> = 0 > int > = 0 >
void to_json(BasicJsonType& j, const T(&arr)[N]) void to_json(BasicJsonType& j, const T(&arr)[N])
{ {
external_constructor<value_t::array>::construct(j, arr); external_constructor<value_t::array>::construct(j, arr);
...@@ -337,8 +337,8 @@ void to_json(BasicJsonType& j, const std::pair<T1, T2>& p) ...@@ -337,8 +337,8 @@ void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
} }
// for https://github.com/nlohmann/json/pull/1134 // for https://github.com/nlohmann/json/pull/1134
template < typename BasicJsonType, typename T, template<typename BasicJsonType, typename T,
enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0> enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>::value, int> = 0>
void to_json(BasicJsonType& j, const T& b) void to_json(BasicJsonType& j, const T& b)
{ {
j = { {b.key(), b.value()} }; j = { {b.key(), b.value()} };
......
...@@ -131,7 +131,7 @@ class input_buffer_adapter ...@@ -131,7 +131,7 @@ class input_buffer_adapter
{ {
if (JSON_HEDLEY_LIKELY(cursor < limit)) if (JSON_HEDLEY_LIKELY(cursor < limit))
{ {
assert(cursor != nullptr and limit != nullptr); assert(cursor != nullptr && limit != nullptr);
return std::char_traits<char>::to_int_type(*(cursor++)); return std::char_traits<char>::to_int_type(*(cursor++));
} }
...@@ -238,7 +238,7 @@ struct wide_string_input_helper<WideStringType, 2> ...@@ -238,7 +238,7 @@ struct wide_string_input_helper<WideStringType, 2>
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
utf8_bytes_filled = 2; utf8_bytes_filled = 2;
} }
else if (0xD800 > wc or wc >= 0xE000) else if (0xD800 > wc || wc >= 0xE000)
{ {
utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u))); utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u)));
utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu)); utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
...@@ -331,24 +331,24 @@ inline input_stream_adapter input_adapter(std::istream&& stream) ...@@ -331,24 +331,24 @@ inline input_stream_adapter input_adapter(std::istream&& stream)
return input_stream_adapter(stream); return input_stream_adapter(stream);
} }
template<typename CharT, typename SizeT, template < typename CharT, typename SizeT,
typename std::enable_if< typename std::enable_if <
std::is_pointer<CharT>::value and std::is_pointer<CharT>::value&&
std::is_integral<typename std::remove_pointer<CharT>::type>::value and std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
not std::is_same<SizeT, bool>::value and !std::is_same<SizeT, bool>::value&&
sizeof(typename std::remove_pointer<CharT>::type) == 1, sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0> int >::type = 0 >
input_buffer_adapter input_adapter(CharT b, SizeT l) input_buffer_adapter input_adapter(CharT b, SizeT l)
{ {
return input_buffer_adapter(reinterpret_cast<const char*>(b), l); return input_buffer_adapter(reinterpret_cast<const char*>(b), l);
} }
template<typename CharT, template < typename CharT,
typename std::enable_if< typename std::enable_if <
std::is_pointer<CharT>::value and std::is_pointer<CharT>::value&&
std::is_integral<typename std::remove_pointer<CharT>::type>::value and std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
sizeof(typename std::remove_pointer<CharT>::type) == 1, sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0> int >::type = 0 >
input_buffer_adapter input_adapter(CharT b) input_buffer_adapter input_adapter(CharT b)
{ {
return input_adapter(reinterpret_cast<const char*>(b), return input_adapter(reinterpret_cast<const char*>(b),
...@@ -408,10 +408,10 @@ inline wide_string_input_adapter<std::u32string> input_adapter(const std::u32str ...@@ -408,10 +408,10 @@ inline wide_string_input_adapter<std::u32string> input_adapter(const std::u32str
return wide_string_input_adapter<std::u32string>(ws); return wide_string_input_adapter<std::u32string>(ws);
} }
template<class ContiguousContainer, typename template < class ContiguousContainer, typename
std::enable_if<not std::is_pointer<ContiguousContainer>::value and std::enable_if < !std::is_pointer<ContiguousContainer>::value&&
std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value, std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
int>::type = 0> int >::type = 0 >
input_buffer_adapter input_adapter(const ContiguousContainer& c) input_buffer_adapter input_adapter(const ContiguousContainer& c)
{ {
return input_adapter(std::begin(c), std::end(c)); return input_adapter(std::begin(c), std::end(c));
...@@ -430,21 +430,21 @@ input_buffer_adapter input_adapter(T (&array)[N]) ...@@ -430,21 +430,21 @@ input_buffer_adapter input_adapter(T (&array)[N])
class span_input_adapter class span_input_adapter
{ {
public: public:
template<typename CharT, template < typename CharT,
typename std::enable_if< typename std::enable_if <
std::is_pointer<CharT>::value and std::is_pointer<CharT>::value&&
std::is_integral<typename std::remove_pointer<CharT>::type>::value and std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
sizeof(typename std::remove_pointer<CharT>::type) == 1, sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0> int >::type = 0 >
span_input_adapter(CharT b, std::size_t l) span_input_adapter(CharT b, std::size_t l)
: ia(reinterpret_cast<const char*>(b), l) {} : ia(reinterpret_cast<const char*>(b), l) {}
template<typename CharT, template < typename CharT,
typename std::enable_if< typename std::enable_if <
std::is_pointer<CharT>::value and std::is_pointer<CharT>::value&&
std::is_integral<typename std::remove_pointer<CharT>::type>::value and std::is_integral<typename std::remove_pointer<CharT>::type>::value&&
sizeof(typename std::remove_pointer<CharT>::type) == 1, sizeof(typename std::remove_pointer<CharT>::type) == 1,
int>::type = 0> int >::type = 0 >
span_input_adapter(CharT b) span_input_adapter(CharT b)
: span_input_adapter(reinterpret_cast<const char*>(b), : span_input_adapter(reinterpret_cast<const char*>(b),
std::strlen(reinterpret_cast<const char*>(b))) {} std::strlen(reinterpret_cast<const char*>(b))) {}
...@@ -461,10 +461,10 @@ class span_input_adapter ...@@ -461,10 +461,10 @@ class span_input_adapter
: span_input_adapter(std::begin(array), std::end(array)) {} : span_input_adapter(std::begin(array), std::end(array)) {}
/// input adapter for contiguous container /// input adapter for contiguous container
template<class ContiguousContainer, typename template < class ContiguousContainer, typename
std::enable_if<not std::is_pointer<ContiguousContainer>::value and std::enable_if < !std::is_pointer<ContiguousContainer>::value&&
std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value, std::is_base_of<std::random_access_iterator_tag, typename iterator_traits<decltype(std::begin(std::declval<ContiguousContainer const>()))>::iterator_category>::value,
int>::type = 0> int >::type = 0 >
span_input_adapter(const ContiguousContainer& c) span_input_adapter(const ContiguousContainer& c)
: span_input_adapter(std::begin(c), std::end(c)) {} : span_input_adapter(std::begin(c), std::end(c)) {}
......
...@@ -218,7 +218,7 @@ class json_sax_dom_parser ...@@ -218,7 +218,7 @@ class json_sax_dom_parser
{ {
ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
{ {
JSON_THROW(out_of_range::create(408, JSON_THROW(out_of_range::create(408,
"excessive object size: " + std::to_string(len))); "excessive object size: " + std::to_string(len)));
...@@ -244,7 +244,7 @@ class json_sax_dom_parser ...@@ -244,7 +244,7 @@ class json_sax_dom_parser
{ {
ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
{ {
JSON_THROW(out_of_range::create(408, JSON_THROW(out_of_range::create(408,
"excessive array size: " + std::to_string(len))); "excessive array size: " + std::to_string(len)));
...@@ -309,7 +309,7 @@ class json_sax_dom_parser ...@@ -309,7 +309,7 @@ class json_sax_dom_parser
return &root; return &root;
} }
assert(ref_stack.back()->is_array() or ref_stack.back()->is_object()); assert(ref_stack.back()->is_array() || ref_stack.back()->is_object());
if (ref_stack.back()->is_array()) if (ref_stack.back()->is_array())
{ {
...@@ -414,7 +414,7 @@ class json_sax_dom_callback_parser ...@@ -414,7 +414,7 @@ class json_sax_dom_callback_parser
ref_stack.push_back(val.second); ref_stack.push_back(val.second);
// check object limit // check object limit
if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
{ {
JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len))); JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len)));
} }
...@@ -431,7 +431,7 @@ class json_sax_dom_callback_parser ...@@ -431,7 +431,7 @@ class json_sax_dom_callback_parser
key_keep_stack.push_back(keep); key_keep_stack.push_back(keep);
// add discarded value at given key and store the reference for later // add discarded value at given key and store the reference for later
if (keep and ref_stack.back()) if (keep && ref_stack.back())
{ {
object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded); object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded);
} }
...@@ -441,18 +441,18 @@ class json_sax_dom_callback_parser ...@@ -441,18 +441,18 @@ class json_sax_dom_callback_parser
bool end_object() bool end_object()
{ {
if (ref_stack.back() and not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) if (ref_stack.back() && !callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
{ {
// discard object // discard object
*ref_stack.back() = discarded; *ref_stack.back() = discarded;
} }
assert(not ref_stack.empty()); assert(!ref_stack.empty());
assert(not keep_stack.empty()); assert(!keep_stack.empty());
ref_stack.pop_back(); ref_stack.pop_back();
keep_stack.pop_back(); keep_stack.pop_back();
if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_structured()) if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
{ {
// remove discarded value // remove discarded value
for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
...@@ -477,7 +477,7 @@ class json_sax_dom_callback_parser ...@@ -477,7 +477,7 @@ class json_sax_dom_callback_parser
ref_stack.push_back(val.second); ref_stack.push_back(val.second);
// check array limit // check array limit
if (ref_stack.back() and JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size())) if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size()))
{ {
JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len))); JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len)));
} }
...@@ -492,20 +492,20 @@ class json_sax_dom_callback_parser ...@@ -492,20 +492,20 @@ class json_sax_dom_callback_parser
if (ref_stack.back()) if (ref_stack.back())
{ {
keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); keep = callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
if (not keep) if (!keep)
{ {
// discard array // discard array
*ref_stack.back() = discarded; *ref_stack.back() = discarded;
} }
} }
assert(not ref_stack.empty()); assert(!ref_stack.empty());
assert(not keep_stack.empty()); assert(!keep_stack.empty());
ref_stack.pop_back(); ref_stack.pop_back();
keep_stack.pop_back(); keep_stack.pop_back();
// remove discarded value // remove discarded value
if (not keep and not ref_stack.empty() and ref_stack.back()->is_array()) if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
{ {
ref_stack.back()->m_value.array->pop_back(); ref_stack.back()->m_value.array->pop_back();
} }
...@@ -565,11 +565,11 @@ class json_sax_dom_callback_parser ...@@ -565,11 +565,11 @@ class json_sax_dom_callback_parser
template<typename Value> template<typename Value>
std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false) std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool skip_callback = false)
{ {
assert(not keep_stack.empty()); assert(!keep_stack.empty());
// do not handle this value if we know it would be added to a discarded // do not handle this value if we know it would be added to a discarded
// container // container
if (not keep_stack.back()) if (!keep_stack.back())
{ {
return {false, nullptr}; return {false, nullptr};
} }
...@@ -578,10 +578,10 @@ class json_sax_dom_callback_parser ...@@ -578,10 +578,10 @@ class json_sax_dom_callback_parser
auto value = BasicJsonType(std::forward<Value>(v)); auto value = BasicJsonType(std::forward<Value>(v));
// check callback // check callback
const bool keep = skip_callback or callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value); const bool keep = skip_callback || callback(static_cast<int>(ref_stack.size()), parse_event_t::value, value);
// do not handle this value if we just learnt it shall be discarded // do not handle this value if we just learnt it shall be discarded
if (not keep) if (!keep)
{ {
return {false, nullptr}; return {false, nullptr};
} }
...@@ -594,13 +594,13 @@ class json_sax_dom_callback_parser ...@@ -594,13 +594,13 @@ class json_sax_dom_callback_parser
// skip this value if we already decided to skip the parent // skip this value if we already decided to skip the parent
// (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360)
if (not ref_stack.back()) if (!ref_stack.back())
{ {
return {false, nullptr}; return {false, nullptr};
} }
// we now only expect arrays and objects // we now only expect arrays and objects
assert(ref_stack.back()->is_array() or ref_stack.back()->is_object()); assert(ref_stack.back()->is_array() || ref_stack.back()->is_object());
// array // array
if (ref_stack.back()->is_array()) if (ref_stack.back()->is_array())
...@@ -612,11 +612,11 @@ class json_sax_dom_callback_parser ...@@ -612,11 +612,11 @@ class json_sax_dom_callback_parser
// object // object
assert(ref_stack.back()->is_object()); assert(ref_stack.back()->is_object());
// check if we should store an element for the current key // check if we should store an element for the current key
assert(not key_keep_stack.empty()); assert(!key_keep_stack.empty());
const bool store_element = key_keep_stack.back(); const bool store_element = key_keep_stack.back();
key_keep_stack.pop_back(); key_keep_stack.pop_back();
if (not store_element) if (!store_element)
{ {
return {false, nullptr}; return {false, nullptr};
} }
......
...@@ -164,15 +164,15 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -164,15 +164,15 @@ class lexer : public lexer_base<BasicJsonType>
{ {
get(); get();
if (current >= '0' and current <= '9') if (current >= '0' && current <= '9')
{ {
codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor); codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x30u) << factor);
} }
else if (current >= 'A' and current <= 'F') else if (current >= 'A' && current <= 'F')
{ {
codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor); codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x37u) << factor);
} }
else if (current >= 'a' and current <= 'f') else if (current >= 'a' && current <= 'f')
{ {
codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor); codepoint += static_cast<int>((static_cast<unsigned int>(current) - 0x57u) << factor);
} }
...@@ -182,7 +182,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -182,7 +182,7 @@ class lexer : public lexer_base<BasicJsonType>
} }
} }
assert(0x0000 <= codepoint and codepoint <= 0xFFFF); assert(0x0000 <= codepoint && codepoint <= 0xFFFF);
return codepoint; return codepoint;
} }
...@@ -203,13 +203,13 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -203,13 +203,13 @@ class lexer : public lexer_base<BasicJsonType>
*/ */
bool next_byte_in_range(std::initializer_list<int> ranges) bool next_byte_in_range(std::initializer_list<int> ranges)
{ {
assert(ranges.size() == 2 or ranges.size() == 4 or ranges.size() == 6); assert(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
add(current); add(current);
for (auto range = ranges.begin(); range != ranges.end(); ++range) for (auto range = ranges.begin(); range != ranges.end(); ++range)
{ {
get(); get();
if (JSON_HEDLEY_LIKELY(*range <= current and current <= *(++range))) if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range)))
{ {
add(current); add(current);
} }
...@@ -315,10 +315,10 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -315,10 +315,10 @@ class lexer : public lexer_base<BasicJsonType>
} }
// check if code point is a high surrogate // check if code point is a high surrogate
if (0xD800 <= codepoint1 and codepoint1 <= 0xDBFF) if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
{ {
// expect next \uxxxx entry // expect next \uxxxx entry
if (JSON_HEDLEY_LIKELY(get() == '\\' and get() == 'u')) if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u'))
{ {
const int codepoint2 = get_codepoint(); const int codepoint2 = get_codepoint();
...@@ -329,7 +329,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -329,7 +329,7 @@ class lexer : public lexer_base<BasicJsonType>
} }
// check if codepoint2 is a low surrogate // check if codepoint2 is a low surrogate
if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 and codepoint2 <= 0xDFFF)) if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF))
{ {
// overwrite codepoint // overwrite codepoint
codepoint = static_cast<int>( codepoint = static_cast<int>(
...@@ -356,7 +356,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -356,7 +356,7 @@ class lexer : public lexer_base<BasicJsonType>
} }
else else
{ {
if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 and codepoint1 <= 0xDFFF)) if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF))
{ {
error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
return token_type::parse_error; return token_type::parse_error;
...@@ -364,7 +364,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -364,7 +364,7 @@ class lexer : public lexer_base<BasicJsonType>
} }
// result of the above calculation yields a proper codepoint // result of the above calculation yields a proper codepoint
assert(0x00 <= codepoint and codepoint <= 0x10FFFF); assert(0x00 <= codepoint && codepoint <= 0x10FFFF);
// translate codepoint into bytes // translate codepoint into bytes
if (codepoint < 0x80) if (codepoint < 0x80)
...@@ -731,7 +731,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -731,7 +731,7 @@ class lexer : public lexer_base<BasicJsonType>
case 0xDE: case 0xDE:
case 0xDF: case 0xDF:
{ {
if (JSON_HEDLEY_UNLIKELY(not next_byte_in_range({0x80, 0xBF}))) if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF})))
{ {
return token_type::parse_error; return token_type::parse_error;
} }
...@@ -741,7 +741,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -741,7 +741,7 @@ class lexer : public lexer_base<BasicJsonType>
// U+0800..U+0FFF: bytes E0 A0..BF 80..BF // U+0800..U+0FFF: bytes E0 A0..BF 80..BF
case 0xE0: case 0xE0:
{ {
if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF}))))
{ {
return token_type::parse_error; return token_type::parse_error;
} }
...@@ -765,7 +765,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -765,7 +765,7 @@ class lexer : public lexer_base<BasicJsonType>
case 0xEE: case 0xEE:
case 0xEF: case 0xEF:
{ {
if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF}))))
{ {
return token_type::parse_error; return token_type::parse_error;
} }
...@@ -775,7 +775,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -775,7 +775,7 @@ class lexer : public lexer_base<BasicJsonType>
// U+D000..U+D7FF: bytes ED 80..9F 80..BF // U+D000..U+D7FF: bytes ED 80..9F 80..BF
case 0xED: case 0xED:
{ {
if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF}))))
{ {
return token_type::parse_error; return token_type::parse_error;
} }
...@@ -785,7 +785,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -785,7 +785,7 @@ class lexer : public lexer_base<BasicJsonType>
// U+10000..U+3FFFF F0 90..BF 80..BF 80..BF // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF
case 0xF0: case 0xF0:
{ {
if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
{ {
return token_type::parse_error; return token_type::parse_error;
} }
...@@ -797,7 +797,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -797,7 +797,7 @@ class lexer : public lexer_base<BasicJsonType>
case 0xF2: case 0xF2:
case 0xF3: case 0xF3:
{ {
if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF}))))
{ {
return token_type::parse_error; return token_type::parse_error;
} }
...@@ -807,7 +807,7 @@ class lexer : public lexer_base<BasicJsonType> ...@@ -807,7 +807,7 @@ class lexer : public lexer_base<BasicJsonType>
// U+100000..U+10FFFF F4 80..8F 80..BF 80..BF // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF
case 0xF4: case 0xF4:
{ {
if (JSON_HEDLEY_UNLIKELY(not (next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF}))))
{ {
return token_type::parse_error; return token_type::parse_error;
} }
...@@ -1308,7 +1308,7 @@ scan_number_done: ...@@ -1308,7 +1308,7 @@ scan_number_done:
if (JSON_HEDLEY_LIKELY(current != std::char_traits<char>::eof())) if (JSON_HEDLEY_LIKELY(current != std::char_traits<char>::eof()))
{ {
assert(not token_string.empty()); assert(!token_string.empty());
token_string.pop_back(); token_string.pop_back();
} }
} }
...@@ -1404,7 +1404,7 @@ scan_number_done: ...@@ -1404,7 +1404,7 @@ scan_number_done:
if (get() == 0xEF) if (get() == 0xEF)
{ {
// check if we completely parse the BOM // check if we completely parse the BOM
return get() == 0xBB and get() == 0xBF; return get() == 0xBB && get() == 0xBF;
} }
// the first character is not the beginning of the BOM; unget it to // the first character is not the beginning of the BOM; unget it to
...@@ -1416,7 +1416,7 @@ scan_number_done: ...@@ -1416,7 +1416,7 @@ scan_number_done:
token_type scan() token_type scan()
{ {
// initially, skip the BOM // initially, skip the BOM
if (position.chars_read_total == 0 and not skip_bom()) if (position.chars_read_total == 0 && !skip_bom())
{ {
error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given";
return token_type::parse_error; return token_type::parse_error;
...@@ -1427,7 +1427,7 @@ scan_number_done: ...@@ -1427,7 +1427,7 @@ scan_number_done:
{ {
get(); get();
} }
while (current == ' ' or current == '\t' or current == '\n' or current == '\r'); while (current == ' ' || current == '\t' || current == '\n' || current == '\r');
switch (current) switch (current)
{ {
......
...@@ -89,7 +89,7 @@ class parser ...@@ -89,7 +89,7 @@ class parser
result.assert_invariant(); result.assert_invariant();
// in strict mode, input must be completely read // in strict mode, input must be completely read
if (strict and (get_token() != token_type::end_of_input)) if (strict && (get_token() != token_type::end_of_input))
{ {
sdp.parse_error(m_lexer.get_position(), sdp.parse_error(m_lexer.get_position(),
m_lexer.get_token_string(), m_lexer.get_token_string(),
...@@ -118,7 +118,7 @@ class parser ...@@ -118,7 +118,7 @@ class parser
result.assert_invariant(); result.assert_invariant();
// in strict mode, input must be completely read // in strict mode, input must be completely read
if (strict and (get_token() != token_type::end_of_input)) if (strict && (get_token() != token_type::end_of_input))
{ {
sdp.parse_error(m_lexer.get_position(), sdp.parse_error(m_lexer.get_position(),
m_lexer.get_token_string(), m_lexer.get_token_string(),
...@@ -147,7 +147,7 @@ class parser ...@@ -147,7 +147,7 @@ class parser
return sax_parse(&sax_acceptor, strict); return sax_parse(&sax_acceptor, strict);
} }
template <typename SAX> template<typename SAX>
JSON_HEDLEY_NON_NULL(2) JSON_HEDLEY_NON_NULL(2)
bool sax_parse(SAX* sax, const bool strict = true) bool sax_parse(SAX* sax, const bool strict = true)
{ {
...@@ -155,7 +155,7 @@ class parser ...@@ -155,7 +155,7 @@ class parser
const bool result = sax_parse_internal(sax); const bool result = sax_parse_internal(sax);
// strict mode: next byte must be EOF // strict mode: next byte must be EOF
if (result and strict and (get_token() != token_type::end_of_input)) if (result && strict && (get_token() != token_type::end_of_input))
{ {
return sax->parse_error(m_lexer.get_position(), return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(), m_lexer.get_token_string(),
...@@ -167,7 +167,7 @@ class parser ...@@ -167,7 +167,7 @@ class parser
} }
private: private:
template <typename SAX> template<typename SAX>
JSON_HEDLEY_NON_NULL(2) JSON_HEDLEY_NON_NULL(2)
bool sax_parse_internal(SAX* sax) bool sax_parse_internal(SAX* sax)
{ {
...@@ -179,14 +179,14 @@ class parser ...@@ -179,14 +179,14 @@ class parser
while (true) while (true)
{ {
if (not skip_to_state_evaluation) if (!skip_to_state_evaluation)
{ {
// invariant: get_token() was called before each iteration // invariant: get_token() was called before each iteration
switch (last_token) switch (last_token)
{ {
case token_type::begin_object: case token_type::begin_object:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1)))) if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
{ {
return false; return false;
} }
...@@ -194,7 +194,7 @@ class parser ...@@ -194,7 +194,7 @@ class parser
// closing } -> we are done // closing } -> we are done
if (get_token() == token_type::end_object) if (get_token() == token_type::end_object)
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
{ {
return false; return false;
} }
...@@ -209,7 +209,7 @@ class parser ...@@ -209,7 +209,7 @@ class parser
parse_error::create(101, m_lexer.get_position(), parse_error::create(101, m_lexer.get_position(),
exception_message(token_type::value_string, "object key"))); exception_message(token_type::value_string, "object key")));
} }
if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
{ {
return false; return false;
} }
...@@ -233,7 +233,7 @@ class parser ...@@ -233,7 +233,7 @@ class parser
case token_type::begin_array: case token_type::begin_array:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1)))) if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
{ {
return false; return false;
} }
...@@ -241,7 +241,7 @@ class parser ...@@ -241,7 +241,7 @@ class parser
// closing ] -> we are done // closing ] -> we are done
if (get_token() == token_type::end_array) if (get_token() == token_type::end_array)
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
{ {
return false; return false;
} }
...@@ -259,14 +259,14 @@ class parser ...@@ -259,14 +259,14 @@ class parser
{ {
const auto res = m_lexer.get_number_float(); const auto res = m_lexer.get_number_float();
if (JSON_HEDLEY_UNLIKELY(not std::isfinite(res))) if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res)))
{ {
return sax->parse_error(m_lexer.get_position(), return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(), m_lexer.get_token_string(),
out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'")); out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'"));
} }
if (JSON_HEDLEY_UNLIKELY(not sax->number_float(res, m_lexer.get_string()))) if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string())))
{ {
return false; return false;
} }
...@@ -276,7 +276,7 @@ class parser ...@@ -276,7 +276,7 @@ class parser
case token_type::literal_false: case token_type::literal_false:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->boolean(false))) if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false)))
{ {
return false; return false;
} }
...@@ -285,7 +285,7 @@ class parser ...@@ -285,7 +285,7 @@ class parser
case token_type::literal_null: case token_type::literal_null:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->null())) if (JSON_HEDLEY_UNLIKELY(!sax->null()))
{ {
return false; return false;
} }
...@@ -294,7 +294,7 @@ class parser ...@@ -294,7 +294,7 @@ class parser
case token_type::literal_true: case token_type::literal_true:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->boolean(true))) if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true)))
{ {
return false; return false;
} }
...@@ -303,7 +303,7 @@ class parser ...@@ -303,7 +303,7 @@ class parser
case token_type::value_integer: case token_type::value_integer:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->number_integer(m_lexer.get_number_integer()))) if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer())))
{ {
return false; return false;
} }
...@@ -312,7 +312,7 @@ class parser ...@@ -312,7 +312,7 @@ class parser
case token_type::value_string: case token_type::value_string:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->string(m_lexer.get_string()))) if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string())))
{ {
return false; return false;
} }
...@@ -321,7 +321,7 @@ class parser ...@@ -321,7 +321,7 @@ class parser
case token_type::value_unsigned: case token_type::value_unsigned:
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->number_unsigned(m_lexer.get_number_unsigned()))) if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned())))
{ {
return false; return false;
} }
...@@ -371,7 +371,7 @@ class parser ...@@ -371,7 +371,7 @@ class parser
// closing ] // closing ]
if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array))
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->end_array())) if (JSON_HEDLEY_UNLIKELY(!sax->end_array()))
{ {
return false; return false;
} }
...@@ -380,7 +380,7 @@ class parser ...@@ -380,7 +380,7 @@ class parser
// new value, we need to evaluate the new state first. // new value, we need to evaluate the new state first.
// By setting skip_to_state_evaluation to false, we // By setting skip_to_state_evaluation to false, we
// are effectively jumping to the beginning of this if. // are effectively jumping to the beginning of this if.
assert(not states.empty()); assert(!states.empty());
states.pop_back(); states.pop_back();
skip_to_state_evaluation = true; skip_to_state_evaluation = true;
continue; continue;
...@@ -405,7 +405,7 @@ class parser ...@@ -405,7 +405,7 @@ class parser
exception_message(token_type::value_string, "object key"))); exception_message(token_type::value_string, "object key")));
} }
if (JSON_HEDLEY_UNLIKELY(not sax->key(m_lexer.get_string()))) if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string())))
{ {
return false; return false;
} }
...@@ -427,7 +427,7 @@ class parser ...@@ -427,7 +427,7 @@ class parser
// closing } // closing }
if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object))
{ {
if (JSON_HEDLEY_UNLIKELY(not sax->end_object())) if (JSON_HEDLEY_UNLIKELY(!sax->end_object()))
{ {
return false; return false;
} }
...@@ -436,7 +436,7 @@ class parser ...@@ -436,7 +436,7 @@ class parser
// new value, we need to evaluate the new state first. // new value, we need to evaluate the new state first.
// By setting skip_to_state_evaluation to false, we // By setting skip_to_state_evaluation to false, we
// are effectively jumping to the beginning of this if. // are effectively jumping to the beginning of this if.
assert(not states.empty()); assert(!states.empty());
states.pop_back(); states.pop_back();
skip_to_state_evaluation = true; skip_to_state_evaluation = true;
continue; continue;
...@@ -460,7 +460,7 @@ class parser ...@@ -460,7 +460,7 @@ class parser
{ {
std::string error_msg = "syntax error "; std::string error_msg = "syntax error ";
if (not context.empty()) if (!context.empty())
{ {
error_msg += "while parsing " + context + " "; error_msg += "while parsing " + context + " ";
} }
......
...@@ -423,7 +423,7 @@ class iter_impl ...@@ -423,7 +423,7 @@ class iter_impl
*/ */
bool operator!=(const iter_impl& other) const bool operator!=(const iter_impl& other) const
{ {
return not operator==(other); return !operator==(other);
} }
/*! /*!
...@@ -459,7 +459,7 @@ class iter_impl ...@@ -459,7 +459,7 @@ class iter_impl
*/ */
bool operator<=(const iter_impl& other) const bool operator<=(const iter_impl& other) const
{ {
return not other.operator < (*this); return !other.operator < (*this);
} }
/*! /*!
...@@ -468,7 +468,7 @@ class iter_impl ...@@ -468,7 +468,7 @@ class iter_impl
*/ */
bool operator>(const iter_impl& other) const bool operator>(const iter_impl& other) const
{ {
return not operator<=(other); return !operator<=(other);
} }
/*! /*!
...@@ -477,7 +477,7 @@ class iter_impl ...@@ -477,7 +477,7 @@ class iter_impl
*/ */
bool operator>=(const iter_impl& other) const bool operator>=(const iter_impl& other) const
{ {
return not operator<(other); return !operator<(other);
} }
/*! /*!
......
...@@ -17,7 +17,7 @@ void int_to_string( string_type& target, std::size_t value ) ...@@ -17,7 +17,7 @@ void int_to_string( string_type& target, std::size_t value )
{ {
target = std::to_string(value); target = std::to_string(value);
} }
template <typename IteratorType> class iteration_proxy_value template<typename IteratorType> class iteration_proxy_value
{ {
public: public:
using difference_type = std::ptrdiff_t; using difference_type = std::ptrdiff_t;
...@@ -131,7 +131,7 @@ template<typename IteratorType> class iteration_proxy ...@@ -131,7 +131,7 @@ template<typename IteratorType> class iteration_proxy
// Structured Bindings Support // Structured Bindings Support
// For further reference see https://blog.tartanllama.xyz/structured-bindings/ // For further reference see https://blog.tartanllama.xyz/structured-bindings/
// And see https://github.com/nlohmann/json/pull/1391 // And see https://github.com/nlohmann/json/pull/1391
template <std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0> template<std::size_t N, typename IteratorType, enable_if_t<N == 0, int> = 0>
auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key()) auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.key())
{ {
return i.key(); return i.key();
...@@ -139,7 +139,7 @@ auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decl ...@@ -139,7 +139,7 @@ auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decl
// Structured Bindings Support // Structured Bindings Support
// For further reference see https://blog.tartanllama.xyz/structured-bindings/ // For further reference see https://blog.tartanllama.xyz/structured-bindings/
// And see https://github.com/nlohmann/json/pull/1391 // And see https://github.com/nlohmann/json/pull/1391
template <std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0> template<std::size_t N, typename IteratorType, enable_if_t<N == 1, int> = 0>
auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value()) auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>& i) -> decltype(i.value())
{ {
return i.value(); return i.value();
...@@ -158,11 +158,11 @@ namespace std ...@@ -158,11 +158,11 @@ namespace std
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmismatched-tags" #pragma clang diagnostic ignored "-Wmismatched-tags"
#endif #endif
template <typename IteratorType> template<typename IteratorType>
class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>> class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
: public std::integral_constant<std::size_t, 2> {}; : public std::integral_constant<std::size_t, 2> {};
template <std::size_t N, typename IteratorType> template<std::size_t N, typename IteratorType>
class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >> class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
{ {
public: public:
......
...@@ -9,10 +9,10 @@ namespace nlohmann ...@@ -9,10 +9,10 @@ namespace nlohmann
{ {
namespace detail namespace detail
{ {
template <typename It, typename = void> template<typename It, typename = void>
struct iterator_types {}; struct iterator_types {};
template <typename It> template<typename It>
struct iterator_types < struct iterator_types <
It, It,
void_t<typename It::difference_type, typename It::value_type, typename It::pointer, void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
...@@ -27,18 +27,18 @@ struct iterator_types < ...@@ -27,18 +27,18 @@ struct iterator_types <
// This is required as some compilers implement std::iterator_traits in a way that // This is required as some compilers implement std::iterator_traits in a way that
// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. // doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341.
template <typename T, typename = void> template<typename T, typename = void>
struct iterator_traits struct iterator_traits
{ {
}; };
template <typename T> template<typename T>
struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
: iterator_types<T> : iterator_types<T>
{ {
}; };
template <typename T> template<typename T>
struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>> struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
{ {
using iterator_category = std::random_access_iterator_tag; using iterator_category = std::random_access_iterator_tag;
......
...@@ -330,7 +330,7 @@ class json_pointer ...@@ -330,7 +330,7 @@ class json_pointer
static int array_index(const std::string& s) static int array_index(const std::string& s)
{ {
// error condition (cf. RFC 6901, Sect. 4) // error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and s[0] == '0')) if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0'))
{ {
JSON_THROW(detail::parse_error::create(106, 0, JSON_THROW(detail::parse_error::create(106, 0,
"array index '" + s + "array index '" + s +
...@@ -338,7 +338,7 @@ class json_pointer ...@@ -338,7 +338,7 @@ class json_pointer
} }
// error condition (cf. RFC 6901, Sect. 4) // error condition (cf. RFC 6901, Sect. 4)
if (JSON_HEDLEY_UNLIKELY(s.size() > 1 and not (s[0] >= '1' and s[0] <= '9'))) if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9')))
{ {
JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number")); JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number"));
} }
...@@ -473,7 +473,7 @@ class json_pointer ...@@ -473,7 +473,7 @@ class json_pointer
}); });
// change value to array for numbers or "-" or to object otherwise // change value to array for numbers or "-" or to object otherwise
*ptr = (nums or reference_token == "-") *ptr = (nums || reference_token == "-")
? detail::value_t::array ? detail::value_t::array
: detail::value_t::object; : detail::value_t::object;
} }
...@@ -661,7 +661,7 @@ class json_pointer ...@@ -661,7 +661,7 @@ class json_pointer
{ {
case detail::value_t::object: case detail::value_t::object:
{ {
if (not ptr->contains(reference_token)) if (!ptr->contains(reference_token))
{ {
// we did not find the key in the object // we did not find the key in the object
return false; return false;
...@@ -678,21 +678,21 @@ class json_pointer ...@@ -678,21 +678,21 @@ class json_pointer
// "-" always fails the range check // "-" always fails the range check
return false; return false;
} }
if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 and not ("0" <= reference_token and reference_token <= "9"))) if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9")))
{ {
// invalid char // invalid char
return false; return false;
} }
if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1))
{ {
if (JSON_HEDLEY_UNLIKELY(not ('1' <= reference_token[0] and reference_token[0] <= '9'))) if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9')))
{ {
// first char should be between '1' and '9' // first char should be between '1' and '9'
return false; return false;
} }
for (std::size_t i = 1; i < reference_token.size(); i++) for (std::size_t i = 1; i < reference_token.size(); i++)
{ {
if (JSON_HEDLEY_UNLIKELY(not ('0' <= reference_token[i] and reference_token[i] <= '9'))) if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9')))
{ {
// other char should be between '0' and '9' // other char should be between '0' and '9'
return false; return false;
...@@ -779,8 +779,8 @@ class json_pointer ...@@ -779,8 +779,8 @@ class json_pointer
assert(reference_token[pos] == '~'); assert(reference_token[pos] == '~');
// ~ must be followed by 0 or 1 // ~ must be followed by 0 or 1
if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 or if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 ||
(reference_token[pos + 1] != '0' and (reference_token[pos + 1] != '0' &&
reference_token[pos + 1] != '1'))) reference_token[pos + 1] != '1')))
{ {
JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'")); JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'"));
...@@ -811,7 +811,7 @@ class json_pointer ...@@ -811,7 +811,7 @@ class json_pointer
static void replace_substring(std::string& s, const std::string& f, static void replace_substring(std::string& s, const std::string& f,
const std::string& t) const std::string& t)
{ {
assert(not f.empty()); assert(!f.empty());
for (auto pos = s.find(f); // find first occurrence of f for (auto pos = s.find(f); // find first occurrence of f
pos != std::string::npos; // make sure f was found pos != std::string::npos; // make sure f was found
s.replace(pos, f.size(), t), // replace with t, and s.replace(pos, f.size(), t), // replace with t, and
...@@ -906,7 +906,7 @@ class json_pointer ...@@ -906,7 +906,7 @@ class json_pointer
static BasicJsonType static BasicJsonType
unflatten(const BasicJsonType& value) unflatten(const BasicJsonType& value)
{ {
if (JSON_HEDLEY_UNLIKELY(not value.is_object())) if (JSON_HEDLEY_UNLIKELY(!value.is_object()))
{ {
JSON_THROW(detail::type_error::create(314, "only objects can be unflattened")); JSON_THROW(detail::type_error::create(314, "only objects can be unflattened"));
} }
...@@ -916,7 +916,7 @@ class json_pointer ...@@ -916,7 +916,7 @@ class json_pointer
// iterate the JSON object values // iterate the JSON object values
for (const auto& element : *value.m_value.object) for (const auto& element : *value.m_value.object)
{ {
if (JSON_HEDLEY_UNLIKELY(not element.second.is_primitive())) if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive()))
{ {
JSON_THROW(detail::type_error::create(315, "values in object must be primitive")); JSON_THROW(detail::type_error::create(315, "values in object must be primitive"));
} }
...@@ -962,7 +962,7 @@ class json_pointer ...@@ -962,7 +962,7 @@ class json_pointer
friend bool operator!=(json_pointer const& lhs, friend bool operator!=(json_pointer const& lhs,
json_pointer const& rhs) noexcept json_pointer const& rhs) noexcept
{ {
return not (lhs == rhs); return !(lhs == rhs);
} }
/// the reference tokens /// the reference tokens
......
...@@ -19,39 +19,39 @@ struct nonesuch ...@@ -19,39 +19,39 @@ struct nonesuch
void operator=(nonesuch&&) = delete; void operator=(nonesuch&&) = delete;
}; };
template <class Default, template<class Default,
class AlwaysVoid, class AlwaysVoid,
template <class...> class Op, template<class...> class Op,
class... Args> class... Args>
struct detector struct detector
{ {
using value_t = std::false_type; using value_t = std::false_type;
using type = Default; using type = Default;
}; };
template <class Default, template <class...> class Op, class... Args> template<class Default, template<class...> class Op, class... Args>
struct detector<Default, void_t<Op<Args...>>, Op, Args...> struct detector<Default, void_t<Op<Args...>>, Op, Args...>
{ {
using value_t = std::true_type; using value_t = std::true_type;
using type = Op<Args...>; using type = Op<Args...>;
}; };
template <template <class...> class Op, class... Args> template<template<class...> class Op, class... Args>
using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t; using is_detected = typename detector<nonesuch, void, Op, Args...>::value_t;
template <template <class...> class Op, class... Args> template<template<class...> class Op, class... Args>
using detected_t = typename detector<nonesuch, void, Op, Args...>::type; using detected_t = typename detector<nonesuch, void, Op, Args...>::type;
template <class Default, template <class...> class Op, class... Args> template<class Default, template<class...> class Op, class... Args>
using detected_or = detector<Default, void, Op, Args...>; using detected_or = detector<Default, void, Op, Args...>;
template <class Default, template <class...> class Op, class... Args> template<class Default, template<class...> class Op, class... Args>
using detected_or_t = typename detected_or<Default, Op, Args...>::type; using detected_or_t = typename detected_or<Default, Op, Args...>::type;
template <class Expected, template <class...> class Op, class... Args> template<class Expected, template<class...> class Op, class... Args>
using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>; using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
template <class To, template <class...> class Op, class... Args> template<class To, template<class...> class Op, class... Args>
using is_detected_convertible = using is_detected_convertible =
std::is_convertible<detected_t<Op, Args...>, To>; std::is_convertible<detected_t<Op, Args...>, To>;
} // namespace detail } // namespace detail
......
...@@ -11,53 +11,53 @@ namespace nlohmann ...@@ -11,53 +11,53 @@ namespace nlohmann
{ {
namespace detail namespace detail
{ {
template <typename T> template<typename T>
using null_function_t = decltype(std::declval<T&>().null()); using null_function_t = decltype(std::declval<T&>().null());
template <typename T> template<typename T>
using boolean_function_t = using boolean_function_t =
decltype(std::declval<T&>().boolean(std::declval<bool>())); decltype(std::declval<T&>().boolean(std::declval<bool>()));
template <typename T, typename Integer> template<typename T, typename Integer>
using number_integer_function_t = using number_integer_function_t =
decltype(std::declval<T&>().number_integer(std::declval<Integer>())); decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
template <typename T, typename Unsigned> template<typename T, typename Unsigned>
using number_unsigned_function_t = using number_unsigned_function_t =
decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>())); decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
template <typename T, typename Float, typename String> template<typename T, typename Float, typename String>
using number_float_function_t = decltype(std::declval<T&>().number_float( using number_float_function_t = decltype(std::declval<T&>().number_float(
std::declval<Float>(), std::declval<const String&>())); std::declval<Float>(), std::declval<const String&>()));
template <typename T, typename String> template<typename T, typename String>
using string_function_t = using string_function_t =
decltype(std::declval<T&>().string(std::declval<String&>())); decltype(std::declval<T&>().string(std::declval<String&>()));
template <typename T> template<typename T>
using start_object_function_t = using start_object_function_t =
decltype(std::declval<T&>().start_object(std::declval<std::size_t>())); decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
template <typename T, typename String> template<typename T, typename String>
using key_function_t = using key_function_t =
decltype(std::declval<T&>().key(std::declval<String&>())); decltype(std::declval<T&>().key(std::declval<String&>()));
template <typename T> template<typename T>
using end_object_function_t = decltype(std::declval<T&>().end_object()); using end_object_function_t = decltype(std::declval<T&>().end_object());
template <typename T> template<typename T>
using start_array_function_t = using start_array_function_t =
decltype(std::declval<T&>().start_array(std::declval<std::size_t>())); decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
template <typename T> template<typename T>
using end_array_function_t = decltype(std::declval<T&>().end_array()); using end_array_function_t = decltype(std::declval<T&>().end_array());
template <typename T, typename Exception> template<typename T, typename Exception>
using parse_error_function_t = decltype(std::declval<T&>().parse_error( using parse_error_function_t = decltype(std::declval<T&>().parse_error(
std::declval<std::size_t>(), std::declval<const std::string&>(), std::declval<std::size_t>(), std::declval<const std::string&>(),
std::declval<const Exception&>())); std::declval<const Exception&>()));
template <typename SAX, typename BasicJsonType> template<typename SAX, typename BasicJsonType>
struct is_sax struct is_sax
{ {
private: private:
...@@ -89,7 +89,7 @@ struct is_sax ...@@ -89,7 +89,7 @@ struct is_sax
is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value; is_detected_exact<bool, parse_error_function_t, SAX, exception_t>::value;
}; };
template <typename SAX, typename BasicJsonType> template<typename SAX, typename BasicJsonType>
struct is_sax_static_asserts struct is_sax_static_asserts
{ {
private: private:
......
...@@ -4,10 +4,10 @@ namespace nlohmann ...@@ -4,10 +4,10 @@ namespace nlohmann
{ {
namespace detail namespace detail
{ {
template <typename ...Ts> struct make_void template<typename ...Ts> struct make_void
{ {
using type = void; using type = void;
}; };
template <typename ...Ts> using void_t = typename make_void<Ts...>::type; template<typename ...Ts> using void_t = typename make_void<Ts...>::type;
} // namespace detail } // namespace detail
} // namespace nlohmann } // namespace nlohmann
...@@ -205,7 +205,7 @@ class serializer ...@@ -205,7 +205,7 @@ class serializer
} }
// last element // last element
assert(not val.m_value.array->empty()); assert(!val.m_value.array->empty());
o->write_characters(indent_string.c_str(), new_indent); o->write_characters(indent_string.c_str(), new_indent);
dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent);
...@@ -226,7 +226,7 @@ class serializer ...@@ -226,7 +226,7 @@ class serializer
} }
// last element // last element
assert(not val.m_value.array->empty()); assert(!val.m_value.array->empty());
dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent);
o->write_character(']'); o->write_character(']');
...@@ -260,7 +260,7 @@ class serializer ...@@ -260,7 +260,7 @@ class serializer
o->write_characters("\"bytes\": [", 10); o->write_characters("\"bytes\": [", 10);
if (not val.m_value.binary->empty()) if (!val.m_value.binary->empty())
{ {
for (auto i = val.m_value.binary->cbegin(); for (auto i = val.m_value.binary->cbegin();
i != val.m_value.binary->cend() - 1; ++i) i != val.m_value.binary->cend() - 1; ++i)
...@@ -291,7 +291,7 @@ class serializer ...@@ -291,7 +291,7 @@ class serializer
{ {
o->write_characters("{\"bytes\":[", 10); o->write_characters("{\"bytes\":[", 10);
if (not val.m_value.binary->empty()) if (!val.m_value.binary->empty())
{ {
for (auto i = val.m_value.binary->cbegin(); for (auto i = val.m_value.binary->cbegin();
i != val.m_value.binary->cend() - 1; ++i) i != val.m_value.binary->cend() - 1; ++i)
...@@ -452,7 +452,7 @@ class serializer ...@@ -452,7 +452,7 @@ class serializer
{ {
// escape control characters (0x00..0x1F) or, if // escape control characters (0x00..0x1F) or, if
// ensure_ascii parameter is used, non-ASCII characters // ensure_ascii parameter is used, non-ASCII characters
if ((codepoint <= 0x1F) or (ensure_ascii and (codepoint >= 0x7F))) if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
{ {
if (codepoint <= 0xFFFF) if (codepoint <= 0xFFFF)
{ {
...@@ -566,7 +566,7 @@ class serializer ...@@ -566,7 +566,7 @@ class serializer
default: // decode found yet incomplete multi-byte code point default: // decode found yet incomplete multi-byte code point
{ {
if (not ensure_ascii) if (!ensure_ascii)
{ {
// code point will not be escaped - copy byte to buffer // code point will not be escaped - copy byte to buffer
string_buffer[bytes++] = s[i]; string_buffer[bytes++] = s[i];
...@@ -670,11 +670,11 @@ class serializer ...@@ -670,11 +670,11 @@ class serializer
@param[in] x integer number (signed or unsigned) to dump @param[in] x integer number (signed or unsigned) to dump
@tparam NumberType either @a number_integer_t or @a number_unsigned_t @tparam NumberType either @a number_integer_t or @a number_unsigned_t
*/ */
template<typename NumberType, detail::enable_if_t< template < typename NumberType, detail::enable_if_t <
std::is_same<NumberType, number_unsigned_t>::value or std::is_same<NumberType, number_unsigned_t>::value ||
std::is_same<NumberType, number_integer_t>::value or std::is_same<NumberType, number_integer_t>::value ||
std::is_same<NumberType, binary_char_t>::value, std::is_same<NumberType, binary_char_t>::value,
int> = 0> int > = 0 >
void dump_integer(NumberType x) void dump_integer(NumberType x)
{ {
static constexpr std::array<std::array<char, 2>, 100> digits_to_99 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
...@@ -703,7 +703,7 @@ class serializer ...@@ -703,7 +703,7 @@ class serializer
// use a pointer to fill the buffer // use a pointer to fill the buffer
auto buffer_ptr = number_buffer.begin(); auto buffer_ptr = number_buffer.begin();
const bool is_negative = std::is_same<NumberType, number_integer_t>::value and not(x >= 0); // see issue #755 const bool is_negative = std::is_same<NumberType, number_integer_t>::value && !(x >= 0); // see issue #755
number_unsigned_t abs_value; number_unsigned_t abs_value;
unsigned int n_chars; unsigned int n_chars;
...@@ -764,7 +764,7 @@ class serializer ...@@ -764,7 +764,7 @@ class serializer
void dump_float(number_float_t x) void dump_float(number_float_t x)
{ {
// NaN / inf // NaN / inf
if (not std::isfinite(x)) if (!std::isfinite(x))
{ {
o->write_characters("null", 4); o->write_characters("null", 4);
return; return;
...@@ -776,8 +776,8 @@ class serializer ...@@ -776,8 +776,8 @@ class serializer
// //
// NB: The test below works if <long double> == <double>. // NB: The test below works if <long double> == <double>.
static constexpr bool is_ieee_single_or_double static constexpr bool is_ieee_single_or_double
= (std::numeric_limits<number_float_t>::is_iec559 and std::numeric_limits<number_float_t>::digits == 24 and std::numeric_limits<number_float_t>::max_exponent == 128) or = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
(std::numeric_limits<number_float_t>::is_iec559 and std::numeric_limits<number_float_t>::digits == 53 and std::numeric_limits<number_float_t>::max_exponent == 1024); (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>()); dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
} }
...@@ -814,7 +814,7 @@ class serializer ...@@ -814,7 +814,7 @@ class serializer
} }
// convert decimal point to '.' // convert decimal point to '.'
if (decimal_point != '\0' and decimal_point != '.') if (decimal_point != '\0' && decimal_point != '.')
{ {
const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point); const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
if (dec_pos != number_buffer.end()) if (dec_pos != number_buffer.end())
...@@ -830,7 +830,7 @@ class serializer ...@@ -830,7 +830,7 @@ class serializer
std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
[](char c) [](char c)
{ {
return c == '.' or c == 'e'; return c == '.' || c == 'e';
}); });
if (value_is_int_like) if (value_is_int_like)
...@@ -916,7 +916,7 @@ class serializer ...@@ -916,7 +916,7 @@ class serializer
*/ */
inline number_unsigned_t remove_sign(number_integer_t x) noexcept inline number_unsigned_t remove_sign(number_integer_t x) noexcept
{ {
assert(x < 0 and x < (std::numeric_limits<number_integer_t>::max)()); assert(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
return static_cast<number_unsigned_t>(-(x + 1)) + 1; return static_cast<number_unsigned_t>(-(x + 1)) + 1;
} }
......
...@@ -77,7 +77,7 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept ...@@ -77,7 +77,7 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept
const auto l_index = static_cast<std::size_t>(lhs); const auto l_index = static_cast<std::size_t>(lhs);
const auto r_index = static_cast<std::size_t>(rhs); const auto r_index = static_cast<std::size_t>(rhs);
return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index]; return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
} }
} // namespace detail } // namespace detail
} // namespace nlohmann } // namespace nlohmann
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment