GCC Code Coverage Report
Directory: next/ Exec Total Coverage
File: next/ranges.hpp Lines: 7 7 100.0 %
Date: 2023-04-03 07:16:25 Branches: 3 4 75.0 %

Line Branch Exec Source
1
#pragma once
2
3
#include "interfaces.hpp"
4
5
namespace next {
6
7
#pragma region linear range
8
9
template <typename T> struct linrange : next_interface<linrange<T>> {
10
11
  const T first;
12
  const T last;
13
  T current;
14
15
45
  linrange(const T &first, const T &last)
16
45
      : first(first), last(last), current(first) {}
17
18
  using type = linrange<T>;
19
  using value_type = T;
20
21
57
  void initialize() { current = first; }
22
23
220
  std::optional<value_type> next() {
24
220
    if (current != last)
25
162
      return current++;
26
    else
27
58
      return std::nullopt;
28
  }
29
};
30
31
#pragma endregion
32
33
} // namespace next