| 19549 | /// @} |
| 19550 | |
| 19551 | private: |
| 19552 | |
| 19553 | /// helper for exception-safe object creation |
| 19554 | template<typename T, typename... Args> |
| 19555 | JSON_HEDLEY_RETURNS_NON_NULL |
| 19556 | static T* create(Args&& ... args) |
| 19557 | { |
| 19558 | AllocatorType<T> alloc; |
| 19559 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 19560 | |
| 19561 | auto deleter = [&](T * obj) |
| 19562 | { |
| 19563 | AllocatorTraits::deallocate(alloc, obj, 1); |
| 19564 | }; |
| 19565 | std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter); |
| 19566 | AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...); |
| 19567 | JSON_ASSERT(obj != nullptr); |
| 19568 | return obj.release(); |
| 19569 | } |
| 19570 | |
| 19571 | //////////////////////// |
| 19572 | // JSON value storage // |
no test coverage detected