[cfe-dev] Error name lookup in template dependant base class
adrien.chauve at gmail.com
Wed Dec 15 14:35:17 CST 2010
I just tested with intel c++ compiler 12.
Indeed, the compilation fails when using the "-strict-ansi" option.
On Wed, Dec 15, 2010 at 21:24, Adrien Chauve <adrien.chauve at gmail.com>wrote:
> Ok then, thank you very much John and Matt for your answers. I'm
> Is it a known error in "C++ Templates: The Complete Guide", or am I getting
> it wrong?
> Thanks again,
> P.S.: Matt, it seems that you replied only to me, but your quote was really
> nice so I copy it here:
> From the standard [temp.dep]:
> " In the deﬁnition of a class or class template, if a base class depends on
> a template-parameter, the base class
> scope is not examined during unqualiﬁed name lookup either at the point of
> deﬁnition of the class template
> or member or during an instantiation of the class template or member"
> On Tue, Dec 14, 2010 at 23:05, John McCall <rjmccall at apple.com> wrote:
>> On Dec 14, 2010, at 2:01 PM, John McCall wrote:
>> > On Dec 14, 2010, at 1:33 PM, Adrien Chauve wrote:
>> >> I don't think the problem is ADL here. The name of the function call is
>> a dependant name, so the unqualified lookup is delayed until instanciation:
>> it's not ADL, it's just delayed ordinary lookup. At instanciation time and
>> when all explicit template specializations are available, lookups can be
>> done in the base class to find members.
>> > Well, no, they can't. This is what we're all trying to explain. The
>> standard is extremely explicit about this:
>> > C++ [temp.dep.res]p1:
>> > In resolving dependent names, names from the following sources are
>> > — Declarations that are visible at the point of definition of the
>> > — Declarations from namespaces associated with the types of the
>> function arguments both from the instantiation context and from the
>> definition context.
>> This is actually not the part of the standard I meant to quote, although
>> it does apply. The better quote is [temp.dep.candidate]p1:
>> For a function call that depends on a template parameter, the candidate
>> functions are found using the usual lookup rules except that:
>> — For the part of the lookup using unqualified name lookup or qualified
>> name lookup, only function declarations from the template definition context
>> are found.
>> — For the part of the lookup using associated namespaces, only function
>> declarations found in either the template definition context or the template
>> instantiation context are found.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev