[cfe-dev] Error name lookup in template dependant base class

Adrien Chauve adrien.chauve at gmail.com
Wed Dec 15 12:35:17 PST 2010


I just tested with intel c++ compiler 12.
Indeed, the compilation fails when using the "-strict-ansi" option.

Thanks,
Adrien

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
> convinced!!
>
> Is it a known error in "C++ Templates: The Complete Guide", or am I getting
> it wrong?
>
> Thanks again,
> Adrien
>
> 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 definition of a class or class template, if a base class depends on
> a template-parameter, the base class
> scope is not examined during unqualified name lookup either at the point of
> definition 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
>> considered:
>> >  — Declarations that are visible at the point of definition of the
>> template.
>> >  — 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.
>>
>> John.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101215/d7268f01/attachment.html>


More information about the cfe-dev mailing list