TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ swap() [2/6]

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 >::swap ( binary_t other)
inline

exchanges the values

Exchanges the contents of a JSON string with those of other. Does not invoke any move, copy, or swap operations on individual elements. All iterators and references remain valid. The past-the-end iterator is invalidated.

Parameters
[in,out]otherbinary to exchange the contents with
Exceptions
type_error.310when JSON value is not a string; example: "cannot use swap() with boolean"

@complexity Constant.

@liveexample{The example below shows how strings can be swapped with swap().,swap__binary_t}

Since
version 3.8.0

Definition at line 23966 of file json.hpp.

23967 {
23968 // swap only works for strings
23969 if (JSON_HEDLEY_LIKELY(is_binary()))
23970 {
23971 std::swap(*(m_value.binary), other);
23972 }
23973
23974 else
23975 {
23976 JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this));
23977 }
23978 }
json_value m_value
the value of the current element
Definition: json.hpp:24928
constexpr bool is_binary() const noexcept
return whether value is a binary array
Definition: json.hpp:20476
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
Definition: json.hpp:24883