33#ifndef DART_COMMON_DETAIL_MEMORYALLOCATOR_HPP_
34#define DART_COMMON_DETAIL_MEMORYALLOCATOR_HPP_
44 return static_cast<T*
>(allocate(n *
sizeof(T)));
48template <
typename T,
typename... Args>
52 void*
object = allocate(
sizeof(T));
61 new (object) T(std::forward<Args>(args)...);
65 deallocate(
object,
sizeof(T));
69 return reinterpret_cast<T*
>(object);
73template <
typename T,
typename... Args>
76 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(pointer)))
77 T(std::forward<Args>(args)...);
81template <
typename T,
typename... Args>
84 return ::new (
const_cast<void*
>(
static_cast<const volatile void*
>(pointer)))
85 T(std::forward<Args>(args)...);
97 deallocate(
object,
sizeof(T));
void destroy(T *object) noexcept
Calls the destructor of the object and deallocate the storage.
Definition MemoryAllocator-impl.hpp:90
T * constructAt(void *pointer, Args &&... args)
Definition MemoryAllocator-impl.hpp:74
T * construct(Args &&... args) noexcept
Allocates uninitialized storage and constructs an object of type T to the allocated storage.
Definition MemoryAllocator-impl.hpp:49
T * allocateAs(size_t n=1) noexcept
Allocates object(s) without calling the constructor.
Definition MemoryAllocator-impl.hpp:42