error while CC compiles templates

Hello!

I am stucked with the following problem.

I am trying to compile such piece of code:

template< template < class > class _Oper,

template<class, class> class _Meta, class _Dom > struct _UnClos;

GCC understands it perfectly and no errors iccure. While CC gives me such errors:

bash-2.03$ /opt/SUNWspro/bin/CC test.cc

"test.cc", line 9: Error: "," expected instead of "<".

"test.cc", line 9: Error: Type name expected instead of "<".

"test.cc", line 9: Error: "{" expected instead of ",".

-

Does anybody know why CC doesn't understand this?

[640 byte] By [dima.ru] at [2007-11-26 7:50:34]
# 1
What version of Sun C++ do you use? Sun C++ has supported template template arguments since Stusio 10 only.
Atanasyan at 2007-7-6 20:08:40 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
I use 5.8 Solaris and SUN Studio 5.8 respectively. Thanks.
dimaru at 2007-7-6 20:08:40 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

It look like I need complete test case from you to reproduce the problem. Simple test case works fine:

% cat test.cc

template< template < class > class _Oper, template<class, class> class _Meta, class _Dom > struct _UnClos;

int main()

{

}

% CC -V test.cc

CC: Sun C++ 5.8 Patch 121017-02 2006/04/19

c++filt: Sun C++ 5.8 2005/10/13

ccfe: Sun C++ 5.8 Patch 121017-02 2006/04/19

ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.482

Atanasyan at 2007-7-6 20:08:40 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4

Here is my test case:

-

bash-2.03$ cat test.cc

#include <stdio.h>

#include <iostream.h>

#include <map>

using namespace std;

typedef map<int, map><int, int> > ii_map;

template< template < class > class _Oper,

template<class, class> class _Meta, class _Dom > struct _UnClos;

int main(){

ii_map imap;

cout<<"Hello"<<endl;

return 0;

}

And here what I get:

bash-2.03$ /opt/SUNWspro/bin/CC -V test.cc

CC: Sun C++ 5.5 2003/03/12

ccfe: Sun C++ 5.5 2003/03/12

"test.cc", line 9: Error: "," expected instead of "><".

"test.cc", line 9: Error: Type name expected instead of "<".

"test.cc", line 9: Error: "{" expected instead of ",".

3 Error(s) detect

dimaru at 2007-7-6 20:08:40 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 5
Hm, let me repeat my question about compiler version. What version of Sun C++ do you use: 5.5 or 5.8? Sun C++ 5.5 is a very old version and it does not support template template arguments.
Atanasyan at 2007-7-6 20:08:40 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 6
Sorry, I made a mistake. So I have Solaris 5.8 with SUN C++ 5.5. I don't know whether this is correct version, but as I know this was installed from the same distro as Solaris itself. I've got that I have an old compiler, thanks for help.
dimaru at 2007-7-6 20:08:40 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 7

Solaris is not shipped with Sun compilers. If you have C++ 5.5, it was installed from a Sun Studio 8 installation CD (or possibly a copy of such an installation).

As Simon noted, support for template-template parameters was introduced in Sun Studio 10 (C++ 5.7).

You can get the current release, Sun Studio 11 (C++ 5.8) and use it for free. Download it here:

http://developers.sun.com/sunstudio/

clamage45 at 2007-7-6 20:08:40 > top of Java-index,Development Tools,Solaris and Linux Development Tools...