CRTP nullary in derived conflicts with unary in base

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 );
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top