
On Tue, Dec 14, 2010 at 6:14 PM, Dave Abrahams <dave@boostpro.com> wrote:
At Tue, 14 Dec 2010 15:35:04 +0800, Dean Michael Berris wrote:
I don't see an obvious problem here in terms of ODR here because you are using a template -- which by definition still gets instantiated anyway across multiple translation units,
No, not by definition. EDG still has a link-time instantiation option.
Ah, I haven't had much experience with EDG and link-time template instantiation. Interesting, I haven't looked for that in other front-ends.
and is not required to have a single definition anyway.
That would be news to me! Do you have a reference?
Actually, I was referring to having the template have a single definition per translation unit. However, as you've pointed out, EDG has a link-time instantiation option for templates, which is also standards compliant behavior.
That said, if all the type difference occurs *within* the decltype *and* within the decltype there are no ODR violations, I *think* there is technically no ODR violation. But I suggest asking a real hard-core core-language expert on this one if you care about technical correctness.
That was what I was thinking too -- because Matt's relying on the decltype being the "discriminant" or the thing that differentiates it from other instantiations of the template, then it wouldn't technically be an ODR violation. I have to get my hands on the latest draft standard to see whether the ODR rules have changed for C++0x. Maybe those writing the compilers (and those involved in the standard committee and this section that are also in this list) can chime in and correct all of my mis-interpretations. ;)
The only worrying thing is that if the nested function invocation referred to has a static but non-extern linkage, and thus will be defined in multiple translation units -- some compilers issue a diagnostic on this occurrence although I forget if the standard requires that a diagnostic be emitted in cases where you have nested static functions in templates. Maybe those who actually know enough about the relevant sections of the standard can chime in.
If someone prepares a _minimal_ representative example of the question, I'll be happy to run it by someone who knows for you.
Let me see if I can come up with a simple C++03 example to illustrate what I meant above. :) -- Dean Michael Berris deanberris.com