Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-10-31 07:44:01


> However, I strongly prefer that we lobby for "typeof" instead of providing
> half-hearted solutions to some aspects of the general problem!

Oh, yes! If the next C++ doesn't have "typeof", I'm just going to sit down
and cry!

> So, you think that a special bind overload to support a closure would be a
> good thing; something between bind and mem_fn, that preserves the
signature
> of the member function but stores an object pointer along with it. (As a
> side note, I don't think it should be named 'bind' as its semantics are
> different. 'closure' perhaps?)

Actually, that's exactly what I was thinking of:
  t.OnTimer = closure(&x, &x::func);

> This is a feature that is often requested and reinvented.
>
> But. This is a situation where the tools influence your design. If you
start
> on a clean sheet, using bind/function from day one, you'll see that this
> feature is not so often needed as you previously thought.

I'm not so sure. In my code, I'm designing several layers of asynchronous
components, where each layer captures (most of, if not all of) the events of
the previous layer.

Not very efficient, but we need that reusability (each layer is templated on
the type of the underlying layer, so you have protocols independent of the
transport medium, etc).

> The reason for this is that the closure solution forces you to maintain
> compatible signatures, i.e. t.OnTimer and X::func must match.
>
> bind doesn't have this restriction. You can design the event interface
> (OnTimer) and the implementation (X::func) independently.

Actually, I hadn't thought of this before -- bind is even cooler than I
knew! :)

        -Steve


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