55 template<
typename T>
T *
add(std::unique_ptr<T>
resource);
67 void add(
void *userdata,
void (*
free)(
void *));
83 template<
typename T,
typename... Args>
T &
construct(Args &&...args);
105 if (
ptr ==
nullptr) {
108 this->
add(ptr, [](
void *
data) {
109 T *typed_data =
reinterpret_cast<T *
>(
data);
118 if (
ptr ==
nullptr) {
122 if constexpr (std::is_trivially_destructible_v<T>) {
126 this->
add(ptr, [](
void *
data) {
127 T *typed_data =
reinterpret_cast<T *
>(
data);
136 data.data = userdata;
138 resources_.append(
data);
148 void *buffer = allocator_.allocate(
sizeof(Func),
alignof(Func));
149 new (buffer) Func(std::move(func));
150 this->
add(buffer, [](
void *
data) { (*
static_cast<Func *
>(
data))(); });
155 destruct_ptr<T> value_ptr = allocator_.construct<
T>(std::forward<Args>(args)...);
156 T &value_ref = *value_ptr;
157 this->
add(std::move(value_ptr));
163 void *buffer = allocator_.allocate(type);
void BLI_kdtree_nd_ free(KDTree *tree)
BMesh const char void * data
bool is_trivially_destructible
void destruct(void *ptr) const
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
T & construct(Args &&...args)
void add_destruct_call(Func func)
void * allocate_owned(const CPPType &type)
LinearAllocator & allocator()
T * add(std::unique_ptr< T > resource)
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr