Boost logo

Boost Users :

Subject: Re: [Boost-users] generic programming : variadic virtual function
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-08-27 18:00:48


On Thu, Aug 27, 2009 at 6:04 AM, Bruno Lalande<bruno.lalande_at_[hidden]> wrote:
>> 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...

I actually had a rather identical problem as the first post, but I
solved it rather easily using Boost.Fusion building up a helper struct
to act as the operator().


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