| 13077 | /// @} |
| 13078 | |
| 13079 | private: |
| 13080 | |
| 13081 | /// helper for exception-safe object creation |
| 13082 | template<typename T, typename... Args> |
| 13083 | static T* create(Args&& ... args) |
| 13084 | { |
| 13085 | AllocatorType<T> alloc; |
| 13086 | using AllocatorTraits = std::allocator_traits<AllocatorType<T>>; |
| 13087 | |
| 13088 | auto deleter = [&](T * object) |
| 13089 | { |
| 13090 | AllocatorTraits::deallocate(alloc, object, 1); |
| 13091 | }; |
| 13092 | std::unique_ptr<T, decltype(deleter)> object(AllocatorTraits::allocate(alloc, 1), deleter); |
| 13093 | AllocatorTraits::construct(alloc, object.get(), std::forward<Args>(args)...); |
| 13094 | assert(object != nullptr); |
| 13095 | return object.release(); |
| 13096 | } |
| 13097 | |
| 13098 | //////////////////////// |
| 13099 | // JSON value storage // |
no test coverage detected