m3ta: A Template Metaprogramming Library

For the needs of a personal C++ project heavily relying on templates, I found myself coding more and more template metaprogramming utilities to the point where I wrote more lines of these than of the actual project itself. The time was for a refactoring—these utilities deserved their own dedicated library.

I thought that the process would take me only a couple of days—how naive of me. Extracting some utilities that work well within a specific project and turning them into something more bulletproof with the help of an extensive set of unit tests is... quite some work. Not even talking of the documentation entirely written manually in reStructuredText, without much help from Sphinx on the C++ front.

Nonetheless, it’s now all good to go and I am pleased to introduce you m3ta!

I’ve made the source code available on GitHub. Note that this library relies on features from C++11.

What Sphinx helped me for though is to make the documentation compatible with the beautifully themed readthedocs.org website.

Curious About Metaprogramming?

If you’re new to template metaprogramming but not to C++, I encourage you to check the examples from the documentation, the source code, or even better, to research the subject on the Internet like I did.

Not only could it potentially expand your way of thinking and your overall programming skills (template metaprogramming can give a small preview of what functional programming is), but it would also open the doors to a whole new set of tools for solving some problems more efficiently.