Boost logo

Boost :

From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-05-09 21:17:25


On Fri, May 9, 2008 at 8:50 PM, Marco Costalba <mcostalba_at_[hidden]> wrote:
> Hi all,
>
> this is the first official version of multi-signature
> boost::function extension (MSF) pushed to Boost Vault under the name
> msf-1.0.zip
> [...]
> This library extension, although flexible and IMHO powerful is notably
> very simple and small, so I would like to ask if someone is interested
> to add this code in some way directly to boost.function
>

While useful, I do not think this library belongs in boost function
(which is monomorphic),
but it should be a library of its own.

A couple of questions:

1) can you dispatch on the dynamic type of an object? I.e.

struct Base { virtual ~Base() {} };

struct A : Base {};
struct B : Base {};

void foo1(A&);
void foo2(B&);

f = foo1;
f = foo2;

A a;
B b;
foo((Base&)a); // calls foo1
foo((Base&)b); // calls foo2

Generalizing this to multiple arguments you of course get multiple dispatch.

2) If I have a polymorphic function object, can I store a single
instance of this object
and specify multiple signatures? i.e.

struct foo_t { template<class T> void(T){...} } foo;

f = foo; // foo will respond to all signatures known to f

-- 
gpd

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