Boost logo

Boost :

From: dan marsden (danmarsden_at_[hidden])
Date: 2007-06-11 15:41:46

Martin Weiser wrote:
>- const is transitive, i.e. dereferencing an iterator into a const vector
>yields a reference to a const element and
>- transformation algorithms work on const sequences.
>Combined, these two imply that an in-place modification of a sequence
>through a view generated by a transformation algorithm is impossible.
>While this is perfectly reasonable for transform, it seems quite
>restrictive for filter or erase. After all, filter_view accepts a
>non-const input sequence.

This is a known and currently deliberate restriction. We decided to adopt a
simple programming model for the transformation algorithms, that their results
are immutable, leading to a functional style of programming. For many algorithms
this makes most sense, although filter is the key example of one where allowing
you to write into the filtered output seems reasonable.

For now we decided that if users needed mutable behaviour, they could use the
equivalent views, such as filter_view, as you identified.

We may loosen the above restrictions in future, depending on feedback such as
yours about whether the restriction is a regular annoyance.



Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today*

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