This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR c++/11987: why is it invalid?


Mark Mitchell <mark@codesourcery.com> writes:

> > ==================================================
> > template <int dim> struct X { 
> >     struct I { I(); }; 
> > }; 
> >  
> > template <int dim> struct Y : X<dim> { 
> >     typedef typename X<dim>::I I; 
> > }; 
> >  
> > template <int dim> 
> > Y<dim>::I::I () {}  // note: I is nested type in X, not Y! 
> >  
> > template struct Y<1>;
> > ==================================================

> I forget the chapter-and-verse, but the point is that I is nested in X,
> and so to *define* its constructor (as opposed to refer to it), you have
> to say X<dim>::I::I().

That makes sense, but just to make sure, is this restriction limited
to constructors (and presumably destructors)?  That is, is this
similar test case valid C++?  Here the code uses Y<dim> to define a
member function foo rather than defining the constructor.

==================================================
template <int dim> struct X { 
  struct I { I(); void foo(); }; 
}; 
 
template <int dim> struct Y : X<dim> { 
    typedef typename X<dim>::I I; 
}; 
 
template <int dim>
void Y<dim>::I::foo () {}

template struct Y<1>;
==================================================

Thanks.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]