ned14 / pcpp

A C99 preprocessor written in pure Python
Other
215 stars 39 forks source link

Template expansion? #68

Closed trelau closed 2 years ago

trelau commented 2 years ago

Could pcpp be used (in theory) to expand templates? I am writing a python binding generator and, while possible to handle templates, it can get quite complex.

Basically, i'd like something like typedef SomeTemplate<Type> MyNewType to be expanded to the class template SomeTemplate with the template variables filled in so it just looks like a class definition after expansion.

ned14 commented 2 years ago

C++ template expansion is extremely tricky to get fully right. It may look like token pasting, but it really isn't.

pcpp only does token pasting, so whilst it might get you 95% of the way to a C++ template expansion, it most definitely can't carry you the remaining 5%. Sorry.