|
Boost : |
From: Jason House (jhouse_at_[hidden])
Date: 2003-03-04 15:10:26
James Curran wrote:
>
> Both the Standard & MSVC6 allow a (const char*) as a template parameter.
> What is rejected (by both) is a text literal parameter. For a non-type
> parameter, the value must be a constant across all translation units linked
> together, hence it must be defined extern.
>
> template <const char* S> SomeClass { ...};
>
> SomeClass<"YourParam"> NoGood;
>
> extern const char* MyParam = "MyParam";
> SomeClass<MyParam> Acceptable;
>
Thanks for the clarification... and that requirement does make sense.
I'll still be a pain in the butt and ask more questions :)
If I understand correctly, each file that uses SomeClass<MyParam> will
compile in its own version of SomeClass. Will a compiler remove the
duplicate versions and leave only one copy of SomeClass<MyParam>?
Another quesion:
if
template <const char *S> SomeClass { ...};
extern const char* MyParam_1 = "MyParam";
extern const char* MyParam_2 = "MyParam";
then would
typeof(SomeClass<MyParam_1>) == typeof(SomeClass<MyParam_2>)
be true?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk