467,922 Members | 1,364 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,922 developers. It's quick & easy.

why it isn't compiled about "template< template<class> class T>"

Hi, all
I find "template template" class cann't been compiled in VC6 but can ok
in Redhat9. I write a test program like as:
template< template<class> class T>
class A
{
};
int main()
{
return 0;
}
compiling failed for message:
D:\my_projects\testcpp\main.cpp(3) : error C2954: template definitions
cannot nest
D:\my_projects\testcpp\main.cpp(3) : error C2951: template declarations
are only permitted at global or namespace scope
D:\my_projects\testcpp\main.cpp(3) : error C2226: syntax error :
unexpected type 'T'
D:\my_projects\testcpp\main.cpp(5) : error C2143: syntax error :
missing '>' before '{'
D:\my_projects\testcpp\main.cpp(6) : error C2059: syntax error : '<end
Parse>'

Who can explain the reason to me. Thanks very much.

Jun 29 '06 #1
  • viewed: 4686
Share:
4 Replies
Gary li wrote:
I find "template template" class cann't been compiled in VC6 [..]

Who can explain the reason to me. Thanks very much.


Have you looked at the release date of that compiler lately?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 29 '06 #2
Gary li wrote:
Hi, all
I find "template template" class cann't been compiled in VC6 but can ok
in Redhat9. I write a test program like as:

Who can explain the reason to me. Thanks very much.

Rather old and not very good compiler?

--
Ian Collins.
Jun 29 '06 #3
"Gary li" <li*************@sina.com> wrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Hi, all
I find "template template" class cann't been compiled in VC6 but can ok
in Redhat9. I write a test program like as:
template< template<class> class T>
class A
{
};
int main()
{
return 0;
}
compiling failed for message:
D:\my_projects\testcpp\main.cpp(3) : error C2954: template definitions
cannot nest
D:\my_projects\testcpp\main.cpp(3) : error C2951: template declarations
are only permitted at global or namespace scope
D:\my_projects\testcpp\main.cpp(3) : error C2226: syntax error :
unexpected type 'T'
D:\my_projects\testcpp\main.cpp(5) : error C2143: syntax error :
missing '>' before '{'
D:\my_projects\testcpp\main.cpp(6) : error C2059: syntax error : '<end
Parse>'

Who can explain the reason to me. Thanks very much.


VC6 is old. Get a newer compiler.
Jun 29 '06 #4
Gary li wrote:
Hi, all
I find "template template" class cann't been compiled in VC6 but can ok
in Redhat9. I write a test program like as:
template< template<class> class T>
class A
{
};
int main()
{
return 0;
}
compiling failed for message:
D:\my_projects\testcpp\main.cpp(3) : error C2954: template definitions
cannot nest
D:\my_projects\testcpp\main.cpp(3) : error C2951: template declarations
are only permitted at global or namespace scope
D:\my_projects\testcpp\main.cpp(3) : error C2226: syntax error :
unexpected type 'T'
D:\my_projects\testcpp\main.cpp(5) : error C2143: syntax error :
missing '>' before '{'
D:\my_projects\testcpp\main.cpp(6) : error C2059: syntax error : '<end
Parse>'

Who can explain the reason to me. Thanks very much.


Googling for C2954 yields the following link:
http://support.microsoft.com/kb/241940/en-us

Sadly enough, even the VC 7.0 compiler won't compile template template
arguments.

Regards,
Stuart
Jun 29 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jim in Arizona | last post: by
9 posts views Thread by PengYu.UT | last post: by
3 posts views Thread by =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.