Ik snap iets niet
Comeau komt hier met de error:
typename weghalen helpt niet, zoals ook zou horen. Maar hoe kun je de compiler duidelijk maken dat dat een template type is?
Ook loopt ie nogal de soep in als je die InnerB als template class mee wilt geven als template argument:
Nu zegt ie dat nontype other::InnerB geen class template is. Als ik er typename voor zet begint ie te klagen over dat ie een identifier verwacht op de plaats waar typename staat.
Ik kan in de standaard verder ook weinig vinden.
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| struct B { typedef int int_type; template <class T> struct InnerB { }; }; struct G { typedef B other; }; template <class T> void func (const T &) { G::other b1; // ok typename T::other b2; // ok G::other::InnerB<int> ib; // ok typedef typename T::other other; // ok typename other::int_type i; // ok typename other::InnerB<int> b; // <-- fout! } int main () { B::InnerB<int> b; G::other::InnerB<int> b2; G g; func (g); return 0; } |
Comeau komt hier met de error:
code:
1
2
3
4
| error: template parameter "T::other::InnerB" may not have a
template argument list
typename other::InnerB<int> b;
^ |
typename weghalen helpt niet, zoals ook zou horen. Maar hoe kun je de compiler duidelijk maken dat dat een template type is?
Ook loopt ie nogal de soep in als je die InnerB als template class mee wilt geven als template argument:
C++:
1
2
3
4
5
6
7
8
| template <template <class> class T> struct A { }; template <class T> void func (const T &) { typedef typename T::other other; A<G::other::InnerB> a1; // ok A<other::InnerB> a2; // fout! } |
Nu zegt ie dat nontype other::InnerB geen class template is. Als ik er typename voor zet begint ie te klagen over dat ie een identifier verwacht op de plaats waar typename staat.
Ik kan in de standaard verder ook weinig vinden.
[ Voor 19% gewijzigd door .oisyn op 10-05-2003 01:40 ]
Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.