This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
template member function not compiled
- To: gcc-bugs at gcc dot gnu dot org
- Subject: template member function not compiled
- From: Pierre Genilloud <pierre at itp dot phys dot ethz dot ch>
- Date: Mon, 3 Jan 2000 15:08:36 +0100 (CET)
Hi all,
the following example will not compile with gcc version 2.95.2,
under linux and solaris 2.6.
As far as I know, it should be supported by c++. It compiles under KCC.
more precisely:
g++ -D BUG_ test.C
gives:
test.C: In function `bool tt<false>(int)':
test.C:29: instantiated from here
test.C:21: invalid operands `{unknown type}' and `int' to binary `operator <'
test.C: In function `bool tt<true>(int)':
test.C:30: instantiated from here
test.C:21: invalid operands `{unknown type}' and `int' to binary `operator <'
g++ test.C
does not encounter the difficulty
-------------------------------------CODE:
#include <iostream.h>
class test {
int memb;
public:
test() : memb(0) {};
template <bool detection>
bool is( int i ) const {
return memb==(i+detection);
};
};
template <bool detect>
bool tt( int s ) {
test t;
return t.is<0>(s);
}
main() {
test t2;
cout << t2.is<0>(3);
#ifdef BUG_
cout << tt<0>(2);
#endif
};
------------------------------------------
This problem appeared in a real size program.
Avoiding it makes the code really messy and impairs performance.
So, I hope you can fix it soon :)
Best regards,
Pierre-Alain Genilloud
Institut for theoretical Physics
ETH-Hoenggerberg
8093 Zuerich
Switzerland