From Jason Turner

[predef.iterators]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpv5f6qmdg/{from.md → to.md} +80 -50
tmp/tmpv5f6qmdg/{from.md → to.md} RENAMED
@@ -18,11 +18,11 @@ namespace std {
18
  using iterator_type = Iterator;
19
  using iterator_concept = see below;
20
  using iterator_category = see below;
21
  using value_type = iter_value_t<Iterator>;
22
  using difference_type = iter_difference_t<Iterator>;
23
- using pointer = typename iterator_traits<Iterator>::pointer;
24
  using reference = iter_reference_t<Iterator>;
25
 
26
  constexpr reverse_iterator();
27
  constexpr explicit reverse_iterator(Iterator x);
28
  template<class U> constexpr reverse_iterator(const reverse_iterator<U>& u);
@@ -95,14 +95,11 @@ are instantiated [[temp.inst]].
95
 
96
  ``` cpp
97
  constexpr reverse_iterator();
98
  ```
99
 
100
- *Effects:* Value-initializes `current`. Iterator operations applied to
101
- the resulting iterator have defined behavior if and only if the
102
- corresponding operations are defined on a value-initialized iterator of
103
- type `Iterator`.
104
 
105
  ``` cpp
106
  constexpr explicit reverse_iterator(Iterator x);
107
  ```
108
 
@@ -428,10 +425,12 @@ the iterator points to in a container. `back_inserter`,
428
  `front_inserter`, and `inserter` are three functions making the insert
429
  iterators out of a container.
430
 
431
  #### Class template `back_insert_iterator` <a id="back.insert.iterator">[[back.insert.iterator]]</a>
432
 
 
 
433
  ``` cpp
434
  namespace std {
435
  template<class Container>
436
  class back_insert_iterator {
437
  protected:
@@ -502,10 +501,12 @@ template<class Container>
502
 
503
  *Returns:* `back_insert_iterator<Container>(x)`.
504
 
505
  #### Class template `front_insert_iterator` <a id="front.insert.iterator">[[front.insert.iterator]]</a>
506
 
 
 
507
  ``` cpp
508
  namespace std {
509
  template<class Container>
510
  class front_insert_iterator {
511
  protected:
@@ -576,10 +577,12 @@ template<class Container>
576
 
577
  *Returns:* `front_insert_iterator<Container>(x)`.
578
 
579
  #### Class template `insert_iterator` <a id="insert.iterator">[[insert.iterator]]</a>
580
 
 
 
581
  ``` cpp
582
  namespace std {
583
  template<class Container>
584
  class insert_iterator {
585
  protected:
@@ -758,10 +761,17 @@ namespace std {
758
  requires random_access_iterator<Iterator>;
759
 
760
  template<sentinel_for<Iterator> S>
761
  constexpr bool operator==(const S& s) const;
762
 
 
 
 
 
 
 
 
763
  constexpr bool operator<(const basic_const_iterator& y) const
764
  requires random_access_iterator<Iterator>;
765
  constexpr bool operator>(const basic_const_iterator& y) const
766
  requires random_access_iterator<Iterator>;
767
  constexpr bool operator<=(const basic_const_iterator& y) const
@@ -979,10 +989,26 @@ template<sentinel_for<Iterator> S>
979
  constexpr bool operator==(const S& s) const;
980
  ```
981
 
982
  *Effects:* Equivalent to: `return `*`current_`*` == s;`
983
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
984
  ``` cpp
985
  constexpr bool operator<(const basic_const_iterator& y) const
986
  requires random_access_iterator<Iterator>;
987
  constexpr bool operator>(const basic_const_iterator& y) const
988
  requires random_access_iterator<Iterator>;
@@ -1037,11 +1063,11 @@ template<not-a-const-iterator I>
1037
  requires random_access_iterator<Iterator> && totally_ordered_with<Iterator, I>;
1038
  ```
1039
 
1040
  Let *`op`* be the operator.
1041
 
1042
- *Returns:* Equivalent to: `return x `*`op`*` y.`*`current_`*`;`
1043
 
1044
  ``` cpp
1045
  friend constexpr basic_const_iterator operator+(const basic_const_iterator& i, difference_type n)
1046
  requires random_access_iterator<Iterator>;
1047
  friend constexpr basic_const_iterator operator+(difference_type n, const basic_const_iterator& i)
@@ -1591,11 +1617,11 @@ namespace std {
1591
  template<sized_sentinel_for<I> I2, sized_sentinel_for<I> S2>
1592
  requires sized_sentinel_for<S, I2>
1593
  friend constexpr iter_difference_t<I2> operator-(
1594
  const common_iterator& x, const common_iterator<I2, S2>& y);
1595
 
1596
- friend constexpr iter_rvalue_reference_t<I> iter_move(const common_iterator& i)
1597
  noexcept(noexcept(ranges::iter_move(declval<const I&>())))
1598
  requires input_iterator<I>;
1599
  template<indirectly_swappable<I> I2, class S2>
1600
  friend constexpr void iter_swap(const common_iterator& x, const common_iterator<I2, S2>& y)
1601
  noexcept(noexcept(ranges::iter_swap(declval<const I&>(), declval<const I2&>())));
@@ -1610,30 +1636,34 @@ namespace std {
1610
  };
1611
 
1612
  template<input_iterator I, class S>
1613
  struct iterator_traits<common_iterator<I, S>> {
1614
  using iterator_concept = see below;
1615
- using iterator_category = see below;
1616
  using value_type = iter_value_t<I>;
1617
  using difference_type = iter_difference_t<I>;
1618
  using pointer = see below;
1619
  using reference = iter_reference_t<I>;
1620
  };
1621
  }
1622
  ```
1623
 
1624
  #### Associated types <a id="common.iter.types">[[common.iter.types]]</a>
1625
 
1626
- The nested *typedef-name*s of the specialization of `iterator_traits`
1627
- for `common_iterator<I, S>` are defined as follows.
 
 
 
 
 
 
 
 
1628
 
1629
  - `iterator_concept` denotes `forward_iterator_tag` if `I` models
1630
  `forward_iterator`; otherwise it denotes `input_iterator_tag`.
1631
- - `iterator_category` denotes `forward_iterator_tag` if the
1632
- *qualified-id* `iterator_traits<I>::iterator_category` is valid and
1633
- denotes a type that models `derived_from<forward_iterator_tag>`;
1634
- otherwise it denotes `input_iterator_tag`.
1635
  - Let `a` denote an lvalue of type `const common_iterator<I, S>`. If the
1636
  expression `a.operator->()` is well-formed, then `pointer` denotes
1637
  `decltype(a.operator->())`. Otherwise, `pointer` denotes `void`.
1638
 
1639
  #### Constructors and conversions <a id="common.iter.const">[[common.iter.const]]</a>
@@ -1656,11 +1686,11 @@ constexpr common_iterator(S s);
1656
  template<class I2, class S2>
1657
  requires convertible_to<const I2&, I> && convertible_to<const S2&, S>
1658
  constexpr common_iterator(const common_iterator<I2, S2>& x);
1659
  ```
1660
 
1661
- *Preconditions:* `x.v_.valueless_by_exception()` is `false`.
1662
 
1663
  *Effects:* Initializes `v_` as if by
1664
  `v_{in_place_index<`i`>, get<`i`>(x.v_)}`, where i is `x.v_.index()`.
1665
 
1666
  ``` cpp
@@ -1668,30 +1698,30 @@ template<class I2, class S2>
1668
  requires convertible_to<const I2&, I> && convertible_to<const S2&, S> &&
1669
  assignable_from<I&, const I2&> && assignable_from<S&, const S2&>
1670
  constexpr common_iterator& operator=(const common_iterator<I2, S2>& x);
1671
  ```
1672
 
1673
- *Preconditions:* `x.v_.valueless_by_exception()` is `false`.
1674
 
1675
  *Effects:* Equivalent to:
1676
 
1677
  - If `v_.index() == x.v_.index()`, then `get<`i`>(v_) = get<`i`>(x.v_)`.
1678
  - Otherwise, `v_.emplace<`i`>(get<`i`>(x.v_))`.
1679
 
1680
  where i is `x.v_.index()`.
1681
 
1682
- *Returns:* `*this`
1683
 
1684
  #### Accessors <a id="common.iter.access">[[common.iter.access]]</a>
1685
 
1686
  ``` cpp
1687
  constexpr decltype(auto) operator*();
1688
  constexpr decltype(auto) operator*() const
1689
  requires dereferenceable<const I>;
1690
  ```
1691
 
1692
- *Preconditions:* `holds_alternative<I>(v_)` is `true`.
1693
 
1694
  *Effects:* Equivalent to: `return *get<I>(v_);`
1695
 
1696
  ``` cpp
1697
  constexpr auto operator->() const
@@ -1705,11 +1735,11 @@ indirectly_readable<const I> &&
1705
  (requires(const I& i) { i.operator->(); } ||
1706
  is_reference_v<iter_reference_t<I>> ||
1707
  constructible_from<iter_value_t<I>, iter_reference_t<I>>)
1708
  ```
1709
 
1710
- *Preconditions:* `holds_alternative<I>(v_)` is `true`.
1711
 
1712
  *Effects:*
1713
 
1714
  - If `I` is a pointer type or if the expression
1715
  `get<I>(v_).operator->()` is well-formed, equivalent to:
@@ -1738,21 +1768,21 @@ indirectly_readable<const I> &&
1738
 
1739
  ``` cpp
1740
  constexpr common_iterator& operator++();
1741
  ```
1742
 
1743
- *Preconditions:* `holds_alternative<I>(v_)` is `true`.
1744
 
1745
  *Effects:* Equivalent to `++get<I>(v_)`.
1746
 
1747
  *Returns:* `*this`.
1748
 
1749
  ``` cpp
1750
  constexpr decltype(auto) operator++(int);
1751
  ```
1752
 
1753
- *Preconditions:* `holds_alternative<I>(v_)` is `true`.
1754
 
1755
  *Effects:* If `I` models `forward_iterator`, equivalent to:
1756
 
1757
  ``` cpp
1758
  common_iterator tmp = *this;
@@ -1803,12 +1833,12 @@ template<class I2, sentinel_for<I> S2>
1803
  requires sentinel_for<S, I2>
1804
  friend constexpr bool operator==(
1805
  const common_iterator& x, const common_iterator<I2, S2>& y);
1806
  ```
1807
 
1808
- *Preconditions:* `x.v_.valueless_by_exception()` and
1809
- `y.v_.valueless_by_exception()` are each `false`.
1810
 
1811
  *Returns:* `true` if i` == `j, and otherwise
1812
  `get<`i`>(x.v_) == get<`j`>(y.v_)`, where i is `x.v_.index()` and j is
1813
  `y.v_.index()`.
1814
 
@@ -1817,12 +1847,12 @@ template<class I2, sentinel_for<I> S2>
1817
  requires sentinel_for<S, I2> && equality_comparable_with<I, I2>
1818
  friend constexpr bool operator==(
1819
  const common_iterator& x, const common_iterator<I2, S2>& y);
1820
  ```
1821
 
1822
- *Preconditions:* `x.v_.valueless_by_exception()` and
1823
- `y.v_.valueless_by_exception()` are each `false`.
1824
 
1825
  *Returns:* `true` if i and j are each `1`, and otherwise
1826
  `get<`i`>(x.v_) == get<`j`>(y.v_)`, where i is `x.v_.index()` and j is
1827
  `y.v_.index()`.
1828
 
@@ -1831,37 +1861,37 @@ template<sized_sentinel_for<I> I2, sized_sentinel_for<I> S2>
1831
  requires sized_sentinel_for<S, I2>
1832
  friend constexpr iter_difference_t<I2> operator-(
1833
  const common_iterator& x, const common_iterator<I2, S2>& y);
1834
  ```
1835
 
1836
- *Preconditions:* `x.v_.valueless_by_exception()` and
1837
- `y.v_.valueless_by_exception()` are each `false`.
1838
 
1839
  *Returns:* `0` if i and j are each `1`, and otherwise
1840
  `get<`i`>(x.v_) - get<`j`>(y.v_)`, where i is `x.v_.index()` and j is
1841
  `y.v_.index()`.
1842
 
1843
  #### Customizations <a id="common.iter.cust">[[common.iter.cust]]</a>
1844
 
1845
  ``` cpp
1846
- friend constexpr iter_rvalue_reference_t<I> iter_move(const common_iterator& i)
1847
  noexcept(noexcept(ranges::iter_move(declval<const I&>())))
1848
  requires input_iterator<I>;
1849
  ```
1850
 
1851
- *Preconditions:* `holds_alternative<I>(i.v_)` is `true`.
1852
 
1853
  *Effects:* Equivalent to: `return ranges::iter_move(get<I>(i.v_));`
1854
 
1855
  ``` cpp
1856
  template<indirectly_swappable<I> I2, class S2>
1857
  friend constexpr void iter_swap(const common_iterator& x, const common_iterator<I2, S2>& y)
1858
  noexcept(noexcept(ranges::iter_swap(declval<const I&>(), declval<const I2&>())));
1859
  ```
1860
 
1861
- *Preconditions:* `holds_alternative<I>(x.v_)` and
1862
- `holds_alternative<I2>(y.v_)` are each `true`.
1863
 
1864
  *Effects:* Equivalent to
1865
  `ranges::iter_swap(get<I>(x.v_), get<I2>(y.v_))`.
1866
 
1867
  ### Default sentinel <a id="default.sentinel">[[default.sentinel]]</a>
@@ -1912,13 +1942,13 @@ namespace std {
1912
  public:
1913
  using iterator_type = I;
1914
  using value_type = iter_value_t<I>; // present only
1915
  // if I models indirectly_readable
1916
  using difference_type = iter_difference_t<I>;
1917
- using iterator_concept = typename I::iterator_concept; // present only
1918
  // if the qualified-id I::iterator_concept is valid and denotes a type
1919
- using iterator_category = typename I::iterator_category; // present only
1920
  // if the qualified-id I::iterator_category is valid and denotes a type
1921
  constexpr counted_iterator() requires default_initializable<I> = default;
1922
  constexpr counted_iterator(I x, iter_difference_t<I> n);
1923
  template<class I2>
1924
  requires convertible_to<const I2&, I>
@@ -1959,30 +1989,30 @@ namespace std {
1959
  requires random_access_iterator<I>;
1960
  template<common_with<I> I2>
1961
  friend constexpr iter_difference_t<I2> operator-(
1962
  const counted_iterator& x, const counted_iterator<I2>& y);
1963
  friend constexpr iter_difference_t<I> operator-(
1964
- const counted_iterator& x, default_sentinel_t);
1965
  friend constexpr iter_difference_t<I> operator-(
1966
- default_sentinel_t, const counted_iterator& y);
1967
  constexpr counted_iterator& operator-=(iter_difference_t<I> n)
1968
  requires random_access_iterator<I>;
1969
 
1970
  constexpr decltype(auto) operator[](iter_difference_t<I> n) const
1971
  requires random_access_iterator<I>;
1972
 
1973
  template<common_with<I> I2>
1974
  friend constexpr bool operator==(
1975
  const counted_iterator& x, const counted_iterator<I2>& y);
1976
  friend constexpr bool operator==(
1977
- const counted_iterator& x, default_sentinel_t);
1978
 
1979
  template<common_with<I> I2>
1980
  friend constexpr strong_ordering operator<=>(
1981
  const counted_iterator& x, const counted_iterator<I2>& y);
1982
 
1983
- friend constexpr iter_rvalue_reference_t<I> iter_move(const counted_iterator& i)
1984
  noexcept(noexcept(ranges::iter_move(i.current)))
1985
  requires input_iterator<I>;
1986
  template<indirectly_swappable<I> I2>
1987
  friend constexpr void iter_swap(const counted_iterator& x, const counted_iterator<I2>& y)
1988
  noexcept(noexcept(ranges::iter_swap(x.current, y.current)));
@@ -2005,11 +2035,11 @@ namespace std {
2005
 
2006
  ``` cpp
2007
  constexpr counted_iterator(I i, iter_difference_t<I> n);
2008
  ```
2009
 
2010
- *Preconditions:* `n >= 0`.
2011
 
2012
  *Effects:* Initializes `current` with `std::move(i)` and `length` with
2013
  `n`.
2014
 
2015
  ``` cpp
@@ -2057,11 +2087,11 @@ constexpr iter_difference_t<I> count() const noexcept;
2057
  constexpr decltype(auto) operator*();
2058
  constexpr decltype(auto) operator*() const
2059
  requires dereferenceable<const I>;
2060
  ```
2061
 
2062
- *Preconditions:* `length > 0` is `true`.
2063
 
2064
  *Effects:* Equivalent to: `return *current;`
2065
 
2066
  ``` cpp
2067
  constexpr auto operator->() const noexcept
@@ -2073,21 +2103,21 @@ constexpr auto operator->() const noexcept
2073
  ``` cpp
2074
  constexpr decltype(auto) operator[](iter_difference_t<I> n) const
2075
  requires random_access_iterator<I>;
2076
  ```
2077
 
2078
- *Preconditions:* `n < length`.
2079
 
2080
  *Effects:* Equivalent to: `return current[n];`
2081
 
2082
  #### Navigation <a id="counted.iter.nav">[[counted.iter.nav]]</a>
2083
 
2084
  ``` cpp
2085
  constexpr counted_iterator& operator++();
2086
  ```
2087
 
2088
- *Preconditions:* `length > 0`.
2089
 
2090
  *Effects:* Equivalent to:
2091
 
2092
  ``` cpp
2093
  ++current;
@@ -2097,11 +2127,11 @@ return *this;
2097
 
2098
  ``` cpp
2099
  constexpr decltype(auto) operator++(int);
2100
  ```
2101
 
2102
- *Preconditions:* `length > 0`.
2103
 
2104
  *Effects:* Equivalent to:
2105
 
2106
  ``` cpp
2107
  --length;
@@ -2167,11 +2197,11 @@ friend constexpr counted_iterator operator+(
2167
  ``` cpp
2168
  constexpr counted_iterator& operator+=(iter_difference_t<I> n)
2169
  requires random_access_iterator<I>;
2170
  ```
2171
 
2172
- *Preconditions:* `n <= length`.
2173
 
2174
  *Effects:* Equivalent to:
2175
 
2176
  ``` cpp
2177
  current += n;
@@ -2198,28 +2228,28 @@ sequence [[counted.iterator]].
2198
 
2199
  *Effects:* Equivalent to: `return y.length - x.length;`
2200
 
2201
  ``` cpp
2202
  friend constexpr iter_difference_t<I> operator-(
2203
- const counted_iterator& x, default_sentinel_t);
2204
  ```
2205
 
2206
  *Effects:* Equivalent to: `return -x.length;`
2207
 
2208
  ``` cpp
2209
  friend constexpr iter_difference_t<I> operator-(
2210
- default_sentinel_t, const counted_iterator& y);
2211
  ```
2212
 
2213
  *Effects:* Equivalent to: `return y.length;`
2214
 
2215
  ``` cpp
2216
  constexpr counted_iterator& operator-=(iter_difference_t<I> n)
2217
  requires random_access_iterator<I>;
2218
  ```
2219
 
2220
- *Preconditions:* `-n <= length`.
2221
 
2222
  *Effects:* Equivalent to:
2223
 
2224
  ``` cpp
2225
  current -= n;
@@ -2240,11 +2270,11 @@ sequence [[counted.iterator]].
2240
 
2241
  *Effects:* Equivalent to: `return x.length == y.length;`
2242
 
2243
  ``` cpp
2244
  friend constexpr bool operator==(
2245
- const counted_iterator& x, default_sentinel_t);
2246
  ```
2247
 
2248
  *Effects:* Equivalent to: `return x.length == 0;`
2249
 
2250
  ``` cpp
@@ -2262,28 +2292,28 @@ sequence [[counted.iterator]].
2262
  because `length` counts down, not up. — *end note*]
2263
 
2264
  #### Customizations <a id="counted.iter.cust">[[counted.iter.cust]]</a>
2265
 
2266
  ``` cpp
2267
- friend constexpr iter_rvalue_reference_t<I>
2268
  iter_move(const counted_iterator& i)
2269
  noexcept(noexcept(ranges::iter_move(i.current)))
2270
  requires input_iterator<I>;
2271
  ```
2272
 
2273
- *Preconditions:* `i.length > 0` is `true`.
2274
 
2275
  *Effects:* Equivalent to: `return ranges::iter_move(i.current);`
2276
 
2277
  ``` cpp
2278
  template<indirectly_swappable<I> I2>
2279
  friend constexpr void
2280
  iter_swap(const counted_iterator& x, const counted_iterator<I2>& y)
2281
  noexcept(noexcept(ranges::iter_swap(x.current, y.current)));
2282
  ```
2283
 
2284
- *Preconditions:* Both `x.length > 0` and `y.length > 0` are `true`.
2285
 
2286
  *Effects:* Equivalent to `ranges::iter_swap(x.current, y.current)`.
2287
 
2288
  ### Unreachable sentinel <a id="unreachable.sentinel">[[unreachable.sentinel]]</a>
2289
 
 
18
  using iterator_type = Iterator;
19
  using iterator_concept = see below;
20
  using iterator_category = see below;
21
  using value_type = iter_value_t<Iterator>;
22
  using difference_type = iter_difference_t<Iterator>;
23
+ using pointer = iterator_traits<Iterator>::pointer;
24
  using reference = iter_reference_t<Iterator>;
25
 
26
  constexpr reverse_iterator();
27
  constexpr explicit reverse_iterator(Iterator x);
28
  template<class U> constexpr reverse_iterator(const reverse_iterator<U>& u);
 
95
 
96
  ``` cpp
97
  constexpr reverse_iterator();
98
  ```
99
 
100
+ *Effects:* Value-initializes `current`.
 
 
 
101
 
102
  ``` cpp
103
  constexpr explicit reverse_iterator(Iterator x);
104
  ```
105
 
 
425
  `front_inserter`, and `inserter` are three functions making the insert
426
  iterators out of a container.
427
 
428
  #### Class template `back_insert_iterator` <a id="back.insert.iterator">[[back.insert.iterator]]</a>
429
 
430
+ ##### General <a id="back.insert.iter.general">[[back.insert.iter.general]]</a>
431
+
432
  ``` cpp
433
  namespace std {
434
  template<class Container>
435
  class back_insert_iterator {
436
  protected:
 
501
 
502
  *Returns:* `back_insert_iterator<Container>(x)`.
503
 
504
  #### Class template `front_insert_iterator` <a id="front.insert.iterator">[[front.insert.iterator]]</a>
505
 
506
+ ##### General <a id="front.insert.iter.general">[[front.insert.iter.general]]</a>
507
+
508
  ``` cpp
509
  namespace std {
510
  template<class Container>
511
  class front_insert_iterator {
512
  protected:
 
577
 
578
  *Returns:* `front_insert_iterator<Container>(x)`.
579
 
580
  #### Class template `insert_iterator` <a id="insert.iterator">[[insert.iterator]]</a>
581
 
582
+ ##### General <a id="insert.iter.general">[[insert.iter.general]]</a>
583
+
584
  ``` cpp
585
  namespace std {
586
  template<class Container>
587
  class insert_iterator {
588
  protected:
 
761
  requires random_access_iterator<Iterator>;
762
 
763
  template<sentinel_for<Iterator> S>
764
  constexpr bool operator==(const S& s) const;
765
 
766
+ template<not-a-const-iterator CI>
767
+ requires constant-iterator<CI> && convertible_to<Iterator const&, CI>
768
+ constexpr operator CI() const &;
769
+ template<not-a-const-iterator CI>
770
+ requires constant-iterator<CI> && convertible_to<Iterator, CI>
771
+ constexpr operator CI() &&;
772
+
773
  constexpr bool operator<(const basic_const_iterator& y) const
774
  requires random_access_iterator<Iterator>;
775
  constexpr bool operator>(const basic_const_iterator& y) const
776
  requires random_access_iterator<Iterator>;
777
  constexpr bool operator<=(const basic_const_iterator& y) const
 
989
  constexpr bool operator==(const S& s) const;
990
  ```
991
 
992
  *Effects:* Equivalent to: `return `*`current_`*` == s;`
993
 
994
+ ``` cpp
995
+ template<not-a-const-iterator CI>
996
+ requires constant-iterator<CI> && convertible_to<Iterator const&, CI>
997
+ constexpr operator CI() const &;
998
+ ```
999
+
1000
+ *Returns:* *current\_*.
1001
+
1002
+ ``` cpp
1003
+ template<not-a-const-iterator CI>
1004
+ requires constant-iterator<CI> && convertible_to<Iterator, CI>
1005
+ constexpr operator CI() &&;
1006
+ ```
1007
+
1008
+ *Returns:* `std::move(`*`current_`*`)`.
1009
+
1010
  ``` cpp
1011
  constexpr bool operator<(const basic_const_iterator& y) const
1012
  requires random_access_iterator<Iterator>;
1013
  constexpr bool operator>(const basic_const_iterator& y) const
1014
  requires random_access_iterator<Iterator>;
 
1063
  requires random_access_iterator<Iterator> && totally_ordered_with<Iterator, I>;
1064
  ```
1065
 
1066
  Let *`op`* be the operator.
1067
 
1068
+ *Effects:* Equivalent to: `return x `*`op`*` y.`*`current_`*`;`
1069
 
1070
  ``` cpp
1071
  friend constexpr basic_const_iterator operator+(const basic_const_iterator& i, difference_type n)
1072
  requires random_access_iterator<Iterator>;
1073
  friend constexpr basic_const_iterator operator+(difference_type n, const basic_const_iterator& i)
 
1617
  template<sized_sentinel_for<I> I2, sized_sentinel_for<I> S2>
1618
  requires sized_sentinel_for<S, I2>
1619
  friend constexpr iter_difference_t<I2> operator-(
1620
  const common_iterator& x, const common_iterator<I2, S2>& y);
1621
 
1622
+ friend constexpr decltype(auto) iter_move(const common_iterator& i)
1623
  noexcept(noexcept(ranges::iter_move(declval<const I&>())))
1624
  requires input_iterator<I>;
1625
  template<indirectly_swappable<I> I2, class S2>
1626
  friend constexpr void iter_swap(const common_iterator& x, const common_iterator<I2, S2>& y)
1627
  noexcept(noexcept(ranges::iter_swap(declval<const I&>(), declval<const I2&>())));
 
1636
  };
1637
 
1638
  template<input_iterator I, class S>
1639
  struct iterator_traits<common_iterator<I, S>> {
1640
  using iterator_concept = see below;
1641
+ using iterator_category = see below; // not always present
1642
  using value_type = iter_value_t<I>;
1643
  using difference_type = iter_difference_t<I>;
1644
  using pointer = see below;
1645
  using reference = iter_reference_t<I>;
1646
  };
1647
  }
1648
  ```
1649
 
1650
  #### Associated types <a id="common.iter.types">[[common.iter.types]]</a>
1651
 
1652
+ The nested *typedef-name* `iterator_category` of the specialization of
1653
+ `iterator_traits` for `common_iterator<I, S>` is defined if and only if
1654
+ `iter_difference_t<I>` is an integral type. In that case,
1655
+ `iterator_category` denotes `forward_iterator_tag` if the *qualified-id*
1656
+ `iterator_traits<I>::iterator_category` is valid and denotes a type that
1657
+ models `derived_from<forward_iterator_tag>`; otherwise it denotes
1658
+ `input_iterator_tag`.
1659
+
1660
+ The remaining nested *typedef-name*s of the specialization of
1661
+ `iterator_traits` for `common_iterator<I, S>` are defined as follows:
1662
 
1663
  - `iterator_concept` denotes `forward_iterator_tag` if `I` models
1664
  `forward_iterator`; otherwise it denotes `input_iterator_tag`.
 
 
 
 
1665
  - Let `a` denote an lvalue of type `const common_iterator<I, S>`. If the
1666
  expression `a.operator->()` is well-formed, then `pointer` denotes
1667
  `decltype(a.operator->())`. Otherwise, `pointer` denotes `void`.
1668
 
1669
  #### Constructors and conversions <a id="common.iter.const">[[common.iter.const]]</a>
 
1686
  template<class I2, class S2>
1687
  requires convertible_to<const I2&, I> && convertible_to<const S2&, S>
1688
  constexpr common_iterator(const common_iterator<I2, S2>& x);
1689
  ```
1690
 
1691
+ `x.v_.valueless_by_exception()` is `false`.
1692
 
1693
  *Effects:* Initializes `v_` as if by
1694
  `v_{in_place_index<`i`>, get<`i`>(x.v_)}`, where i is `x.v_.index()`.
1695
 
1696
  ``` cpp
 
1698
  requires convertible_to<const I2&, I> && convertible_to<const S2&, S> &&
1699
  assignable_from<I&, const I2&> && assignable_from<S&, const S2&>
1700
  constexpr common_iterator& operator=(const common_iterator<I2, S2>& x);
1701
  ```
1702
 
1703
+ `x.v_.valueless_by_exception()` is `false`.
1704
 
1705
  *Effects:* Equivalent to:
1706
 
1707
  - If `v_.index() == x.v_.index()`, then `get<`i`>(v_) = get<`i`>(x.v_)`.
1708
  - Otherwise, `v_.emplace<`i`>(get<`i`>(x.v_))`.
1709
 
1710
  where i is `x.v_.index()`.
1711
 
1712
+ *Returns:* `*this`.
1713
 
1714
  #### Accessors <a id="common.iter.access">[[common.iter.access]]</a>
1715
 
1716
  ``` cpp
1717
  constexpr decltype(auto) operator*();
1718
  constexpr decltype(auto) operator*() const
1719
  requires dereferenceable<const I>;
1720
  ```
1721
 
1722
+ `holds_alternative<I>(v_)` is `true`.
1723
 
1724
  *Effects:* Equivalent to: `return *get<I>(v_);`
1725
 
1726
  ``` cpp
1727
  constexpr auto operator->() const
 
1735
  (requires(const I& i) { i.operator->(); } ||
1736
  is_reference_v<iter_reference_t<I>> ||
1737
  constructible_from<iter_value_t<I>, iter_reference_t<I>>)
1738
  ```
1739
 
1740
+ `holds_alternative<I>(v_)` is `true`.
1741
 
1742
  *Effects:*
1743
 
1744
  - If `I` is a pointer type or if the expression
1745
  `get<I>(v_).operator->()` is well-formed, equivalent to:
 
1768
 
1769
  ``` cpp
1770
  constexpr common_iterator& operator++();
1771
  ```
1772
 
1773
+ `holds_alternative<I>(v_)` is `true`.
1774
 
1775
  *Effects:* Equivalent to `++get<I>(v_)`.
1776
 
1777
  *Returns:* `*this`.
1778
 
1779
  ``` cpp
1780
  constexpr decltype(auto) operator++(int);
1781
  ```
1782
 
1783
+ `holds_alternative<I>(v_)` is `true`.
1784
 
1785
  *Effects:* If `I` models `forward_iterator`, equivalent to:
1786
 
1787
  ``` cpp
1788
  common_iterator tmp = *this;
 
1833
  requires sentinel_for<S, I2>
1834
  friend constexpr bool operator==(
1835
  const common_iterator& x, const common_iterator<I2, S2>& y);
1836
  ```
1837
 
1838
+ `x.v_.valueless_by_exception()` and `y.v_.valueless_by_exception()` are
1839
+ each `false`.
1840
 
1841
  *Returns:* `true` if i` == `j, and otherwise
1842
  `get<`i`>(x.v_) == get<`j`>(y.v_)`, where i is `x.v_.index()` and j is
1843
  `y.v_.index()`.
1844
 
 
1847
  requires sentinel_for<S, I2> && equality_comparable_with<I, I2>
1848
  friend constexpr bool operator==(
1849
  const common_iterator& x, const common_iterator<I2, S2>& y);
1850
  ```
1851
 
1852
+ `x.v_.valueless_by_exception()` and `y.v_.valueless_by_exception()` are
1853
+ each `false`.
1854
 
1855
  *Returns:* `true` if i and j are each `1`, and otherwise
1856
  `get<`i`>(x.v_) == get<`j`>(y.v_)`, where i is `x.v_.index()` and j is
1857
  `y.v_.index()`.
1858
 
 
1861
  requires sized_sentinel_for<S, I2>
1862
  friend constexpr iter_difference_t<I2> operator-(
1863
  const common_iterator& x, const common_iterator<I2, S2>& y);
1864
  ```
1865
 
1866
+ `x.v_.valueless_by_exception()` and `y.v_.valueless_by_exception()` are
1867
+ each `false`.
1868
 
1869
  *Returns:* `0` if i and j are each `1`, and otherwise
1870
  `get<`i`>(x.v_) - get<`j`>(y.v_)`, where i is `x.v_.index()` and j is
1871
  `y.v_.index()`.
1872
 
1873
  #### Customizations <a id="common.iter.cust">[[common.iter.cust]]</a>
1874
 
1875
  ``` cpp
1876
+ friend constexpr decltype(auto) iter_move(const common_iterator& i)
1877
  noexcept(noexcept(ranges::iter_move(declval<const I&>())))
1878
  requires input_iterator<I>;
1879
  ```
1880
 
1881
+ `holds_alternative<I>(i.v_)` is `true`.
1882
 
1883
  *Effects:* Equivalent to: `return ranges::iter_move(get<I>(i.v_));`
1884
 
1885
  ``` cpp
1886
  template<indirectly_swappable<I> I2, class S2>
1887
  friend constexpr void iter_swap(const common_iterator& x, const common_iterator<I2, S2>& y)
1888
  noexcept(noexcept(ranges::iter_swap(declval<const I&>(), declval<const I2&>())));
1889
  ```
1890
 
1891
+ `holds_alternative<I>(x.v_)` and `holds_alternative<I2>(y.v_)` are each
1892
+ `true`.
1893
 
1894
  *Effects:* Equivalent to
1895
  `ranges::iter_swap(get<I>(x.v_), get<I2>(y.v_))`.
1896
 
1897
  ### Default sentinel <a id="default.sentinel">[[default.sentinel]]</a>
 
1942
  public:
1943
  using iterator_type = I;
1944
  using value_type = iter_value_t<I>; // present only
1945
  // if I models indirectly_readable
1946
  using difference_type = iter_difference_t<I>;
1947
+ using iterator_concept = I::iterator_concept; // present only
1948
  // if the qualified-id I::iterator_concept is valid and denotes a type
1949
+ using iterator_category = I::iterator_category; // present only
1950
  // if the qualified-id I::iterator_category is valid and denotes a type
1951
  constexpr counted_iterator() requires default_initializable<I> = default;
1952
  constexpr counted_iterator(I x, iter_difference_t<I> n);
1953
  template<class I2>
1954
  requires convertible_to<const I2&, I>
 
1989
  requires random_access_iterator<I>;
1990
  template<common_with<I> I2>
1991
  friend constexpr iter_difference_t<I2> operator-(
1992
  const counted_iterator& x, const counted_iterator<I2>& y);
1993
  friend constexpr iter_difference_t<I> operator-(
1994
+ const counted_iterator& x, default_sentinel_t) noexcept;
1995
  friend constexpr iter_difference_t<I> operator-(
1996
+ default_sentinel_t, const counted_iterator& y) noexcept;
1997
  constexpr counted_iterator& operator-=(iter_difference_t<I> n)
1998
  requires random_access_iterator<I>;
1999
 
2000
  constexpr decltype(auto) operator[](iter_difference_t<I> n) const
2001
  requires random_access_iterator<I>;
2002
 
2003
  template<common_with<I> I2>
2004
  friend constexpr bool operator==(
2005
  const counted_iterator& x, const counted_iterator<I2>& y);
2006
  friend constexpr bool operator==(
2007
+ const counted_iterator& x, default_sentinel_t) noexcept;
2008
 
2009
  template<common_with<I> I2>
2010
  friend constexpr strong_ordering operator<=>(
2011
  const counted_iterator& x, const counted_iterator<I2>& y);
2012
 
2013
+ friend constexpr decltype(auto) iter_move(const counted_iterator& i)
2014
  noexcept(noexcept(ranges::iter_move(i.current)))
2015
  requires input_iterator<I>;
2016
  template<indirectly_swappable<I> I2>
2017
  friend constexpr void iter_swap(const counted_iterator& x, const counted_iterator<I2>& y)
2018
  noexcept(noexcept(ranges::iter_swap(x.current, y.current)));
 
2035
 
2036
  ``` cpp
2037
  constexpr counted_iterator(I i, iter_difference_t<I> n);
2038
  ```
2039
 
2040
+ `n >= 0` is `true`.
2041
 
2042
  *Effects:* Initializes `current` with `std::move(i)` and `length` with
2043
  `n`.
2044
 
2045
  ``` cpp
 
2087
  constexpr decltype(auto) operator*();
2088
  constexpr decltype(auto) operator*() const
2089
  requires dereferenceable<const I>;
2090
  ```
2091
 
2092
+ `length > 0` is `true`.
2093
 
2094
  *Effects:* Equivalent to: `return *current;`
2095
 
2096
  ``` cpp
2097
  constexpr auto operator->() const noexcept
 
2103
  ``` cpp
2104
  constexpr decltype(auto) operator[](iter_difference_t<I> n) const
2105
  requires random_access_iterator<I>;
2106
  ```
2107
 
2108
+ `n < length` is `true`.
2109
 
2110
  *Effects:* Equivalent to: `return current[n];`
2111
 
2112
  #### Navigation <a id="counted.iter.nav">[[counted.iter.nav]]</a>
2113
 
2114
  ``` cpp
2115
  constexpr counted_iterator& operator++();
2116
  ```
2117
 
2118
+ `length > 0` is `true`.
2119
 
2120
  *Effects:* Equivalent to:
2121
 
2122
  ``` cpp
2123
  ++current;
 
2127
 
2128
  ``` cpp
2129
  constexpr decltype(auto) operator++(int);
2130
  ```
2131
 
2132
+ `length > 0` is `true`.
2133
 
2134
  *Effects:* Equivalent to:
2135
 
2136
  ``` cpp
2137
  --length;
 
2197
  ``` cpp
2198
  constexpr counted_iterator& operator+=(iter_difference_t<I> n)
2199
  requires random_access_iterator<I>;
2200
  ```
2201
 
2202
+ `n <= length` is `true`.
2203
 
2204
  *Effects:* Equivalent to:
2205
 
2206
  ``` cpp
2207
  current += n;
 
2228
 
2229
  *Effects:* Equivalent to: `return y.length - x.length;`
2230
 
2231
  ``` cpp
2232
  friend constexpr iter_difference_t<I> operator-(
2233
+ const counted_iterator& x, default_sentinel_t) noexcept;
2234
  ```
2235
 
2236
  *Effects:* Equivalent to: `return -x.length;`
2237
 
2238
  ``` cpp
2239
  friend constexpr iter_difference_t<I> operator-(
2240
+ default_sentinel_t, const counted_iterator& y) noexcept;
2241
  ```
2242
 
2243
  *Effects:* Equivalent to: `return y.length;`
2244
 
2245
  ``` cpp
2246
  constexpr counted_iterator& operator-=(iter_difference_t<I> n)
2247
  requires random_access_iterator<I>;
2248
  ```
2249
 
2250
+ `-n <= length` is `true`.
2251
 
2252
  *Effects:* Equivalent to:
2253
 
2254
  ``` cpp
2255
  current -= n;
 
2270
 
2271
  *Effects:* Equivalent to: `return x.length == y.length;`
2272
 
2273
  ``` cpp
2274
  friend constexpr bool operator==(
2275
+ const counted_iterator& x, default_sentinel_t) noexcept;
2276
  ```
2277
 
2278
  *Effects:* Equivalent to: `return x.length == 0;`
2279
 
2280
  ``` cpp
 
2292
  because `length` counts down, not up. — *end note*]
2293
 
2294
  #### Customizations <a id="counted.iter.cust">[[counted.iter.cust]]</a>
2295
 
2296
  ``` cpp
2297
+ friend constexpr decltype(auto)
2298
  iter_move(const counted_iterator& i)
2299
  noexcept(noexcept(ranges::iter_move(i.current)))
2300
  requires input_iterator<I>;
2301
  ```
2302
 
2303
+ `i.length > 0` is `true`.
2304
 
2305
  *Effects:* Equivalent to: `return ranges::iter_move(i.current);`
2306
 
2307
  ``` cpp
2308
  template<indirectly_swappable<I> I2>
2309
  friend constexpr void
2310
  iter_swap(const counted_iterator& x, const counted_iterator<I2>& y)
2311
  noexcept(noexcept(ranges::iter_swap(x.current, y.current)));
2312
  ```
2313
 
2314
+ Both `x.length > 0` and `y.length > 0` are `true`.
2315
 
2316
  *Effects:* Equivalent to `ranges::iter_swap(x.current, y.current)`.
2317
 
2318
  ### Unreachable sentinel <a id="unreachable.sentinel">[[unreachable.sentinel]]</a>
2319