1
0
mirror of https://github.com/nlohmann/json.git synced 2025-08-07 18:02:57 +03:00

🎨 replace alternative operators (and, not, or)

This commit is contained in:
Niels Lohmann
2020-06-03 14:20:36 +02:00
parent 4f04ea1bef
commit 0498202a03
22 changed files with 1300 additions and 1300 deletions

View File

@@ -1135,7 +1135,7 @@ class basic_json
}
}
while (not stack.empty())
while (!stack.empty())
{
// move the last item to local variable to be processed
basic_json current_item(std::move(stack.back()));
@@ -1217,10 +1217,10 @@ class basic_json
*/
void assert_invariant() const noexcept
{
assert(m_type != value_t::object or m_value.object != nullptr);
assert(m_type != value_t::array or m_value.array != nullptr);
assert(m_type != value_t::string or m_value.string != nullptr);
assert(m_type != value_t::binary or m_value.binary != nullptr);
assert(m_type != value_t::object || m_value.object != nullptr);
assert(m_type != value_t::array || m_value.array != nullptr);
assert(m_type != value_t::string || m_value.string != nullptr);
assert(m_type != value_t::binary || m_value.binary != nullptr);
}
public:
@@ -1428,10 +1428,10 @@ class basic_json
@since version 2.1.0
*/
template <typename CompatibleType,
typename U = detail::uncvref_t<CompatibleType>,
detail::enable_if_t<
not detail::is_basic_json<U>::value and detail::is_compatible_type<basic_json_t, U>::value, int> = 0>
template < typename CompatibleType,
typename U = detail::uncvref_t<CompatibleType>,
detail::enable_if_t <
!detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value, int > = 0 >
basic_json(CompatibleType && val) noexcept(noexcept(
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
std::forward<CompatibleType>(val))))
@@ -1466,9 +1466,9 @@ class basic_json
@since version 3.2.0
*/
template <typename BasicJsonType,
detail::enable_if_t<
detail::is_basic_json<BasicJsonType>::value and not std::is_same<basic_json, BasicJsonType>::value, int> = 0>
template < typename BasicJsonType,
detail::enable_if_t <
detail::is_basic_json<BasicJsonType>::value&& !std::is_same<basic_json, BasicJsonType>::value, int > = 0 >
basic_json(const BasicJsonType& val)
{
using other_boolean_t = typename BasicJsonType::boolean_t;
@@ -1601,11 +1601,11 @@ class basic_json
bool is_an_object = std::all_of(init.begin(), init.end(),
[](const detail::json_ref<basic_json>& element_ref)
{
return element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string();
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
});
// adjust type if type deduction is not wanted
if (not type_deduction)
if (!type_deduction)
{
// if array is wanted, do not create an object though possible
if (manual_type == value_t::array)
@@ -1614,7 +1614,7 @@ class basic_json
}
// if object is wanted but impossible, throw an exception
if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object and not is_an_object))
if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object))
{
JSON_THROW(type_error::create(301, "cannot create object from initializer list"));
}
@@ -1908,9 +1908,9 @@ class basic_json
@since version 1.0.0
*/
template<class InputIT, typename std::enable_if<
std::is_same<InputIT, typename basic_json_t::iterator>::value or
std::is_same<InputIT, typename basic_json_t::const_iterator>::value, int>::type = 0>
template < class InputIT, typename std::enable_if <
std::is_same<InputIT, typename basic_json_t::iterator>::value ||
std::is_same<InputIT, typename basic_json_t::const_iterator>::value, int >::type = 0 >
basic_json(InputIT first, InputIT last)
{
assert(first.m_object != nullptr);
@@ -1934,8 +1934,8 @@ class basic_json
case value_t::number_unsigned:
case value_t::string:
{
if (JSON_HEDLEY_UNLIKELY(not first.m_it.primitive_iterator.is_begin()
or not last.m_it.primitive_iterator.is_end()))
if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin()
|| !last.m_it.primitive_iterator.is_end()))
{
JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
}
@@ -2011,9 +2011,9 @@ class basic_json
// other constructors and destructor //
///////////////////////////////////////
template <typename JsonRef,
detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
template<typename JsonRef,
detail::enable_if_t<detail::conjunction<detail::is_json_ref<JsonRef>,
std::is_same<typename JsonRef::value_type, basic_json>>::value, int> = 0 >
basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {}
/*!
@@ -2168,9 +2168,9 @@ class basic_json
@since version 1.0.0
*/
basic_json& operator=(basic_json other) noexcept (
std::is_nothrow_move_constructible<value_t>::value and
std::is_nothrow_move_assignable<value_t>::value and
std::is_nothrow_move_constructible<json_value>::value and
std::is_nothrow_move_constructible<value_t>::value&&
std::is_nothrow_move_assignable<value_t>::value&&
std::is_nothrow_move_constructible<json_value>::value&&
std::is_nothrow_move_assignable<json_value>::value
)
{
@@ -2349,7 +2349,7 @@ class basic_json
*/
constexpr bool is_primitive() const noexcept
{
return is_null() or is_string() or is_boolean() or is_number() or is_binary();
return is_null() || is_string() || is_boolean() || is_number() || is_binary();
}
/*!
@@ -2376,7 +2376,7 @@ class basic_json
*/
constexpr bool is_structured() const noexcept
{
return is_array() or is_object();
return is_array() || is_object();
}
/*!
@@ -2450,7 +2450,7 @@ class basic_json
*/
constexpr bool is_number() const noexcept
{
return is_number_integer() or is_number_float();
return is_number_integer() || is_number_float();
}
/*!
@@ -2479,7 +2479,7 @@ class basic_json
*/
constexpr bool is_number_integer() const noexcept
{
return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
}
/*!
@@ -2860,9 +2860,9 @@ class basic_json
@since version 3.2.0
*/
template<typename BasicJsonType, detail::enable_if_t<
not std::is_same<BasicJsonType, basic_json>::value and
detail::is_basic_json<BasicJsonType>::value, int> = 0>
template < typename BasicJsonType, detail::enable_if_t <
!std::is_same<BasicJsonType, basic_json>::value&&
detail::is_basic_json<BasicJsonType>::value, int > = 0 >
BasicJsonType get() const
{
return *this;
@@ -2907,19 +2907,19 @@ class basic_json
@since version 2.1.0
*/
template<typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
detail::enable_if_t <
not detail::is_basic_json<ValueType>::value and
detail::has_from_json<basic_json_t, ValueType>::value and
not detail::has_non_default_from_json<basic_json_t, ValueType>::value,
int> = 0>
template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
detail::enable_if_t <
!detail::is_basic_json<ValueType>::value &&
detail::has_from_json<basic_json_t, ValueType>::value &&
!detail::has_non_default_from_json<basic_json_t, ValueType>::value,
int > = 0 >
ValueType get() const noexcept(noexcept(
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
{
// we cannot static_assert on ValueTypeCV being non-const, because
// there is support for get<const basic_json_t>(), which is why we
// still need the uncvref
static_assert(not std::is_reference<ValueTypeCV>::value,
static_assert(!std::is_reference<ValueTypeCV>::value,
"get() cannot be used with reference types, you might want to use get_ref()");
static_assert(std::is_default_constructible<ValueType>::value,
"types must be DefaultConstructible when used with get()");
@@ -2960,14 +2960,14 @@ class basic_json
@since version 2.1.0
*/
template<typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
detail::enable_if_t<not std::is_same<basic_json_t, ValueType>::value and
detail::has_non_default_from_json<basic_json_t, ValueType>::value,
int> = 0>
template < typename ValueTypeCV, typename ValueType = detail::uncvref_t<ValueTypeCV>,
detail::enable_if_t < !std::is_same<basic_json_t, ValueType>::value &&
detail::has_non_default_from_json<basic_json_t, ValueType>::value,
int > = 0 >
ValueType get() const noexcept(noexcept(
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
{
static_assert(not std::is_reference<ValueTypeCV>::value,
static_assert(!std::is_reference<ValueTypeCV>::value,
"get() cannot be used with reference types, you might want to use get_ref()");
return JSONSerializer<ValueType>::from_json(*this);
}
@@ -3005,11 +3005,11 @@ class basic_json
@since version 3.3.0
*/
template<typename ValueType,
detail::enable_if_t <
not detail::is_basic_json<ValueType>::value and
detail::has_from_json<basic_json_t, ValueType>::value,
int> = 0>
template < typename ValueType,
detail::enable_if_t <
!detail::is_basic_json<ValueType>::value&&
detail::has_from_json<basic_json_t, ValueType>::value,
int > = 0 >
ValueType & get_to(ValueType& v) const noexcept(noexcept(
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
{
@@ -3069,9 +3069,9 @@ class basic_json
@brief get a pointer value (implicit)
@copydoc get_ptr()
*/
template<typename PointerType, typename std::enable_if<
std::is_pointer<PointerType>::value and
std::is_const<typename std::remove_pointer<PointerType>::type>::value, int>::type = 0>
template < typename PointerType, typename std::enable_if <
std::is_pointer<PointerType>::value&&
std::is_const<typename std::remove_pointer<PointerType>::type>::value, int >::type = 0 >
constexpr auto get_ptr() const noexcept -> decltype(std::declval<const basic_json_t&>().get_impl_ptr(std::declval<PointerType>()))
{
// delegate the call to get_impl_ptr<>() const
@@ -3163,9 +3163,9 @@ class basic_json
@brief get a reference value (implicit)
@copydoc get_ref()
*/
template<typename ReferenceType, typename std::enable_if<
std::is_reference<ReferenceType>::value and
std::is_const<typename std::remove_reference<ReferenceType>::type>::value, int>::type = 0>
template < typename ReferenceType, typename std::enable_if <
std::is_reference<ReferenceType>::value&&
std::is_const<typename std::remove_reference<ReferenceType>::type>::value, int >::type = 0 >
ReferenceType get_ref() const
{
// delegate call to get_ref_impl
@@ -3202,15 +3202,15 @@ class basic_json
@since version 1.0.0
*/
template < typename ValueType, typename std::enable_if <
not std::is_pointer<ValueType>::value and
not std::is_same<ValueType, detail::json_ref<basic_json>>::value and
not std::is_same<ValueType, typename string_t::value_type>::value and
not detail::is_basic_json<ValueType>::value
and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) and _MSC_VER >= 1910 and _MSC_VER <= 1914))
and not std::is_same<ValueType, typename std::string_view>::value
!std::is_pointer<ValueType>::value&&
!std::is_same<ValueType, detail::json_ref<basic_json>>::value&&
!std::is_same<ValueType, typename string_t::value_type>::value&&
!detail::is_basic_json<ValueType>::value
&& !std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
&& !std::is_same<ValueType, typename std::string_view>::value
#endif
and detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value
&& detail::is_detected<detail::get_template_function, const basic_json_t&, ValueType>::value
, int >::type = 0 >
operator ValueType() const
{
@@ -3229,7 +3229,7 @@ class basic_json
*/
binary_t& get_binary()
{
if (not is_binary())
if (!is_binary())
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name())));
}
@@ -3240,7 +3240,7 @@ class basic_json
/// @copydoc get_binary()
const binary_t& get_binary() const
{
if (not is_binary())
if (!is_binary())
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name())));
}
@@ -3767,9 +3767,9 @@ class basic_json
@since version 1.0.0
*/
template<class ValueType, typename std::enable_if<
std::is_convertible<basic_json_t, ValueType>::value
and not std::is_same<value_t, ValueType>::value, int>::type = 0>
template < class ValueType, typename std::enable_if <
std::is_convertible<basic_json_t, ValueType>::value
&& !std::is_same<value_t, ValueType>::value, int >::type = 0 >
ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const
{
// at only works for objects
@@ -4003,10 +4003,10 @@ class basic_json
@since version 1.0.0
*/
template<class IteratorType, typename std::enable_if<
std::is_same<IteratorType, typename basic_json_t::iterator>::value or
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int>::type
= 0>
template < class IteratorType, typename std::enable_if <
std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int >::type
= 0 >
IteratorType erase(IteratorType pos)
{
// make sure iterator fits the current value
@@ -4026,7 +4026,7 @@ class basic_json
case value_t::string:
case value_t::binary:
{
if (JSON_HEDLEY_UNLIKELY(not pos.m_it.primitive_iterator.is_begin()))
if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin()))
{
JSON_THROW(invalid_iterator::create(205, "iterator out of range"));
}
@@ -4116,14 +4116,14 @@ class basic_json
@since version 1.0.0
*/
template<class IteratorType, typename std::enable_if<
std::is_same<IteratorType, typename basic_json_t::iterator>::value or
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int>::type
= 0>
template < class IteratorType, typename std::enable_if <
std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int >::type
= 0 >
IteratorType erase(IteratorType first, IteratorType last)
{
// make sure iterator fits the current value
if (JSON_HEDLEY_UNLIKELY(this != first.m_object or this != last.m_object))
if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
{
JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value"));
}
@@ -4139,8 +4139,8 @@ class basic_json
case value_t::string:
case value_t::binary:
{
if (JSON_HEDLEY_LIKELY(not first.m_it.primitive_iterator.is_begin()
or not last.m_it.primitive_iterator.is_end()))
if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin()
|| !last.m_it.primitive_iterator.is_end()))
{
JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
}
@@ -4385,11 +4385,11 @@ class basic_json
@since version 3.6.0
*/
template<typename KeyT, typename std::enable_if<
not std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int>::type = 0>
template < typename KeyT, typename std::enable_if <
!std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int >::type = 0 >
bool contains(KeyT && key) const
{
return is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
return is_object() && m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
}
/*!
@@ -5207,7 +5207,7 @@ class basic_json
void push_back(basic_json&& val)
{
// push_back only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array())))
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
}
@@ -5242,7 +5242,7 @@ class basic_json
void push_back(const basic_json& val)
{
// push_back only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array())))
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
}
@@ -5292,7 +5292,7 @@ class basic_json
void push_back(const typename object_t::value_type& val)
{
// push_back only works for null objects or objects
if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_object())))
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
}
@@ -5346,7 +5346,7 @@ class basic_json
*/
void push_back(initializer_list_t init)
{
if (is_object() and init.size() == 2 and (*init.begin())->is_string())
if (is_object() && init.size() == 2 && (*init.begin())->is_string())
{
basic_json&& key = init.begin()->moved_or_copied();
push_back(typename object_t::value_type(
@@ -5395,7 +5395,7 @@ class basic_json
reference emplace_back(Args&& ... args)
{
// emplace_back only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_array())))
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
{
JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name())));
}
@@ -5448,7 +5448,7 @@ class basic_json
std::pair<iterator, bool> emplace(Args&& ... args)
{
// emplace only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(not(is_null() or is_object())))
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
{
JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name())));
}
@@ -5615,7 +5615,7 @@ class basic_json
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
{
// insert only works for arrays
if (JSON_HEDLEY_UNLIKELY(not is_array()))
if (JSON_HEDLEY_UNLIKELY(!is_array()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
}
@@ -5668,7 +5668,7 @@ class basic_json
iterator insert(const_iterator pos, initializer_list_t ilist)
{
// insert only works for arrays
if (JSON_HEDLEY_UNLIKELY(not is_array()))
if (JSON_HEDLEY_UNLIKELY(!is_array()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
}
@@ -5709,7 +5709,7 @@ class basic_json
void insert(const_iterator first, const_iterator last)
{
// insert only works for objects
if (JSON_HEDLEY_UNLIKELY(not is_object()))
if (JSON_HEDLEY_UNLIKELY(!is_object()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
}
@@ -5721,7 +5721,7 @@ class basic_json
}
// passed iterators must belong to objects
if (JSON_HEDLEY_UNLIKELY(not first.m_object->is_object()))
if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()))
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
}
@@ -5758,11 +5758,11 @@ class basic_json
assert_invariant();
}
if (JSON_HEDLEY_UNLIKELY(not is_object()))
if (JSON_HEDLEY_UNLIKELY(!is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
}
if (JSON_HEDLEY_UNLIKELY(not j.is_object()))
if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
}
@@ -5809,7 +5809,7 @@ class basic_json
assert_invariant();
}
if (JSON_HEDLEY_UNLIKELY(not is_object()))
if (JSON_HEDLEY_UNLIKELY(!is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
}
@@ -5821,8 +5821,8 @@ class basic_json
}
// passed iterators must belong to objects
if (JSON_HEDLEY_UNLIKELY(not first.m_object->is_object()
or not last.m_object->is_object()))
if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()
|| !last.m_object->is_object()))
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
}
@@ -5851,9 +5851,9 @@ class basic_json
@since version 1.0.0
*/
void swap(reference other) noexcept (
std::is_nothrow_move_constructible<value_t>::value and
std::is_nothrow_move_assignable<value_t>::value and
std::is_nothrow_move_constructible<json_value>::value and
std::is_nothrow_move_constructible<value_t>::value&&
std::is_nothrow_move_assignable<value_t>::value&&
std::is_nothrow_move_constructible<json_value>::value&&
std::is_nothrow_move_assignable<json_value>::value
)
{
@@ -6113,27 +6113,27 @@ class basic_json
return false;
}
}
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
{
return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
}
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
{
return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
}
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
{
return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
}
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
{
return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
}
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
{
return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
}
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
{
return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
}
@@ -6183,7 +6183,7 @@ class basic_json
*/
friend bool operator!=(const_reference lhs, const_reference rhs) noexcept
{
return not (lhs == rhs);
return !(lhs == rhs);
}
/*!
@@ -6276,27 +6276,27 @@ class basic_json
return false;
}
}
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float)
{
return static_cast<number_float_t>(lhs.m_value.number_integer) < rhs.m_value.number_float;
}
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer)
{
return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_integer);
}
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float)
{
return static_cast<number_float_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_float;
}
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned)
{
return lhs.m_value.number_float < static_cast<number_float_t>(rhs.m_value.number_unsigned);
}
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned)
{
return lhs.m_value.number_integer < static_cast<number_integer_t>(rhs.m_value.number_unsigned);
}
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer)
{
return static_cast<number_integer_t>(lhs.m_value.number_unsigned) < rhs.m_value.number_integer;
}
@@ -6350,7 +6350,7 @@ class basic_json
*/
friend bool operator<=(const_reference lhs, const_reference rhs) noexcept
{
return not (rhs < lhs);
return !(rhs < lhs);
}
/*!
@@ -6396,7 +6396,7 @@ class basic_json
*/
friend bool operator>(const_reference lhs, const_reference rhs) noexcept
{
return not (lhs <= rhs);
return !(lhs <= rhs);
}
/*!
@@ -6442,7 +6442,7 @@ class basic_json
*/
friend bool operator>=(const_reference lhs, const_reference rhs) noexcept
{
return not (lhs < rhs);
return !(lhs < rhs);
}
/*!
@@ -6695,7 +6695,7 @@ class basic_json
@since version 3.2.0
*/
template <typename SAX, typename InputType>
template<typename SAX, typename InputType>
JSON_HEDLEY_NON_NULL(2)
static bool sax_parse(InputType&& i, SAX* sax,
input_format_t format = input_format_t::json,
@@ -6707,7 +6707,7 @@ class basic_json
: detail::binary_reader<basic_json, decltype(ia), SAX>(std::move(ia)).sax_parse(format, sax, strict);
}
template <typename SAX>
template<typename SAX>
JSON_HEDLEY_NON_NULL(2)
static bool sax_parse(detail::span_input_adapter&& i, SAX* sax,
input_format_t format = input_format_t::json,
@@ -8211,7 +8211,7 @@ class basic_json
};
// type check: top level value must be an array
if (JSON_HEDLEY_UNLIKELY(not json_patch.is_array()))
if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array()))
{
JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
}
@@ -8237,7 +8237,7 @@ class basic_json
}
// check if result is of type string
if (JSON_HEDLEY_UNLIKELY(string_type and not it->second.is_string()))
if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string()))
{
JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'"));
}
@@ -8247,7 +8247,7 @@ class basic_json
};
// type check: every element of the array must be an object
if (JSON_HEDLEY_UNLIKELY(not val.is_object()))
if (JSON_HEDLEY_UNLIKELY(!val.is_object()))
{
JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
}
@@ -8325,7 +8325,7 @@ class basic_json
}
// throw an exception if test fails
if (JSON_HEDLEY_UNLIKELY(not success))
if (JSON_HEDLEY_UNLIKELY(!success))
{
JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump()));
}
@@ -8407,7 +8407,7 @@ class basic_json
{
// first pass: traverse common elements
std::size_t i = 0;
while (i < source.size() and i < target.size())
while (i < source.size() && i < target.size())
{
// recursive call to compare array values at index i
auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i));
@@ -8558,7 +8558,7 @@ class basic_json
{
if (apply_patch.is_object())
{
if (not is_object())
if (!is_object())
{
*this = object();
}
@@ -8648,7 +8648,7 @@ struct less<::nlohmann::detail::value_t>
*/
template<>
inline void swap<nlohmann::json>(nlohmann::json& j1, nlohmann::json& j2) noexcept(
is_nothrow_move_constructible<nlohmann::json>::value and
is_nothrow_move_constructible<nlohmann::json>::value&&
is_nothrow_move_assignable<nlohmann::json>::value
)
{