Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-02-04 07:59:34

I think that if we add another template parameter to boost::function,
Storage, with requirements that (1) sizeof(Storage) >= sizeof(void*), (2) an
object of type Storage always has the correct alignment for every type T
such that sizeof(T) <= sizeof(Storage), then (a) the implementation of
boost::function could be simplified, and (b) it will provide nothrow
guarantees for function objects smaller than Storage.

The default Storage would be something similar to max_align_t, i.e.

union default_storage
    void * pv;
    void (*pf) ();
    void (A::*pmf) ();
    double d;
// etc

    // bind(&A::f, this)
    struct B
        struct F
            void (A::*pmf2) ();
        } f;

        struct L
            A * p2;
        } l;
    } b;

Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at, gregod at, cpdaniel at, john at