Boost logo

Boost :

From: Alexander Nasonov (alnsn-mycop_at_[hidden])
Date: 2003-02-18 08:31:54


With a help of boost::dynamic_any::call operation (not yet implemented) it's
possible to use boost::dynamic_any::any instead of Boost.Function. Though
this new solution is less specialized and probably slower then
Boost.Function it has one advantage demonstrated in the example below:

typedef boost::dynamic_any<
    boost::mpl::list<
        boost::dynamic_any::call<void (int &)>,
        boost::dynamic_any::call<void (double &)>
>
> flexible_function; // 2 in 1!

int main()
{
    flexible_function f;
    f = ++_1; // increment for int and double

    int i = 2;
    f(i); // ++i

    double d = 3;
    f(d); // ++d
}

-- 
Alexander Nasonov
Remove - m y c o p from my e-mail address for timely response

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