Template Struct Factory

Struct Documentation

template<typename T, typename Allocator>
struct Factory

Allocates one contiguous batch and constructs each T separately.

Each returned handle destroys its object; the shared allocation owner calls allocator deallocate(original, count) after the final handle is gone.

Public Types

using AAloc = std::allocator_traits<Allocator>

Public Static Functions

template<typename ...Args>
static std::vector<std::shared_ptr<T>> create(size_t N, Args... args)

Allocate one batch and return a handle for each constructed object.

template<typename ...Args>
static void construct(T *p, size_t N, Args... args)

Construct N objects in caller-owned storage; roll back on failure.

static void destroy(T *p, size_t N = 1)

Destroy N objects without releasing their backing allocation.