1 /* Copyright (c) 2016-2020. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_XBT_RANGE_HPP
8 #define SIMGRID_XBT_RANGE_HPP
15 /** Describes a contiguous inclusive-exclusive [a,b) range of values */
16 template<class T> class Range {
20 Range() : begin_(), end_() {}
21 Range(T begin, T end) : begin_(std::move(begin)), end_(std::move(end)) {}
22 explicit Range(T value) : begin_(value), end_(value + 1) {}
23 T& begin() { return begin_; }
24 T& end() { return end_; }
25 const T& begin() const { return begin_; }
26 const T& end() const { return end_; }
27 bool empty() const { return begin_ >= end_; }
28 bool contain(T const& x) const { return begin_ <= x && end_ > x; }