Code generation without templates

I'm currently trying to create a C ++ wrapper for OpenGL shaders at compile time. My current implementation uses templates, but none of my employees could read it, and it also put all the code in the header.

Now I wonder if there is a better way? I recently watched a story about a game where a guy said that they never use templates in their engine and that there are much better ways to generate code.

Honestly, I have not found what works for me, and most code generation tools are written in different languages.

I am wondering if there is something like this:

auto foo_class = create_class().setName("Foo");
                               .addMember<int>("i1")
                               .addMethod("print",||(){std::cout<< "hello";});
foo_class.generate();

which will generate

class Foo{
  int i1;
  void print();
  ....
};

void Foo::print(){ std::cout << "hello";}

That way, I could create a separate tool that I could just call at compile time. Is there something similar?

+4

All Articles