| 17480 | /// @} |
| 17481 | |
| 17482 | private: |
| 17483 | |
| 17484 | /// helper for exception-safe object creation |
| 17485 | template<typename T, typename... Args> |
| 17486 | JSON_HEDLEY_RETURNS_NON_NULL |
| 17487 | static T* create(Args&& ... args) |
| 17488 | { |
| 17489 | AllocatorType<T> alloc; |
| 17490 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 17491 | |
| 17492 | auto deleter = [&](T * object) |
| 17493 | { |
| 17494 | AllocatorTraits::deallocate(alloc, object, 1); |
| 17495 | }; |
| 17496 | std::unique_ptr<T, decltype(deleter)> object(AllocatorTraits::allocate(alloc, 1), deleter); |
| 17497 | AllocatorTraits::construct(alloc, object.get(), std::forward<Args>(args)...); |
| 17498 | JSON_ASSERT(object != nullptr); |
| 17499 | return object.release(); |
| 17500 | } |
| 17501 | |
| 17502 | //////////////////////// |
| 17503 | // JSON value storage // |
no test coverage detected