$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-07-26 09:04:37
The half_open_range class that Dave mentioned is basically the same idea
as the below range class.
On Thu, 26 Jul 2001 helmut.zeisel_at_[hidden] wrote:
>
> template<typename Iterator> struct range
> {
>    Iterator m_begin;
>    Iterator m_end;
>    range(Iterator begin, Iterator end): m_begin(begin), m_end(end) {}
>    Iterator begin() const {return m_begin;}
>    Iterator end() const {return m_end;}
>    typedef Iterator iterator;
> };
>
> template<typename Iterator> range<Iterator>
> make_range(Iterator begin, Iterator end)
> {
>   return range<Iterator>(begin,end);
> }
>
> template<typename Range>  void sort(Range& r)
> {
>   std::sort(r.begin(), r.end());
> }
> template<typename Range, typename Out>  void copy(Range& r, Out res)
> {
>   typename Range::iterator it=r.begin();
>   while(it != r.end())
>   {
>     *res++ = *it++;
>   }
> }
>
> #include <algorithm>
> #include <vector>
> #include <iostream>
> int main()
> {
>   std::vector<int> v;
>   v.push_back(2);
>   v.push_back(3);
>   v.push_back(1);
>   int w[]={3,2,4,1};
>   static const int n = sizeof(w)/sizeof(int);
>   sort(v);
>   copy(v,std::ostream_iterator<int>(std::cout," "));
>   std::cout << "\n";
>   sort(make_range(w,w+n));
>   copy(make_range(w,w+n),std::ostream_iterator<int>(std::cout," "));
>
>   return 0;
> }
>
>
> Info: http://www.boost.org  Unsubscribe: <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
----------------------------------------------------------------------
 Jeremy Siek                        www: http://www.lsc.nd.edu/~jsiek/
 Ph.D. Candidate, IU B'ton          email: jsiek_at_[hidden]
 Summer Manager, AT&T Research      phone: (973) 360-8185
----------------------------------------------------------------------