Re:CppCon 2022
by krona on Saturday September 17, 2022 @11:56AM
(#32878533)
Break up Alloc<T> in to templated and (mostly) non-templated parts? Without seeing the code its hard to know.
[ Parent
| on HN ]
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#...So there is nothing to really break up
Make it forced-inline and it should be more similar to the macro.