Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Basically, taking advantage of VS's variadic macros (http://msdn.microsoft.com/en-us/library/ms177415(v=vs.80).aspx), notice the allocation call inside of the macro: */
- #define stack_new(type, sa, ...) new (sa.Allocate(sizeof(type))) type(__VA_ARGS__);
- /* So all you'd do is pass in the type, allocator, and the class's parameters, and you're good to go without the yucky template specialization: */
- {
- StackAllocator stack_alloc(linear_allocator);
- SomeObject* so = stack_new(SomeObject, stack_alloc, param1, param2, param3, param4); //etc.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement