C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

friend member-template class

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
tpochep@mail.ru
Guest





PostPosted: Fri Jul 08, 2005 10:33 am    Post subject: friend member-template class Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.