Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2004-04-15 00:10:05


"Witz" <witz_at_[hidden]> writes:

> just a quick question - which maybe should have been directed at the
> developers list but ...
>
> would it be possible in the iterator adaptors to have an operator== defined
> that takes the base iterator as the right hand side? it would certainly cut
> down on typing and also obviate the need to create an end iterator that is
> only used as an 'end of container' sentinel value
>
> if it was possible it would allow us to write, for example:
>
> copy( make_filter_iterator<is_positive_number>(numbers, numbers + N),
> numbers + N, ostream_iterator<int>(cout, " "));
>
> rather than:
>
> copy( make_filter_iterator<is_positive_number>(numbers, numbers + N),
> make_filter_iterator<is_positive_number>(numbers + N, numbers + N),
> ostream_iterator<int>(cout, " "));
>
> of course i am aware that i might be missing something obvious ...

I think you are. the signature of std::copy is:

  template<class InputIterator, class OutputIterator>
  OutputIterator copy(
     InputIterator first, InputIterator last, OutputIterator result);

What will the compiler deduce InputIterator to be?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net