cptr::make_array

Allocate n value-initialised T in one block inside the cage, as new Tn does on the heap; free them with destroy_array() and the same n. The count is not stored, which keeps the block the size of the elements, so it is the caller's to keep, as for std::allocator.

Synopsis

Declared in <cptr/ptr.hpp>

template<
    class T,
    class Cage = default_cage>
ptr<T, Cage>
make_array(std::size_t n);

Description

Throws std::bad_array_new_length if n * sizeof(T) overflows and std::bad_alloc when the cage is full. If a constructor throws, the elements already constructed are destroyed, the memory is freed and the exception propagates.

Return Value

The usual compressed pointer: converts implicitly from and to T*.