4 ms·
Break up Alloc<T> in to templated and (mostly) non-templated parts? Without seeing the code its hard to know.
by krona 4y ago
Break up Alloc<T> in to templated and (mostly) non-templated parts? Without seeing the code its hard to know.
- chubot 4y agoIt 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