| 18423 | /// @} |
| 18424 | |
| 18425 | private: |
| 18426 | |
| 18427 | /// helper for exception-safe object creation |
| 18428 | template<typename T, typename... Args> |
| 18429 | JSON_HEDLEY_RETURNS_NON_NULL |
| 18430 | static T* create(Args&& ... args) |
| 18431 | { |
| 18432 | AllocatorType<T> alloc; |
| 18433 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 18434 | |
| 18435 | auto deleter = [&](T * obj) |
| 18436 | { |
| 18437 | AllocatorTraits::deallocate(alloc, obj, 1); |
| 18438 | }; |
| 18439 | std::unique_ptr<T, decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter); |
| 18440 | AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...); |
| 18441 | JSON_ASSERT(obj != nullptr); |
| 18442 | return obj.release(); |
| 18443 | } |
| 18444 | |
| 18445 | //////////////////////// |
| 18446 | // JSON value storage // |
no test coverage detected