A C++11 technique for encoding string literals as unique types using variadic templates, constexpr functions, and preprocessor macros. The approach builds a t_string template parameterized on individual characters, uses a constexpr at() function to index string literals at compile time, and chains append template members to

5m read timeFrom playfulprogramming.com
Post cover image
Table of contents
constexpr and the preprocessor to the rescue! Copy link Link copied!Generalizing on length Copy link Link copied!Getting rid of those zeroes Copy link Link copied!Conclusion Copy link Link copied!

Sort: