[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Is it g++ bug with "typename"?
From: |
Grizlyk |
Subject: |
Is it g++ bug with "typename"? |
Date: |
Sun, 11 Mar 2007 09:56:50 +0300 |
Hello.
I am thinking: why if i will comment lines marked with '#' in the following
example, all will be compiled, else will not:
// ***********************
typedef unsigned uint;
namespace Pxx{
template <
class Tobj,
class c_Second,
class Tuint=uint
>
class First
{
public:
typedef c_Second Second;
typedef typename c_Second::Third Third; //#1
typedef typename c_Second::Forth Forth; //#2
First(){}
inline explicit First(const Tuint);
public:
class Tfriend
{
public:
public:
mutable First *parent;
void
operator= (const First *const p)const
{ parent=const_cast<First*>(p); }
Tfriend():parent(0){}
Tfriend(const First& p):
parent(const_cast<First*>(&p))
{}
};
};}
// ***********************
namespace Pxx{
template <
class Tobj,
class c_First,
class c_Forth,
class c_Third,
class Tuint=uint
>
class Second
{
public:
typedef c_First First;
typedef c_Forth Forth;
typedef c_Third Third;
//derived Second
typedef typename c_First::Second c_Second;
Second(){}
inline Second(const First&);
};}
// ***********************
// ***********************
namespace Pxx{
namespace Puser{
// ***********************
template <class Tobj,class Tuint> class First;
template <class Tobj,class Tuint> class Second;
template <class Tobj,class Tuint> class Third;
template <class Tobj,class Tuint> class Forth;
// ***********************
template <
class Tobj,
class Tuint=uint
>
class First:
public Pxx::First<
Tobj,
Second<Tobj,Tuint>,
Tuint
>
{
typedef Pxx::First<
Tobj,
Second<Tobj,Tuint>,
Tuint
>
Tparent;
public:
typedef typename Tparent::Second Second;
First(){}
explicit First(const Tuint p):Tparent(p){}
};
// ***********************
template <
class Tobj,
class Tuint=uint
>
class Second:
public Pxx::Second<
Tobj,
First<Tobj,Tuint>,
Forth<Tobj,Tuint>,
Third<Tobj,Tuint>,
Tuint
>
{
typedef Pxx::Second<
Tobj,
First<Tobj,Tuint>,
Forth<Tobj,Tuint>,
Third<Tobj,Tuint>,
Tuint
>
Tparent;
public:
typedef typename Tparent::First First;
Second(){}
Second(const First& p):Tparent(p){}
};
//namespace Puser
}
//namespace Pxx
}
using Pxx::Puser::First;
using Pxx::Puser::Second;
// ***********************
// ***********************
First<int> first(100);
Second<int> second(first);
=============
Output
11.cpp: In instantiation of
'Pxx::Second<int,
Pxx::Puser::First<int, unsigned int>,
Pxx::Puser::Forth<int, unsigned int>,
Pxx::Puser::Third<int, unsigned int>,
unsigned int>':
11.cpp:113: instantiated from
'Pxx::Puser::Second<int, unsigned int>'
11.cpp:14: instantiated from
'Pxx::First<int,
Pxx::Puser::Second<int, unsigned int>,
unsigned int>'
11.cpp:86: instantiated from
'Pxx::Puser::First<int, unsigned int>'
11.cpp:141: instantiated from here
11.cpp:57: error: no type named 'Second' in 'class
11.cpp:57: error: Pxx::Puser::First<int, unsigned int>'
--
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new
- Is it g++ bug with "typename"?,
Grizlyk <=