Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-02-21 11:18:27


Okay, I understand where you're headed. However, I think the idea needs a
little development before it can qualify on anyone's list of "most
needed/desired features in C++" ;-)

-Dave

----- Original Message -----
From: "Michiel Salters" <Michiel.Salters_at_[hidden]>

> Valid points. I think your point about carrying around the begin
> iterator is valid; but this was a quick sketch. I can imagine
> making the at_end( ) functionality separable from the
> begin part ( i.e. have at_end( ) in a base class, the begin
> iterator in the derived Range class, and use a slicing copy)
>
> Let me state my point somewhat clearer :If the end should
> always be an iterator, you can end up with additional baggage
> in such iterators. By allowing a different type to represent the
> end, all valid iterators in such ranges can be smaller.
>
> Perhaps we should name it std::end<ITERATOR>:
>
> template < typename ITERATOR >
> void foo( ITERATOR i,
> std::end<ITERATOR> TheEnd = std::end<ITERATOR>( ) )
> {
> for ( ;i != TheEnd ; ++i )
> bar( *i )
> }
>
> int array[10];
> end<int*> TheEnd = array+10;
>
> foo( array, TheEnd );
>
> istream_iterator<int> ( file ) FileIter;
> foo ( FileIter );
>
> Insert code for operator==( Iter, end<Iter> ) as appropriate :)
>
> --
> Michiel Salters


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