template problem with MIPSpro compiler



 DEVELOP > c-Plus-Plus > template problem with MIPSpro compiler

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1
Topic: DEVELOP > c-Plus-Plus
User: "r5"
Date: 28 May 2004 02:16:31 PM
Object: template problem with MIPSpro compiler
I'm using the MIPSpro Compiler and having trouble defining
a function template (involving array size specifiers as
template arguments) inside a class. The same definition
compiles fine outside the class. I have listed a short
sample code and resulting error messages at the end of
this posting.
Is there a known work-around that fixes this "inside
the class" problem for SGI compilers -- short of
upgrading beyond v7.2.1?
One final note, the code below compiles and runs
correctly with g++. Thanks.
//////////////// junk.C ////////////////
#include <iostream.h>
template <typename T, size_t N>
size_t count1(T (&array)[N] )
{
return N;
}
class A {
public:
template <typename T, size_t N> size_t count2(T (&array)[N]);
};
template <typename T, size_t N> size_t A::count2(T (&array)[N])
{
return N;
}
int main()
{
A a;
int b[3];
cerr << count1(b) << " " << a.count2(b) << endl;
return 0;
}
////////////////////////////////
% CC -version
MIPSpro Compilers: Version 7.2.1
% CC -n32 junk.C
"junk.C", line 12: error(1424): constant "N" is not used in declaring the
parameter types of function template "A::count2"
template <typename T, size_t N> size_t count2(T (&array)[ N ] );
^
"junk.C", line 16: error(1424): constant "N" is not used in declaring the
parameter types of function template "A::count2"
template <typename T, size_t N> size_t A::count2(T (&array)[N] )
^
"junk.C", line 27: error(1278): no instance of function template "A::count2"
matches the argument list
argument types are: (int [3])
cerr << count1(b) << " " << a.count2(b) << endl;
^
3 errors detected in the compilation of "junk.C".
.

 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER