CRTP nullary in derived conflicts with unary in base

Discussion in 'C++' started by er ci, Jul 24, 2010.

  1. er ci

    er ci Guest

    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 );
    }
     
    er ci, Jul 24, 2010
    #1
    1. Advertising

  2. er ci

    SG Guest

    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
     
    SG, Jul 24, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    11
    Views:
    460
    Steven Bethard
    Nov 16, 2005
  2. SpOiLeR
    Replies:
    10
    Views:
    823
    SpOiLeR
    Oct 19, 2005
  3. Replies:
    1
    Views:
    403
    myork
    May 23, 2007
  4. Replies:
    1
    Views:
    393
    Victor Bazarov
    May 23, 2007
  5. oor
    Replies:
    0
    Views:
    1,370
Loading...

Share This Page