1. 2

I tend to use often C++ template metaprogramming for various reasons. One of the usual annoyances is the impossibility of using literal strings as type parameters within template parameter lists (this is something different from using constexpr strings and so on).

I thought of distilling a short yet powerful implementation in a single-header, fast-compile time wise, standard compliant and no-deps library for others to use instead of having to deal with really warped code in order to do something as simple, as powerful yet as missing from the language (so far). Hope you’ll enjoy.


  2. 2

    “If you don’t realize what this is for, by now, then it is probably not meant for you.”

    This is true, but I’m still curious about it. Could some one please summarize what this is for? Thanks!

    1. 2

      Hello and thanks for the interest. One of the applications of such a feature would be in the field of template metaprogramming generating code for parsers. See things like PEGTL. Another application is in things like type-safe printf, DSL embedding etc, see Sincovics’s academic work on such string use. It is true I need to make a better readme, but I wasn’t expecting the interest it got in certain grounds, I mostly authored this because I needed the standalone functionality for my own work in a very tight package. Technical analysis is available inside the header.

      In essence, it takes a string literal or an array with constant expression semantics representing a string literal and transforms it into a single type through the instantiation of a template whose char-typed non-type template parameters in the template parameter list are the characters of the string. Now imagine being able to parse that compile-time and generate code according to a “language” you yourself designed through TMP.