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

G

Gary li

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.
 
V

Victor Bazarov

Gary said:
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
 
I

Ian Collins

Gary said:
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?
 
J

Jim Langston

Gary li said:
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.
 
S

Stuart Redmann

Gary said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top