TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ assert_invariant()

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_parentswhether 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 {
18937 JSON_ASSERT(m_type != value_t::object || m_value.object != nullptr);
18938 JSON_ASSERT(m_type != value_t::array || m_value.array != nullptr);
18939 JSON_ASSERT(m_type != value_t::string || m_value.string != nullptr);
18940 JSON_ASSERT(m_type != value_t::binary || m_value.binary != nullptr);
18941#if JSON_DIAGNOSTICS
18942 JSON_TRY
18943 {
18944 // cppcheck-suppress assertWithSideEffect
18945 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j)
18946 {
18947 return j.m_parent == this;
18948 }));
18949 }
18950 JSON_CATCH(...) {} // LCOV_EXCL_LINE
18951#endif
18952 static_cast<void>(check_parents);
18953 }
basic_json(const value_t v)
create an empty value with a given type
Definition: json.hpp:19164
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:22377
constexpr bool is_structured() const noexcept
return whether type is structured
Definition: json.hpp:20229
json_value m_value
the value of the current element
Definition: json.hpp:24928
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:22448
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ array
array (ordered collection of values)