From Jason Turner

[range.subrange.ctor]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpngnli9bd/{from.md → to.md} +49 -0
tmp/tmpngnli9bd/{from.md → to.md} RENAMED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Constructors and conversions <a id="range.subrange.ctor">[[range.subrange.ctor]]</a>
2
+
3
+ ``` cpp
4
+ constexpr subrange(convertible-to-non-slicing<I> auto i, S s) requires (!StoreSize);
5
+ ```
6
+
7
+ *Preconditions:* \[`i`, `s`) is a valid range.
8
+
9
+ *Effects:* Initializes *begin\_* with `std::move(i)` and *end\_* with
10
+ `s`.
11
+
12
+ ``` cpp
13
+ constexpr subrange(convertible-to-non-slicing<I> auto i, S s,
14
+ make-unsigned-like-t<iter_difference_t<I>> n)
15
+ requires (K == subrange_kind::sized);
16
+ ```
17
+
18
+ *Preconditions:* \[`i`, `s`) is a valid range, and
19
+ `n == `*`to-unsigned-like`*`(ranges::distance(i, s))`.
20
+
21
+ *Effects:* Initializes *begin\_* with `std::move(i)` and *end\_* with
22
+ `s`. If *StoreSize* is `true`, initializes *size\_* with `n`.
23
+
24
+ [*Note 1*: Accepting the length of the range and storing it to later
25
+ return from `size()` enables `subrange` to model `sized_range` even when
26
+ it stores an iterator and sentinel that do not model
27
+ `sized_sentinel_for`. — *end note*]
28
+
29
+ ``` cpp
30
+ template<not-same-as<subrange> R>
31
+ requires borrowed_range<R> &&
32
+ convertible-to-non-slicing<iterator_t<R>, I> &&
33
+ convertible_to<sentinel_t<R>, S>
34
+ constexpr subrange(R&& r) requires (!StoreSize || sized_range<R>);
35
+ ```
36
+
37
+ *Effects:* Equivalent to:
38
+
39
+ - If *StoreSize* is `true`, `subrange{r, ranges::size(r)}`.
40
+ - Otherwise, `subrange{ranges::begin(r), ranges::end(r)}`.
41
+
42
+ ``` cpp
43
+ template<not-same-as<subrange> PairLike>
44
+ requires pair-like-convertible-from<PairLike, const I&, const S&>
45
+ constexpr operator PairLike() const;
46
+ ```
47
+
48
+ *Effects:* Equivalent to: `return PairLike(`*`begin_`*`, `*`end_`*`);`
49
+