Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2005-04-15 09:55:37

Tobias Schwinger wrote:
> 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.

Boost.Function stores the results of Boost.Bind, and already serves as a
"closure function".

> 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
> case.

See above.

> 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.

I am well aware of the BCC __closure having programmed with C++ Builder
for many years. I think that Boost.Function/Boost.Bind adequately
emulates it in standard C++, while providing richer functionality with a
slightly more complicated syntax.

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