Boost logo

Boost :

From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2003-03-04 15:33:37


At 01:10 PM 3/4/2003, Jason House wrote:

>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.

No. There must be only one definition of MyParam.

> 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?

Maybe.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk