memgraph/poc/memory/maker.hpp
Mislav Bradac 0588de76bb Move unused datastructures to poc
Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D526
2017-07-10 12:03:11 +02:00

20 lines
383 B
C++

#pragma once
#include <cstdlib>
#include "allocator.hpp"
template <class T, typename... Args, class allocator = fast_allocator<T>>
T* makeme(Args... args) {
allocator alloc;
T* mem = alloc.allocate(1);
return new (mem) T(args...);
}
template <class T, class allocator = fast_allocator<T>>
void takeme(T* mem) {
allocator alloc;
mem->~T();
alloc.deallocate(mem, 1);
}