template<template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator, template< typename T, typename SFINAE=void > class JSONSerializer = adl_serializer, class BinaryType = std::vector<std::uint8_t>>
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::assert_invariant |
( |
bool |
check_parents = true | ) |
const |
|
inlineprivatenoexcept |
checks the class invariants
This function asserts the class invariants. It needs to be called at the end of every constructor to make sure that created objects respect the invariant. Furthermore, it has to be called each time the type of a JSON value is changed, because the invariant expresses a relationship between m_type and m_value.
Furthermore, the parent relation is checked for arrays and objects: If check_parents true and the value is an array or object, then the container's elements must have the current value as parent.
- Parameters
-
[in] | check_parents | whether the parent relation should be checked. The value is true by default and should only be set to false during destruction of objects when the invariant does not need to hold. |
Definition at line 18935 of file json.hpp.
18936 {
18941#if JSON_DIAGNOSTICS
18942 JSON_TRY
18943 {
18944
18946 {
18947 return j.m_parent == this;
18948 }));
18949 }
18950 JSON_CATCH(...) {}
18951#endif
18952 static_cast<void>(check_parents);
18953 }
basic_json(const value_t v)
create an empty value with a given type
iterator begin() noexcept
returns an iterator to the first element
constexpr bool is_structured() const noexcept
return whether type is structured
json_value m_value
the value of the current element
iterator end() noexcept
returns an iterator to one past the last element
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ array
array (ordered collection of values)