Title
Base class lookup in explicit specialization
Status
nad
Section
13.8.3 [temp.dep]
Submitter
John Spicer

Created on 2005-11-01.00:00:00 last changed 227 months ago

Messages

Date: 2006-04-15.00:00:00

Rationale (April, 2006):

An explicitly-specialized member of a class template is not, in fact, a member of a class template but a member of a particular specialization of that template. The special treatment of lookup vis-a-vis dependent base classes in 13.8.3 [temp.dep] thus does not apply, and base class members are found by unqualified name lookup.

Date: 2022-11-20.07:54:16

There is some question as to whether 13.8.3 [temp.dep] paragraph 3 applies to the definition of an explicitly-specialized member of a class template:

In the definition of a class template or a member of a class template, if a base class of the class template 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.

Consider an example like the following:

    template <class T>
    struct A {
     void foo() {}
    };

    template <class T>
    struct B: A<T> {
     int bar();
    };

    int foo() { return 0; }

    template <>
    int B<int>::bar() { return foo(); }

    int main() {
     return B<int>().bar();
    }

Does foo in the definition of B<int>::bar() refer to ::foo() or to A<int>::foo()?

History
Date User Action Args
2006-04-22 00:00:00adminsetmessages: + msg1375
2006-04-22 00:00:00adminsetstatus: open -> nad
2005-11-01 00:00:00admincreate