Boost logo

Boost :

From: helmut.zeisel_at_[hidden]
Date: 2001-07-26 09:51:41


--- In boost_at_y..., Jeremy Siek <jsiek_at_r...> wrote:
>
> The half_open_range class that Dave mentioned is basically the same
idea
> as the below range class.

Great :-)

template<typename Iterator> ::boost::half_open_range<Iterator>
make_range(Iterator begin, Iterator end)
{
  return range<Iterator>(begin,end);
}

Using my previously posted sort and copy,
this works :-)

  std::vector<int> v;
  v.push_back(2);
  v.push_back(3);
  v.push_back(1);
  sort(v);
  copy(v,std::ostream_iterator<int>(std::cout," "));
  std::cout << "\n";

This, however, doesn't :-(

  int w[]={3,2,4,1};
  static const int n = sizeof(w)/sizeof(int);
  sort(make_range(w,w+n));
  copy(make_range(w,w+n),std::ostream_iterator<int>(std::cout," "));
  std::cout << "\n";
  sort(make_range(v.rbegin(),v.rend()));
  copy(v,std::ostream_iterator<int>(std::cout," "));

Just from a pragmatic point of view:
shouldn't make_range also work with built-in pointers?
Then also the existing STL algorithms can be
uniquely extended to an interface
that accepts a container or a make_range-result.

Helmut


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