From Jason Turner

[iterator.operations]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9uukqh3f/{from.md → to.md} +9 -11
tmp/tmp9uukqh3f/{from.md → to.md} RENAMED
@@ -9,31 +9,29 @@ iterators they use `++` to provide linear time implementations.
9
  ``` cpp
10
  template<class InputIterator, class Distance>
11
  constexpr void advance(InputIterator& i, Distance n);
12
  ```
13
 
14
- *Requires:* `n` shall be negative only for bidirectional and random
15
- access iterators.
16
 
17
- *Effects:* Increments (or decrements for negative `n`) iterator
18
- reference `i` by `n`.
19
 
20
  ``` cpp
21
  template<class InputIterator>
22
  constexpr typename iterator_traits<InputIterator>::difference_type
23
  distance(InputIterator first, InputIterator last);
24
  ```
25
 
26
- *Effects:* If `InputIterator` meets the requirements of random access
27
- iterator, returns `(last - first)`; otherwise, returns the number of
 
 
 
 
28
  increments needed to get from `first` to `last`.
29
 
30
- *Requires:* If `InputIterator` meets the requirements of random access
31
- iterator, `last` shall be reachable from `first` or `first` shall be
32
- reachable from `last`; otherwise, `last` shall be reachable from
33
- `first`.
34
-
35
  ``` cpp
36
  template<class InputIterator>
37
  constexpr InputIterator next(InputIterator x,
38
  typename iterator_traits<InputIterator>::difference_type n = 1);
39
  ```
 
9
  ``` cpp
10
  template<class InputIterator, class Distance>
11
  constexpr void advance(InputIterator& i, Distance n);
12
  ```
13
 
14
+ *Preconditions:* `n` is negative only for bidirectional iterators.
 
15
 
16
+ *Effects:* Increments `i` by `n` if `n` is non-negative, and decrements
17
+ `i` by `-n` otherwise.
18
 
19
  ``` cpp
20
  template<class InputIterator>
21
  constexpr typename iterator_traits<InputIterator>::difference_type
22
  distance(InputIterator first, InputIterator last);
23
  ```
24
 
25
+ *Preconditions:* `last` is reachable from `first`, or `InputIterator`
26
+ meets the *Cpp17RandomAccessIterator* requirements and `first` is
27
+ reachable from `last`.
28
+
29
+ *Effects:* If `InputIterator` meets the *Cpp17RandomAccessIterator*
30
+ requirements, returns `(last - first)`; otherwise, returns the number of
31
  increments needed to get from `first` to `last`.
32
 
 
 
 
 
 
33
  ``` cpp
34
  template<class InputIterator>
35
  constexpr InputIterator next(InputIterator x,
36
  typename iterator_traits<InputIterator>::difference_type n = 1);
37
  ```