Passing const char* as template argument

Because this would not be a useful utility. Since they are not of the allowed form of a template argument, it currently does not work.

Let’s assume they work. Because they are not required to have the same address for the same value used, you will get different instantiations even though you have the same string literal value in your code.

lols<"A"> n;

// might fail because a different object address is passed as argument!
lols<"A"> n1 = n;

You could write a plugin for your text editor that replaces a string by a comma separated list of character literals and back. With variadic templates, you could “solve” that problem this way, in some way.

Leave a Comment