[announce] Multi signature boost::function

Hi everybody, in Vault it is possible to download msf.zip, a (very small) file that contains multi-signature extension to boost::function It is possible to instantiate a boost::multi_signature_function::function on a mpl sequence of signatures and this object will behave as expected, in particular it keeps all the functionality of boost::function but allows to be called with different arguments types and/or number. Interested people could read (and compile) included test.cpp file, an example is better then 1000 words. If there is interest I can improve documentation and examples. Regards Marco P.S: This puppy should be compiler friendly, anyhow tested on g++ and MSVC

Marco Costalba wrote:
If there is interest I can improve documentation and examples.
I am definitely interested. I think it should be submitted for review. Some comments: 1. Does "reset" sound like a better name for "unset"? 2. How about providing a get<signature> method returning ref to the underlying boost::function object. - this facilitates interfacing with other API already using boost::function. - f.get<signature>() = 0; may be used instead of "unset". Regards, Joseph

On Sat, Apr 26, 2008 at 12:37 PM, Joseph Wu <josephclwu@yahoo.com> wrote:
Marco Costalba wrote:
If there is interest I can improve documentation and examples.
I am definitely interested. I think it should be submitted for review.
Some comments:
1. Does "reset" sound like a better name for "unset"?
boost::function uses clear(), should I use the same API for consistency?
2. How about providing a get<signature> method returning ref to the underlying boost::function object.
Yes, I'll add it. Thanks for your comments Marco

Hi, I'm interested too, On Sat, Apr 26, 2008 at 2:09 PM, Marco Costalba <mcostalba@gmail.com> wrote:
On Sat, Apr 26, 2008 at 12:37 PM, Joseph Wu <josephclwu@yahoo.com> wrote:
Marco Costalba wrote:
If there is interest I can improve documentation and examples.
I am definitely interested. I think it should be submitted for review.
Some comments:
1. Does "reset" sound like a better name for "unset"?
boost::function uses clear(), should I use the same API for consistency?
I'd suggest two overloads: clear<signature>() //for resetting the given signature and clear(); //for resetting everything
2. How about providing a get<signature> method returning ref to the underlying boost::function object.
Yes, I'll add it.
Thanks for your comments Marco
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- ________________ ::matus_chochlik

On Sat, 26 Apr 2008 14:54:07 +0200, Matus Chochlik <chochlik@gmail.com> wrote: If you are interested in a multi-signature Boost.Function, you can give a look to my Boost.Overload library: http://docs.google.com/View?docid=dfxvjncs_1x6456m The latest release is 5 months old now, but it's not too bad. I hope to restart working on it as soon as possible. Kind Regards, Marco Cecchetti
Hi,
I'm interested too,
On Sat, Apr 26, 2008 at 2:09 PM, Marco Costalba <mcostalba@gmail.com> wrote:
On Sat, Apr 26, 2008 at 12:37 PM, Joseph Wu <josephclwu@yahoo.com> wrote:
Marco Costalba wrote:
If there is interest I can improve documentation and examples.
I am definitely interested. I think it should be submitted for review.
Some comments:
1. Does "reset" sound like a better name for "unset"?
boost::function uses clear(), should I use the same API for consistency?
I'd suggest two overloads:
clear<signature>() //for resetting the given signature and clear(); //for resetting everything
2. How about providing a get<signature> method returning ref to the underlying boost::function object.
Yes, I'll add it.
Thanks for your comments Marco
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Marco Costalba wrote:
boost::function uses clear(), should I use the same API for consistency?
I like having clear() to mean clear all. And having empty() to mean all overloads are empty. For signature-based clear() and empty(), one would use get<signature>().empty() and get<signature>.clear(). But then, it is just me. Also, I've skimmed thru the implementation. It looks like that each signature is managed by an auto_ptr to a boost::function. How about "small-overload optimization" in that the boost::function objects for the first couple of signatures are stack-based (ideally based on the dynamic order of callables being set, which is not necessarily the same as the static order of signatures in the mpl sequence of signatures.) Regards, Joseph

On Sun, Apr 27, 2008 at 4:27 AM, Joseph Wu <josephclwu@yahoo.com> wrote:
Marco Costalba wrote:
boost::function uses clear(), should I use the same API for consistency?
I like having clear() to mean clear all. And having empty() to mean all overloads are empty. For signature-based clear() and empty(), one would use get<signature>().empty() and get<signature>.clear().
But then, it is just me.
I'm a little bit not sure about this but anyway I have applied your proposed changes the same as an added bonus to have reviewed my code ;-)
Also, I've skimmed thru the implementation. It looks like that each signature is managed by an auto_ptr to a boost::function.
Yes!! I completely missed this! Thanks a lot for this important suggestion. What happened is that auto_ptr was necessary in some previous code of mine that used an home grown function instead of boost::function. Now a pointer is no more necessary and we can simply store boost::function object as class member data. I have upload in Vault the new much better (but even smaller) version that I start to consider stable so I have called msf_27_4_2008.zip Thanks Marco

Ok I have uploaded in Vault a new version of msf.zip with included the feedback from Joseph and Matus.
1. Does "reset" sound like a better name for "unset"?
Added clear<signature>() for consistency with boost::function Added clear_all() to clear all functions in one go.
2. How about providing a get<signature> method returning ref to the underlying boost::function object.
Added.
Added also an example on how multi signature function supports copy semantic Thanks everybody, more feedback welcomed Marco
participants (4)
-
Joseph Wu
-
Marco
-
Marco Costalba
-
Matus Chochlik