| 374 | /// @} |
| 375 | |
| 376 | private: |
| 377 | |
| 378 | /// helper for exception-safe object creation |
| 379 | template<typename T, typename... Args> |
| 380 | JSON_HEDLEY_RETURNS_NON_NULL |
| 381 | static T* create(Args&& ... args) |
| 382 | { |
| 383 | AllocatorType<T> alloc; |
| 384 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 385 | |
| 386 | auto deleter = [&](T * obj) |
| 387 | { |
| 388 | AllocatorTraits::deallocate(alloc, obj, 1); |
| 389 | }; |
| 390 | std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter); |
| 391 | AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...); |
| 392 | JSON_ASSERT(obj != nullptr); |
| 393 | return obj.release(); |
| 394 | } |
| 395 | |
| 396 | //////////////////////// |
| 397 | // JSON value storage // |
no test coverage detected