Function allocateSized

Synopsis

#include <Source/Falcor/Utils/AlignedAllocator.h>

template <typename T, typename ... Args>
T * allocateSized(size_t size, Args &&... args)

Description

Allocates an object of given type, potentially including additional memory at the end of it, and executes its constructor.

Parameters:

[ in ] size - Amount of memory to allocate. Must be >= sizeof(T).

[ in ] args - Arguments to pass to the constructor.

Return
pointer to allocated object.

Source

Lines 86-92 in Source/Falcor/Utils/AlignedAllocator.h.

template <typename T, typename ...Args> T* allocateSized(size_t size, Args&&... args)
{
    assert(size >= sizeof(T));
    computeAndAllocatePadding(size);
    void* ptr = allocInternal(size);
    return new (ptr) T(std::forward<Args>(args)...);
}





Add Discussion as Guest

Log in to DocsForge