Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2005-04-15 05:12:12

Hi Community,

The Function Types library has just been updated to include an
implementation of closure functions as an example:

    [ example (hpp): ]
    [ exmaple (cpp): ]

You need to have the Function Types library installed if you want to
successfully compile it:

    [ archive (zip): ]
    [ documentation: ]

A closure function (in object orientated context) is a member function
bound to an object.

Closure functions are well-suited to achieve orthogonal design because
they capture member functions independent of their name and class an
thus allow to operate on a per-function basis instead of requiring
inheritance to e.g. implement classic design patterns such as "Observer".

In contrast to Boost.Bind (and other Boost argument binding facilities)
   closures are intended to be stored and allow the captured target
function to dynamically change at runtime.

Out of curiosity I was wondering if there is a closure function
implementation in Boost already (or components that make their
implementation trivial - IIRC I have seen something labeled 'closure' in
the vault, but I can't find it anymore), whether there is any interest
in brushing it up to give it a right to exist somewhere outside an
'example' folder and what requirements you would like it to meet in this

I know there are "closures" in Boost.Phoenix, but these are about
capturing fields, which is not quite the same and why I used the term
"closure function" instead of "closure" here.

What I describe here is close to the BCC compiler extension '__closure',
   which is used by C++Builder IDE to easily map GUI (and other) events
to member functions.



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