| 1 | // { dg-do compile { target c++20 } } |
| 2 | |
| 3 | #include <ranges> |
| 4 | |
| 5 | struct iterator |
| 6 | { |
| 7 | using difference_type = int; |
| 8 | |
| 9 | int i; |
| 10 | |
| 11 | int operator*() const { return i; } |
| 12 | |
| 13 | // These are intentionally not constexpr: |
| 14 | iterator& operator++() { ++i; return *this; } |
| 15 | iterator operator++(int) { return {i++}; } |
| 16 | bool operator==(const iterator& it) const { return i == it.i; } |
| 17 | }; |
| 18 | |
| 19 | constexpr iterator begin(1), end(2); |
| 20 | |
| 21 | using std::ranges::subrange; |
| 22 | using std::ranges::subrange_kind; |
| 23 | |
| 24 | // This used to fail due to using operator++ and operator== in an assertion: |
| 25 | constexpr subrange<iterator, iterator, subrange_kind::sized> s(begin, end, 1); |