4 ms·
It is a tiny function that is basically equivalent to that macro, but using variadic templates: template <typename T, typename... Args> T* Alloc(Args&&
by chubot 4y ago
It is a tiny function that is basically equivalent to that macro, but using variadic templates:
template <typename T, typename... Args>
T* Alloc(Args&&... args) {
assert(gHeap.is_initialized_);
void* place = gHeap.Allocate(sizeof(T));
assert(place != nullptr);
// placement new
return new (place) T(std::forward<Args>(args)...);
}
https://github.com/oilshell/oil/blob/master/mycpp/gc_heap.h#L23 https://github.com/oilshell/oil/blob/master/mycpp/gc_heap.h#...
So there is nothing to really break up