This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-05-06


544. Base class lookup in explicit specialization

Section: 13.8.3  [temp.dep]     Status: NAD     Submitter: John Spicer     Date: 01 November 2005

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()?

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.