Title
Incompletely-defined class template base
Status
drafting
Section
13.8.3.2 [temp.dep.type]
Submitter
Jason Merrill

Created on 2012-07-17.00:00:00 last changed 146 months ago

Messages

Date: 2012-10-15.00:00:00

Notes from the October, 2012 meeting:

CWG determined that the example should be ill-formed.

Date: 2012-07-17.00:00:00

The correct handling of an example like the following is unclear:

  template<typename T> struct A {
    struct B: A { };
  };

A type used as a base must be complete (11.7 [class.derived] paragraph 2) . The fact that the base class in this example is the current instantiation could be interpreted as indicating that it should be available for lookup, and thus the normal rule should apply, as members declared after the nested class would not be visible.

On the other hand, 13.8.3 [temp.dep] paragraph 3 says,

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.

This wording refers not to a dependent type, which would permit lookup in the current instantiation, but simply to a type that “depends on a template-parameter,” and the current instantiation is such a type.

Implementations vary on the handling of this example.

(See also issue 1526 for another case related to the distinction between a “dependent type” and a “type that depends on a template-parameter.”)

History
Date User Action Args
2012-11-03 00:00:00adminsetmessages: + msg4109
2012-11-03 00:00:00adminsetstatus: open -> drafting
2012-07-17 00:00:00admincreate