|
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
msf-1.2.2.zip by Marco Costalba
and
overload-mrcec/overload-0.3.0.zip by me
About the last one you can read a tutorial here:
http://docs.google.com/Doc?id=dfxvjncs_1x6456m
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;
mf.set(doubler);
mf("ab");
mf((UINT_MAX/2)+1);
mf((UINT_MAX/2)+1.0);
(2) they are not extensions of boost function but separate libraries.
Kind regards,
Marco
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: http://www.opera.com/mail/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk