Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-07-19 04:04:55

Gennadiy Rozental wrote:
> Cuold you help me out with chapter 2.3.5. In general I do
> not understand how iter_fold is working.
> Here is the list of specificisues:
> 1. Could you somehow in pseudoterms explain how iter_fold is
> defined and what is it doing? Just like
> std::accumulate( Iter begin, Iter end, T& res, Predicate p,
> ) { while(
> begin != end ) { res += p(begin++); } }

Is this of any help -

> 2. Second argument: what is it state or iterator?

State. See the reference.

> 3. In your code there is no iter_fold with four arguments.
> Why does docs says so?

The interface has changed recently, and I forgot to update the article in
this respect - thanks for catching it. The up-to-date way to do a two-way
iteration on the sequence is to use 'iter_fold_backward' - see

> 4. What are fold and reverce_fold algorithms are doing?

See the reference doc. Note that 'fold_reverse' has been renamed to
'fold_backward' (another missed change).

> 5. select_max does not have anything to do with max. Would
> not it be better to name something like select_by_predicate

Correct, but it's just a helper function for 'max_element', and IMO giving
it a general name like 'select_by_predicate' is undesirable. BTW, it's not
needed with lambda anyway ;).

> 6. What is project1st?

A compile-time equivalent of this one - I'll add it to the reference.


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