Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2005-08-22 04:50:24


Hi,

I have a proposal for addition to Boost.Range library:

template<typename RangeT, typename OtherRangeT>
RangeT construct<RangeT>(const OtherRangeT& Source);

template<typename RangeT, typename IteratorT>
RangeT construct<RangeT>(IteratorT From, IteratorT To);

Both functions should construct a range of type RangeT, that will
contain elements from Source or [From,To) respectively.

Motivation:

In the standard library Sequence concept defines a way for constructing a
sequence from and arbitrary range of iterators. This is very useful
concept and it would be nice to have something similar available
in the Range library.

Most significant advantage of this construct is that it allows to create
algorithms, that modify an input range and return a copy of it.

Currently there is no generic way for constructing or modifying a
range, therefor it restricts the usage of range to non-mutable input parameters.

For instance a simple to_lower algorithm (available in StringAlgo library)

template<typename SequenceT>
SequenceT to_lower_copy(const SequenceT& Input, const std::locale& Loc=std::locale());

requires the input to satisfy sequence requirements so it can construct the result.
This effectively disables many advantages of Range library. Because it is not possible
to adapt an external class (like CString) to work with this algorithm.
Yes it could be very easy to implement construction for this class.

There is already a similar function in the range library. It's called copy<> but,
this function is provided solely for sequences and there is no feasible and
documented way for customization.

Best Regards,
Pavol


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