Boost logo

Boost Users :

From: Daniel Wallin (dalwan01_at_[hidden])
Date: 2004-12-29 11:00:25

Aleksey Gurtovoy wrote:
> David Abrahams writes:
>>Hum. Seems a bit counterintuitive that protect doesn't apply equally
>>well to this case.
> ??? As I tried to explain in my previous reply, 'protect' already has a
> well-defined semantics in lambda expressions, and it's quite different
> from what is needed to support "nested scopes". It would be nice to have
> a single magic primitive that would work the way you want it to work
> depending on the particular use case at hand, but I for one have no
> knowledge of how to implement one.

I'm sorry if I'm being thick here, but I can't grasp this. To me protect
 looks exactly like what is needed here. I have always thought of
protect as delaying the placeholder substitution one step, so that:

  typedef fold<
    , map_types
    , copy<
        , inserter<_1, protect<push_back<_1, _2> > >
>::type result;

Would work. Changing the protect specialization in


to this:

  template< typename T, typename Tag >
  struct lambda< mpl::protect<T>,Tag, int_<1> >
      typedef false_ is_le;
      typedef T result_;
      typedef result_ type;

Makes protect work like I thought it did, and makes the above compile. I
don't really understand the workings of lambda, so this probably breaks
something else. So what am I missing? Why can't it work like this?

Daniel Wallin

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at