| 17398 | /// @} |
| 17399 | |
| 17400 | private: |
| 17401 | |
| 17402 | /// helper for exception-safe object creation |
| 17403 | template<typename T, typename... Args> |
| 17404 | JSON_HEDLEY_RETURNS_NON_NULL |
| 17405 | static T* create(Args&& ... args) |
| 17406 | { |
| 17407 | AllocatorType<T> alloc; |
| 17408 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 17409 | |
| 17410 | auto deleter = [&](T* object) |
| 17411 | { |
| 17412 | AllocatorTraits::deallocate(alloc, object, 1); |
| 17413 | }; |
| 17414 | std::unique_ptr<T, decltype(deleter)> object(AllocatorTraits::allocate(alloc, 1), deleter); |
| 17415 | AllocatorTraits::construct(alloc, object.get(), std::forward<Args>(args)...); |
| 17416 | JSON_ASSERT(object != nullptr); |
| 17417 | return object.release(); |
| 17418 | } |
| 17419 | |
| 17420 | //////////////////////// |
| 17421 | // JSON value storage // |
no test coverage detected