Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-03-14 01:04:05


I have been working on range-based algorithms and adaptors. The
algorithms are variants of the std::algorithms that accept ranges
instead of a [begin,end) iterator pair. The adaptors are like the
iterator adaptors, except they adapt ranges.

Following the principal of least surprise, I want to call my range
adaptors filter_range, indirect_range, reverse_range and transform_range
(to parallel filter_iterator, indirect_iterator, etc). But I can't do
this, because there already is a transform_range, and it's a function!


At the bottom of iterator_range.hpp is this:

    template< typename SeqT, typename Range, typename FuncT >
    inline SeqT transform_range( const Range& r, FuncT Func )
        SeqT Seq;
        std::transform( begin( r ), end( r ),
                        std::back_inserter(Seq), Func );
        return Seq;

I'm not sure why. It looks like a range-based algorithm, but ... why
provide only one? (Two actually -- copy_range is there also.) And why
call it transform_range() instead of just calling it "transform" and
making it part of a complete range-based algorithm library?


I suggest the functions copy_range() and transform_range() should be
removed or moved into a "deprecated" namespace, freeing up the
identifier "boost::transform_range" to be a type, analagous to
boost::transform_iterator. Development should proceed on a range-based
algorithms library to fill the need that the existing
"transform_range()" function is meeting.


Eric Niebler
Boost Consulting

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