Boost logo

Boost :

From: James Curran (jamescurran_at_[hidden])
Date: 2003-03-04 15:53:01


Jason House wrote:
> 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>?

    I believe that would be a Quality of Implementation issue. A compiler
would merge them if it were to merge multiple copies of any templated class.

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

    I guess the correct answer here is "Not Necessarily". Remember that
the template is using the char*, not the text literal, as it's parameter. A
compiler may pool the identical text literals and have both MyParam_1 and
MyParam_2 point to the same address (inwhich case that expresion would be
true), but it's not required to.

--
Truth,
James Curran
www.noveltheory.com (personal)
www.njtheater.com (professional)

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