File indexing completed on 2025-01-18 09:11:47
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <iterator>
0012 #include <utility>
0013
0014 namespace ActsExamples {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 template <typename Iterator>
0027 class Range {
0028 public:
0029 Range(Iterator b, Iterator e) : m_begin(b), m_end(e) {}
0030 Range(Range&&) noexcept = default;
0031 Range(const Range&) = default;
0032 ~Range() = default;
0033 Range& operator=(Range&&) noexcept = default;
0034 Range& operator=(const Range&) = default;
0035
0036 Iterator begin() const { return m_begin; }
0037 Iterator end() const { return m_end; }
0038 bool empty() const { return m_begin == m_end; }
0039 std::size_t size() const { return std::distance(m_begin, m_end); }
0040
0041 private:
0042 Iterator m_begin;
0043 Iterator m_end;
0044 };
0045
0046 template <typename Iterator>
0047 Range<Iterator> makeRange(Iterator begin, Iterator end) {
0048 return Range<Iterator>(begin, end);
0049 }
0050
0051 template <typename Iterator>
0052 Range<Iterator> makeRange(std::pair<Iterator, Iterator> range) {
0053 return Range<Iterator>(range.first, range.second);
0054 }
0055
0056 }