Template instantiation and string vs const char[]

JR via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 3 00:38:52 PDT 2014


On Wednesday, 3 September 2014 at 05:18:42 UTC, Jason den Dulk 
wrote:
[...]

While not really answering your question, I believe the idiomatic 
way is to use enum here instead of string/char[].

Conjecture: strings are final but the symbol can be redirected to 
point to new arrays, such as results of concatenations. 
Concatenations create new and unique arrays upon each operation 
as each by definition cannot be altered. char[] can be *appended* 
to, technically retaining the same array and merely reallocating 
(potentially moving) to fit the extra content.

This sounds like something the compiler should be able to work 
around but apparently it doesn't.

Also, note that your check of (R.length) will only evaluate to 
false if the template is instantiated as somet!().


More information about the Digitalmars-d-learn mailing list