E
er ci
Could someone please shed light on the cause of the error below, and
perhaps hint at a solution? I used Mac OSX 10.6 -- GCC 4.2. Thanks.
template<typename D>
struct crtp{
template<typename T>
void fun(T const& x)const{
static_cast<D const&>(*this).template impl<T>(x);
}
};
struct foo : crtp<foo>{
foo(){}
// uncommenting causes compile error
// no matching function for call to 'foo::fun(int)'
// candidates are: void foo::fun() const
// void fun()const{}
template<typename T>
void impl(T const& x)const{}
};
int main (int argc, char * const argv[]) {
foo f;
f.fun( 1 );
}
perhaps hint at a solution? I used Mac OSX 10.6 -- GCC 4.2. Thanks.
template<typename D>
struct crtp{
template<typename T>
void fun(T const& x)const{
static_cast<D const&>(*this).template impl<T>(x);
}
};
struct foo : crtp<foo>{
foo(){}
// uncommenting causes compile error
// no matching function for call to 'foo::fun(int)'
// candidates are: void foo::fun() const
// void fun()const{}
template<typename T>
void impl(T const& x)const{}
};
int main (int argc, char * const argv[]) {
foo f;
f.fun( 1 );
}