17 #ifndef __COMMON_VALUES_HPP__ 18 #define __COMMON_VALUES_HPP__ 21 #include <type_traits> 41 std::is_integral<T>::value,
42 "IntervalSet<T> must use an integral type");
44 foreach (
const Value::Range& range, ranges.range()) {
47 return Error(
"Range is out of bounds");
61 std::vector<T> result;
64 std::is_integral<T>::value,
65 "vector<T> must use an integral type");
67 foreach (
const Value::Range& range, ranges.range()) {
70 return Error(
"Range is out of bounds");
73 for (T value = range.begin(); value <= range.end(); value++) {
74 result.push_back(value);
89 std::is_integral<T>::value,
90 "IntervalSet<T> must use an integral type");
93 Value::Range* range = ranges.add_range();
94 range->set_begin(interval.
lower());
95 range->set_end(interval.
upper() - 1);
105 #endif // __COMMON_VALUES_HPP__ Definition: interval.hpp:34
Definition: errorbase.hpp:36
Definition: interval.hpp:28
Definition: interval.hpp:24
Try< std::vector< T > > rangesToVector(const Value::Ranges &ranges)
Definition: values.hpp:59
T lower() const
Definition: interval.hpp:81
Option< T > max(const Option< T > &left, const Option< T > &right)
Definition: option.hpp:214
Value::Ranges intervalSetToRanges(const IntervalSet< T > &set)
Definition: values.hpp:84
Option< T > min(const Option< T > &left, const Option< T > &right)
Definition: option.hpp:185
T upper() const
Definition: interval.hpp:84
Definition: attributes.hpp:24
Try< IntervalSet< T > > rangesToIntervalSet(const Value::Ranges &ranges)
Definition: values.hpp:36
static Bound< T > closed(const T &value)
Definition: interval.hpp:44