Boost logo

Boost :

From: Marco Costalba (mcostalba_at_[hidden])
Date: 2008-06-07 07:40:31


On Sat, Jun 7, 2008 at 3:17 AM, Giovanni Piero Deretta
<gpderetta_at_[hidden]> wrote:
>
> I think that Marco's MSF was an hibryd of both: it (always) performed
> type erasures and it could store different functions. Unfortunately it
> lacked direct support for polymorphic function objects and stored
> every function object in the overload set in a different
> boost::function, making the size of msf explode.

Well, " making the size of msf explode" it seems to me a little bit on
the scary side ;-)

Just to clear what we are taking about:

For NON polymorphic function objects or standard functions

sizeof(msf) = sizeof(boost::function) * num_signatures;

For polymorphic function objects

sizeof(msf) = sizeof(boost::function) * num_signatures + sizeof(pointer);

Note that this is INDEPENDENT of how many function objects you bind,
be them standard or polymorphic.

A different case is when you explicit ask boost::function to store a
COPY of your function object because of semantic purposes, but IMHO it
would be an error to consider it a size increase implementation
dependent because you explicit asked for a copy.

When you don't want to create copies of your objects you can always do
that and the size of MSF is always what is reported above.

Finally both with standard function objects and with polymorphic
function objects you can ask MSF (for semantic purposes) to create
only ONE copy of your object, so in ALL the cases the added size,
implementation dependent, is just what is written above no more no
less.

So I would dare to say that IMHO MSF does NOT lack (direct) support
for polymorphic function objects.

Thanks
Marco


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk