Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > template problem with MIPSpro compiler

Reply
Thread Tools

template problem with MIPSpro compiler

 
 
r5
Guest
Posts: n/a
 
      05-28-2004
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(127: 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".
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IRIX MipsPro compiler chokes on Python.h Bram Stolk Python 4 05-25-2005 04:15 PM
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
what to do with template classes in template unsupported compiler ? Shlomi C++ 5 05-20-2004 07:42 AM
Compiling MIPSpro C program using MIPSpro C++ compiler on SGI system Christopher M. Lusardi C++ 4 05-13-2004 04:17 PM
Problem using IRIX 6.5 CC (MIPSPro C++) STL I/O w/ POSIX threads Evan David Light C++ 6 12-01-2003 06:29 PM



Advertisments