M
Marcel Müller
Hi,
from time to time I used something like
template <int I> class_or_function ...
This works fine.
Today I had the first case where
template <const char* C> foo();
...
foo<"LST">();
would be useful. Unfortunately the compiler dislikes it:
error: string literal "LST" is not a valid template argument because
it is the address of an object with static linkage
Why is this not allowed? The address of a static object is a constant.
And with this restriction I could never pass any string as template
argument, or die I miss something?
Marcel
from time to time I used something like
template <int I> class_or_function ...
This works fine.
Today I had the first case where
template <const char* C> foo();
...
foo<"LST">();
would be useful. Unfortunately the compiler dislikes it:
error: string literal "LST" is not a valid template argument because
it is the address of an object with static linkage
Why is this not allowed? The address of a static object is a constant.
And with this restriction I could never pass any string as template
argument, or die I miss something?
Marcel