Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > CRTP nullary in derived conflicts with unary in base

Reply
Thread Tools

CRTP nullary in derived conflicts with unary in base

 
 
er ci
Guest
Posts: n/a
 
      07-24-2010
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 );
}
 
Reply With Quote
 
 
 
 
SG
Guest
Posts: n/a
 
      07-24-2010
On 24 Jul., 20:07, er ci wrote:
> Could someone please shed light on the cause of the error below,
> and perhaps hint at a solution?


See C++ FAQ Lite 23.8 and 23.9.

Cheers!
SG
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CRTP-problem: How can the base class typedef a derived class' typedef? oor C++ 0 05-20-2008 12:39 PM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 01:44 PM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 12:07 AM
derived / base class name conflicts christopherlmarshall@yahoo.com Python 11 11-16-2005 05:47 PM
Ordinary unary function to STL adaptable unary predicate how? SpOiLeR C++ 10 10-19-2005 01:18 PM



Advertisments