is this standard C++?
noelkeen
ndk@soybean.llnl.gov
Mon Mar 13 18:01:00 GMT 2000
template<class T, T& (*FP)(T&)>
class Foo {
public:
Foo(const T& x) : t(x) {}
template <class T2, T2& (*FP2)(T2&)>
Foo(const Foo<T2, FP2>& x) : t(x.t) {}
T t;
};
double& goo(double& d) { return d; }
const double& const_goo(const double& d) { return d; }
// Following explicit instantiation of function causes compiler error:
//template
//Foo<const double, const_goo>::Foo(const Foo<double, goo>& foo);
int main() {
Foo<double, goo> foo(0.0);
// Use templated constructor with arguments T2=double and FP2=goo:
//Foo<const double, const_goo>::Foo(const Foo<double, goo>& foo)
Foo<const double, const_goo> const_foo(foo);
}
This compiles with KCC and the DEC native compiler (cxx).
But does not compile with g++ (2.95.2 or the feb28th snapshot)
or with a beta version of IBM's xlC compiler. We can't
find anything non-standard with it.
thanks ooodles
noel
ps i'm not on the mailing list, so CC'ing would be rainbowish :)
More information about the Gcc
mailing list