From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-02-07 16:06:51
> Well, I was unable to compile with gcc 3.0.3 (cygwin) and 2.95.3
> (mingw). All test I've tried gave the same errors:
> The offending line in actions.hpp is
> BOOST_STATIC_CONSTANT(bool, value =
> (boost::is_base_and_derived<protectable, T>::value));
> I'm using boost v 1.26.0. Do I need the current CVS sources?
Oh yes. is_base_and_derived was only added in January. :(
> " ... the lambda expression _1 + 1 can be seen as syntactic sugar
> for the pseudo code bind(operator+, _1, 1). "
> Should be "... the lambda expression 1 + _1 ...". This way the order
> of arguments is the same for both expressions. Note that you later
> define an asymmetric operator+ in another example.
Can you elaborate this? I can't see what is wrong with the argument
> "for_each(v.begin(), v.end(), _1 = bind(foo, _1));"
> 'for_each' is a non-mutating algorithm. 'transform' is better for this
Yes, for_each only requires the iterators to be InputIterators and I guess
that is why it is listed as non-modifying sequence operation.
I'm not sure what to do with this. To me code like this
for_each(a.begin(), a.end(), ++_1);
compared to this
transform(a.begin(), a.end(), a.begin(), _1 + 1);
looks more intuitive.
Both will work, but the former may be (mis)using for_each in a
We can always define
with a less constraining requirements to go around this :)
> (1) Having recursion would be great.
> > (2) Having some kind of 'let' form
Something to think about :)
Thanks for the comments, Jaakko
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk