 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
tpochep@mail.ru Guest
|
Posted: Fri Jul 08, 2005 10:33 am Post subject: friend member-template class |
|
|
Hello.
I have example of ill-formed(???) code.
template<class T>
class Enclose {
public:
template<class T1>
class Nested0 {
template<class T2>
friend class Nested0;
};
class Nested1 : public Nested0<T>{};
};
int main()
{
Enclose<int>::Nested1 a;
}
g++ (and VC 7.1) can compile it.
Comeau online:
"ComeauTest.c", line 7: error: template nesting depth does not match
the previous
declaration of class template "Enclose<T>::Nested0 [with
T=int]"
friend class Nested0;
^
detected during:
instantiation of class
"Enclose<T>::Nested0<T1> [with T=int, T1=int]" at
line 9
instantiation of class "Enclose<T>::Nested1 [with T=int]"
at line
14
Ok, I can fix it:
template<class T>
class Enclose {
public:
template<class T1>
class Nested0 {
template<class T2>template<class T3>
friend class Enclose<T2>::Nested0;
};
class Nested1 : public Nested0<T>{};
};
int main()
{
Enclose<int>::Nested1 a;
}
Now, it's compilable by como.
The question is: does standard define such behavior and where (if it
does) ?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|