|
Boost : |
From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2005-06-29 09:12:17
Christoph Ludwig wrote:
> On Wed, Jun 29, 2005 at 02:52:12PM +0200, Markus Schöpflin wrote:
>>Christoph Ludwig wrote:
>>>Section 10.5:
>>> The standard also specifies that there can be at most one explicit
>>> instantiation of a certain template specialization in a
>>> program. Furthermore, if a template specialization is explicitly
>>> instantiated, it should not be explicitly specialized, and vice versa.
>>
>>I can't find anything in the standard (14.7) indicating this.
> OK, I overcame my laziness :-) It is 14.7p5:
>
> No program shall explicitly instantiate any template more than once, both
> explicitly instantiate and explicitly specialize a template, or specialize a
> template more than once for a given set of template arguments.
> An implementation is not required to diagnose a violation of this rule.
>
> I admit I find Vandvoorde's and Josuttis' phrasing much easier to grok.
Duh, I read 14.7.2 and 14.7.3 over and over and I completely missed that
one. :-(
Hmm, now I'm left wondering how in general to deal with this issue. Would
this be legal?
---%<---
template <class T>
struct foo {
static T bar() { static T t; return t; }
};
template<> foo<int>;
template int foo<int>::bar();
--->%--
Time to ask the compiler vendor on how to avoid multiple copies of t here,
I think.
Thanks, Markus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk