| 15364 | /// @} |
| 15365 | |
| 15366 | private: |
| 15367 | |
| 15368 | /// helper for exception-safe object creation |
| 15369 | template<typename T, typename... Args> |
| 15370 | JSON_HEDLEY_RETURNS_NON_NULL |
| 15371 | static T* create(Args&& ... args) |
| 15372 | { |
| 15373 | AllocatorType<T> alloc; |
| 15374 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 15375 | |
| 15376 | auto deleter = [&](T * object) |
| 15377 | { |
| 15378 | AllocatorTraits::deallocate(alloc, object, 1); |
| 15379 | }; |
| 15380 | std::unique_ptr<T, decltype(deleter)> object(AllocatorTraits::allocate(alloc, 1), deleter); |
| 15381 | AllocatorTraits::construct(alloc, object.get(), std::forward<Args>(args)...); |
| 15382 | assert(object != nullptr); |
| 15383 | return object.release(); |
| 15384 | } |
| 15385 | |
| 15386 | //////////////////////// |
| 15387 | // JSON value storage // |
no test coverage detected