template partial specializations
Rich Lee
llee1@lsc.nd.edu
Wed Jul 1 20:52:00 GMT 1998
Hello, egcs guys, I much appreciated to have such a great
compiler. Thanks you for your great work.
There is a problem for template partial specializations when I
compiled the code attached which can be correctly compiled by KCC 3.3.
The detail information is as follows:
gcc version egcs-2.91.43 19980628 (gcc2 ss-980502 experimental)
command
g++ tst.cc -o tst
Error messages:
tst.cc: In function `int main()':
tst.cc:59: type specifier omitted for parameter
tst.cc:59: parse error before `4'
tst.cc:60: request for member `print' in `c(...)', which is of non-aggregate type `A<vector<int,__default_alloc_template<false,0> >,int> ()(...)'
more config.status
#!/bin/sh
# This file was generated automatically by configure. Do not edit.
# This directory was configured as follows:
./configure --with-gcc-version-trigger=/afs/nd.edu/user22/llee1/src/egcs-1998062
1/gcc/version.c --host=sparc-sun-solaris2.6 --prefix=/afs/nd.edu/user22/llee1/le
e/egcs --enable-shared --norecursion
# using "mh-frag" and "mt-frag"
//source code
//tst.cc
#include <vector>
#if defined __KCC
using std::vector;
#endif
#include <iostream.h>
template < class T1, class T2>
class A {
public:
A(T1 a_, T2 b_) :
a(a_), b(b_)
{}
void print() {
cout << a << " "
<< b << endl;
}
private:
T1 a;
T2 b;
};
#if 1
template < class T2 >
class A <vector<T2>, T2> {
public:
A(vector<T2> a_, T2 b_) :
a(a_), b(b_)
{}
void print() {
cout << "It is a vector "
<< b << endl;
}
private:
vector<T2> a;
T2 b;
};
#endif
int main()
{
A<int, int> a(1, 2);
a.print();
A<char, int> b('A', 3);
b.print();
A<vector<int>, int> c(vector<int>(), 4);
c.print();
return 0;
}
More information about the Gcc-bugs
mailing list