Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct FactoryAST {
- FactoryAST() = default;
- //in general I am not a super fan of hardcore or complex templates
- //but I decided to experiment a little with it.
- //This is the inner function, a generic function getting an arbitrary
- //number of arguments and forwarding them to the constructor
- template <typename T, typename... Args> T *allocASTNode(Args... args) {
- return new(allocator.alloc(sizeof(T))) T(args...);
- }
- template <typename... Args>
- codegen::VariableExprAST *allocVariableAST(Args &&... args) {
- return allocASTNode<codegen::VariableExprAST>(
- std::forward<Args...>(args));
- }
- SlabAllocator allocator;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement