From Jason Turner

[range.adjacent]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6dmj_n7w/{from.md → to.md} +20 -1
tmp/tmp6dmj_n7w/{from.md → to.md} RENAMED
@@ -10,11 +10,12 @@ resulting view is empty.
10
  The name `views::adjacent<N>` denotes a range adaptor object
11
  [[range.adaptor.object]]. Given a subexpression `E` and a constant
12
  expression `N`, the expression `views::adjacent<N>(E)` is
13
  expression-equivalent to
14
 
15
- - `((void)E, auto(views::empty<tuple<>>))` if `N` is equal to `0`,
 
16
  - otherwise, `adjacent_view<views::all_t<decltype((E))>, N>(E)`.
17
 
18
  [*Example 1*:
19
 
20
  ``` cpp
@@ -78,10 +79,13 @@ namespace std::ranges {
78
  }
79
  }
80
 
81
  constexpr auto size() requires sized_range<V>;
82
  constexpr auto size() const requires sized_range<const V>;
 
 
 
83
  };
84
  }
85
  ```
86
 
87
  ``` cpp
@@ -103,10 +107,25 @@ using CT = common_type_t<ST, size_t>;
103
  auto sz = static_cast<CT>(ranges::size(base_));
104
  sz -= std::min<CT>(sz, N - 1);
105
  return static_cast<ST>(sz);
106
  ```
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  #### Class template `adjacent_view::iterator` <a id="range.adjacent.iterator">[[range.adjacent.iterator]]</a>
109
 
110
  ``` cpp
111
  namespace std::ranges {
112
  template<forward_range V, size_t N>
 
10
  The name `views::adjacent<N>` denotes a range adaptor object
11
  [[range.adaptor.object]]. Given a subexpression `E` and a constant
12
  expression `N`, the expression `views::adjacent<N>(E)` is
13
  expression-equivalent to
14
 
15
+ - `((void)E, auto(views::empty<tuple<>>))` if `N` is equal to `0` and
16
+ `decltype((E))` models `forward_range`,
17
  - otherwise, `adjacent_view<views::all_t<decltype((E))>, N>(E)`.
18
 
19
  [*Example 1*:
20
 
21
  ``` cpp
 
79
  }
80
  }
81
 
82
  constexpr auto size() requires sized_range<V>;
83
  constexpr auto size() const requires sized_range<const V>;
84
+
85
+ constexpr auto reserve_hint() requires approximately_sized_range<V>;
86
+ constexpr auto reserve_hint() const requires approximately_sized_range<const V>;
87
  };
88
  }
89
  ```
90
 
91
  ``` cpp
 
107
  auto sz = static_cast<CT>(ranges::size(base_));
108
  sz -= std::min<CT>(sz, N - 1);
109
  return static_cast<ST>(sz);
110
  ```
111
 
112
+ ``` cpp
113
+ constexpr auto reserve_hint() requires approximately_sized_range<V>;
114
+ constexpr auto reserve_hint() const requires approximately_sized_range<const V>;
115
+ ```
116
+
117
+ *Effects:* Equivalent to:
118
+
119
+ ``` cpp
120
+ using DT = range_difference_t<decltype((base_))>;
121
+ using CT = common_type_t<DT, size_t>;
122
+ auto sz = static_cast<CT>(ranges::reserve_hint(base_));
123
+ sz -= std::min<CT>(sz, N - 1);
124
+ return to-unsigned-like(sz);
125
+ ```
126
+
127
  #### Class template `adjacent_view::iterator` <a id="range.adjacent.iterator">[[range.adjacent.iterator]]</a>
128
 
129
  ``` cpp
130
  namespace std::ranges {
131
  template<forward_range V, size_t N>