TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ basic_json() [9/10]

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>>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::basic_json ( const basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType > &  other)
inline

copy constructor

Creates a copy of a given JSON value.

Parameters
[in]otherthe JSON value to copy
Postcondition
*this == other

@complexity Linear in the size of other.

@exceptionsafety Strong guarantee: if an exception is thrown, there are no changes to any JSON value.

@requirement This function helps basic_json satisfying the Container requirements:

  • The complexity is linear.
  • As postcondition, it holds: other == basic_json(other).

@liveexample{The following code shows an example for the copy constructor.,basic_json__basic_json}

Since
version 1.0.0

Definition at line 19893 of file json.hpp.

19894 : m_type(other.m_type)
19895 {
19896 // check of passed value is valid
19897 other.assert_invariant();
19898
19899 switch (m_type)
19900 {
19901 case value_t::object:
19902 {
19903 m_value = *other.m_value.object;
19904 break;
19905 }
19906
19907 case value_t::array:
19908 {
19909 m_value = *other.m_value.array;
19910 break;
19911 }
19912
19913 case value_t::string:
19914 {
19915 m_value = *other.m_value.string;
19916 break;
19917 }
19918
19919 case value_t::boolean:
19920 {
19921 m_value = other.m_value.boolean;
19922 break;
19923 }
19924
19926 {
19927 m_value = other.m_value.number_integer;
19928 break;
19929 }
19930
19932 {
19933 m_value = other.m_value.number_unsigned;
19934 break;
19935 }
19936
19938 {
19939 m_value = other.m_value.number_float;
19940 break;
19941 }
19942
19943 case value_t::binary:
19944 {
19945 m_value = *other.m_value.binary;
19946 break;
19947 }
19948
19949 case value_t::null:
19950 case value_t::discarded:
19951 default:
19952 break;
19953 }
19954
19955 set_parents();
19957 }
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
Definition: json.hpp:18935
json_value m_value
the value of the current element
Definition: json.hpp:24928
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)