Boost logo

Boost :

Subject: Re: [boost] An analogue of boost.function with multiple signatures
From: Marco (mrcekets_at_[hidden])
Date: 2009-03-05 19:35:14

Hello Jiøí,
you can find two implementations of multi functions in the boost vault by Marco Costalba


overload-mrcec/ by me

About the last one you can read a tutorial here:

Some remark:

(1) I don't know if they can interoperate with boost::lamba,
you should give it a try.

Using my implementation you can get what you're interested in
with the following code:

struct doubler
    template< typename T>
    T operator() (const T& x)
        return x + x;

boost::overload< std::string (std::string),
                  float (float),
                  unsigned (unsigned)
> mf;

(2) they are not extensions of boost function but separate libraries.

Kind regards,

On Fri, 06 Mar 2009 00:44:23 +0100, Jiøí Paleèek <jpalecek_at_[hidden]> wrote:

> Hello,
> I'd like to have an object similar to boost::function, but with multiple
> function signatures. Eg. something like that
> multifunction<std::string(std::string), float(float),
> unsigned(unsigned)> mf;
> mf=_1 + _1; // I mean boost::lambda::_1
> mf("ab"); // should be "abab"
> mf((UINT_MAX/2)+1); // should be 0
> mf((UINT_MAX/2)+1.0); // should be UINT_MAX+1.0
> Would it be possible/feasible to change boost::function to allow this (as
> opposed to implementing it separately from boost::function)? Was
> something like this even proposed before (I vaguely recall something,
> but couldn't
> google anything useful, so I may be wrong)?
> Regards
> Jiri Palecek

Using Opera's revolutionary e-mail client:

Boost list run by bdawes at, gregod at, cpdaniel at, john at