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

2024-04-05


1429. Scope of a member template's template parameter

Section: 6.4.9  [basic.scope.temp]     Status: NAD     Submitter: James Widman     Date: 2011-12-09

Consider:

    struct A {
        struct B { typedef int X; };
    };

    template<class B> struct C : A {
        B::X q; // Ok: A::B.
        struct U { typedef int X; };
        template<class U>
            struct D;
    };

    template<class B>
    template<class U>
    struct C<B>::D {
        typename U::X r; // which U?
    };

    C<int>::D<double> y;

In the definition of D, U definitely needs to be in scope as soon as it's declared because it might have been used in subsequent template parameter declarations, or it might have been used in the id-expression that names the declared entity — just as B is used in C<B>::D. (So 6.4.9 [basic.scope.temp] does the right thing for that purpose.)

But it would be nice if the result of lookup did not depend on whether D's body appears lexically inside C's body; currently, we don't seem to have the wording that makes it so.

Rationale (October, 2012):

This example is covered by the wording in 13.8.2 [temp.local] paragraphs 7-8: the template parameter is found.