Boost logo

Boost :

From: Martin Weiser (weiser_at_[hidden])
Date: 2007-06-12 07:35:39


On Monday 11 June 2007 21:41, dan marsden wrote:
> 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.

Thanks for clarifying this. I didn't locate this issue in the
documentation, which may easily be my fault, but otherwise I think it
would be worth putting this statement onto the transformation algorithms
page.

Yours
Martin

-- 
Dr. Martin Weiser                  web:     www.zib.de/weiser
Zuse Institute Berlin              mail:    weiser_at_[hidden]
Numerical Analysis and Modelling   pgp key: www.zib.de/weiser/weiser.asc



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