TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ create()

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>>
template<typename T , typename... Args>
static JSON_HEDLEY_RETURNS_NON_NULL T * nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::create ( Args &&...  args)
inlinestaticprivate

helper for exception-safe object creation

Definition at line 18608 of file json.hpp.

18609 {
18610 AllocatorType<T> alloc;
18611 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
18612 auto deleter = [&](T * obj)
18613 {
18614 AllocatorTraits::deallocate(alloc, obj, 1);
18615 };
18616 std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
18617 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
18618 JSON_ASSERT(obj != nullptr);
18619 return obj.release();
18620 }