Boost logo

Boost Users :

Subject: Re: [Boost-users] generic programming : variadic virtual function
From: Bruno Lalande (bruno.lalande_at_[hidden])
Date: 2009-08-27 08:04:07


> Yes, in fact after I found no answers in my mailbox this morning I
> noodled on the problem some more and came up with that solution.  The
> difficulty is that there is a lot of non-variadic cruft common to the
> general and specialized template classes. I didn't want to repeat all of
> that.

Another way to solve that could be to isolate the variadic stuff if a
class (named "foo" below):

template <typename S, typename W>
class foo
{
    void operator()(S, W);
};

template <typename S>
class foo<S, void>
{
    void operator()(S);
};

template <typename S, typename W>
class derived:
    public foo<S, W>,
    public baseclass<S, W>
{
    // common non-variadic stuff
};

If I remember the C++ rules well, the operator() in "foo" would
properly override the virtual operator() of "baseclass" in "derived".

You can use a CRTP if "foo" needs anything in "derived" for its
implementation...

Bruno


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net