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: g++ rejects legal?


On Thu, 4 Nov 2004, Richard Guenther wrote:

> Hi!
>
> There must be some weird C++ rules again.  Consider:

Simpler testcase:

template <class E, class C>
struct CompFwd;

struct Brick;

template <int Dim, class T, class EngineTag>
struct Engine;

template <int Dim, class T, class E>
class Array;

template <class Subject>
struct ComponentView;

template<int Dim, class T, class EngineTag>
struct ComponentView<Array<Dim, T, EngineTag> >
{
  typedef Array<Dim, T, EngineTag> Subject_t;
  typedef typename Subject_t::Engine_t Engine_t;
  typedef Array<Dim, T, CompFwd<Engine_t, int> > Type_t;
};

template <int Dim, class T, class EngineTag>
struct Array
{
  typedef Engine<Dim, T, EngineTag> Engine_t;
  typedef Array<Dim, T, EngineTag> This_t;

  typename ComponentView<This_t>::Type_t
  comp(int i1) const;
};

typedef Array<1, double, Brick> Array_t;
//typedef Array_t::Engine_t Dummy1_t;
//typedef Engine<1, double, Brick> Dummy2_t;
typedef ComponentView<Array_t>::Type_t CView_t;


tests> g++-3.4 -c notype.cpp
notype.cpp: In instantiation of `Array<1, double, Brick>':
notype.cpp:19:   instantiated from `ComponentView<Array_t>'
notype.cpp:36:   instantiated from here
notype.cpp:30: error: no type named `Type_t' in `struct
ComponentView<Array_t>'


uncommenting the Dummy1_t typedef fixes the testcase, uncommenting the
Dummy2_t one not.

Richard.


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