/* $Id: range.h 5713 2010-09-09 03:11:22Z abehm $ Copyright (C) 2010 by The Regents of the University of California Redistribution of this file is permitted under the terms of the BSD license. Date: 07/19/2008 Author: Rares Vernica */ #ifndef _range_h_ #define _range_h_ #include template struct range { T _begin, _end; range(const T& begin = T(), const T& end = T()): _begin(begin), _end(end) {} template range(const range& p): _begin(p._begin), _end(p._end) {} size_t size() const { return std::distance(_begin, _end); } const T& begin() const { return _begin; } const T& end() const { return _end; } typedef T iterator; typedef T const_iterator; }; template inline bool operator==(const range& x, const range& y) { return x._begin == y._begin && x._end == y._end; } template inline bool operator!=(const range& x, const range& y) { return !(x == y); } template inline range make_range(T x, T y) { return range(x, y); } #endif