Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-07-26 11:41:56


On Thu, 26 Jul 2001, Fernando Cacciola wrote:
> If I were to reinvent the STL, I would separate containers from ranges right
> from the start. That is, a container would have a member function range()
> returning a range object, and all the algorithms would use range objects.
> Unfortunately, we can just wrap STL, but that should be done carefully.

We don't need member functions and wrapping. Global make_range() functions
taking a single container argument would do the trick.

template <class Container>
range<typename Container::iterator>
make_range(Container& x) {
  return range<typename Container::iterator>(x.begin(), x.end());
}

template <class Container>
range<typename Container::const_iterator>
make_range(const Container& x)
{
  return range<typename Container::const_iterator>(x.begin(), x.end());
}

----------------------------------------------------------------------
 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
----------------------------------------------------------------------


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