| 19589 | /// @} |
| 19590 | |
| 19591 | private: |
| 19592 | |
| 19593 | /// helper for exception-safe object creation |
| 19594 | template<typename T, typename... Args> |
| 19595 | JSON_HEDLEY_RETURNS_NON_NULL |
| 19596 | static T* create(Args&& ... args) |
| 19597 | { |
| 19598 | AllocatorType<T> alloc; |
| 19599 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 19600 | |
| 19601 | auto deleter = [&](T * obj) |
| 19602 | { |
| 19603 | AllocatorTraits::deallocate(alloc, obj, 1); |
| 19604 | }; |
| 19605 | std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter); |
| 19606 | AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...); |
| 19607 | JSON_ASSERT(obj != nullptr); |
| 19608 | return obj.release(); |
| 19609 | } |
| 19610 | |
| 19611 | //////////////////////// |
| 19612 | // JSON value storage // |
no test coverage detected