Title
Scope of a member template's template parameter
Status
nad
Section
6.4.9 [basic.scope.temp]
Submitter
James Widman

Created on 2011-12-09.00:00:00 last changed 138 months ago

Messages

Date: 2012-10-15.00:00:00

Rationale (October, 2012):

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

Date: 2022-11-20.07:54:16

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.

History
Date User Action Args
2012-11-03 00:00:00adminsetmessages: + msg4172
2012-11-03 00:00:00adminsetstatus: open -> nad
2011-12-09 00:00:00admincreate