From Jason Turner

[span.cons]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvrp2j0kj/{from.md → to.md} +151 -0
tmp/tmpvrp2j0kj/{from.md → to.md} RENAMED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Constructors, copy, and assignment <a id="span.cons">[[span.cons]]</a>
2
+
3
+ ``` cpp
4
+ constexpr span() noexcept;
5
+ ```
6
+
7
+ *Constraints:* `Extent == dynamic_extent || Extent == 0` is `true`.
8
+
9
+ *Ensures:* `size() == 0 && data() == nullptr`.
10
+
11
+ ``` cpp
12
+ template<class It>
13
+ constexpr explicit(extent != dynamic_extent) span(It first, size_type count);
14
+ ```
15
+
16
+ *Constraints:* Let `U` be `remove_reference_t<iter_reference_t<It>>`.
17
+
18
+ - `It` satisfies `contiguous_iterator`.
19
+ - `is_convertible_v<U(*)[], element_type(*)[]>` is `true`.
20
+ \[*Note 1*: The intent is to allow only qualification conversions of
21
+ the iterator reference type to `element_type`. — *end note*]
22
+
23
+ *Preconditions:*
24
+
25
+ - \[`first`, `first + count`) is a valid range.
26
+ - `It` models `contiguous_iterator`.
27
+ - If `extent` is not equal to `dynamic_extent`, then `count` is equal to
28
+ `extent`.
29
+
30
+ *Effects:* Initializes `data_` with `to_address(first)` and `size_` with
31
+ `count`.
32
+
33
+ *Throws:* Nothing.
34
+
35
+ ``` cpp
36
+ template<class It, class End>
37
+ constexpr explicit(extent != dynamic_extent) span(It first, End last);
38
+ ```
39
+
40
+ *Constraints:* Let `U` be `remove_reference_t<iter_reference_t<It>>`.
41
+
42
+ - `is_convertible_v<U(*)[], element_type(*)[]>` is `true`.
43
+ \[*Note 2*: The intent is to allow only qualification conversions of
44
+ the iterator reference type to `element_type`. — *end note*]
45
+ - `It` satisfies `contiguous_iterator`.
46
+ - `End` satisfies `sized_sentinel_for<It>`.
47
+ - `is_convertible_v<End, size_t>` is `false`.
48
+
49
+ *Preconditions:*
50
+
51
+ - If `extent` is not equal to `dynamic_extent`, then `last - first` is
52
+ equal to `extent`.
53
+ - \[`first`, `last`) is a valid range.
54
+ - `It` models `contiguous_iterator`.
55
+ - `End` models `sized_sentinel_for<It>`.
56
+
57
+ *Effects:* Initializes `data_` with `to_address(first)` and `size_` with
58
+ `last - first`.
59
+
60
+ *Throws:* When and what `last - first` throws.
61
+
62
+ ``` cpp
63
+ template<size_t N> constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept;
64
+ template<class T, size_t N> constexpr span(array<T, N>& arr) noexcept;
65
+ template<class T, size_t N> constexpr span(const array<T, N>& arr) noexcept;
66
+ ```
67
+
68
+ *Constraints:* Let `U` be `remove_pointer_t<decltype(data(arr))>`.
69
+
70
+ - `extent == dynamic_extent || N == extent` is `true`, and
71
+ - `is_convertible_v<U(*)[], element_type(*)[]>` is `true`.
72
+ \[*Note 3*: The intent is to allow only qualification conversions of
73
+ the array element type to `element_type`. — *end note*]
74
+
75
+ *Effects:* Constructs a `span` that is a view over the supplied array.
76
+
77
+ [*Note 1*: `type_identity_t` affects class template argument
78
+ deduction. — *end note*]
79
+
80
+ *Ensures:* `size() == N && data() == data(arr)` is `true`.
81
+
82
+ ``` cpp
83
+ template<class R> constexpr explicit(extent != dynamic_extent) span(R&& r);
84
+ ```
85
+
86
+ *Constraints:* Let `U` be
87
+ `remove_reference_t<ranges::range_reference_t<R>>`.
88
+
89
+ - `R` satisfies `ranges::contiguous_range` and `ranges::sized_range`.
90
+ - Either `R` satisfies `ranges::borrowed_range` or
91
+ `is_const_v<element_type>` is `true`.
92
+ - `remove_cvref_t<R>` is not a specialization of `span`.
93
+ - `remove_cvref_t<R>` is not a specialization of `array`.
94
+ - `is_array_v<remove_cvref_t<R>>` is `false`.
95
+ - `is_convertible_v<U(*)[], element_type(*)[]>` is `true`.
96
+ \[*Note 4*: The intent is to allow only qualification conversions of
97
+ the range reference type to `element_type`. — *end note*]
98
+
99
+ *Preconditions:*
100
+
101
+ - If `extent` is not equal to `dynamic_extent`, then `ranges::size(r)`
102
+ is equal to `extent`.
103
+ - `R` models `ranges::contiguous_range` and `ranges::sized_range`.
104
+ - If `is_const_v<element_type>` is `false`, `R` models
105
+ `ranges::borrowed_range`.
106
+
107
+ *Effects:* Initializes `data_` with `ranges::data(r)` and `size_` with
108
+ `ranges::size(r)`.
109
+
110
+ *Throws:* What and when `ranges::data(r)` and `ranges::size(r)` throw.
111
+
112
+ ``` cpp
113
+ constexpr span(const span& other) noexcept = default;
114
+ ```
115
+
116
+ *Ensures:* `other.size() == size() && other.data() == data()`.
117
+
118
+ ``` cpp
119
+ template<class OtherElementType, size_t OtherExtent>
120
+ constexpr explicit(see below) span(const span<OtherElementType, OtherExtent>& s) noexcept;
121
+ ```
122
+
123
+ *Constraints:*
124
+
125
+ - `extent == dynamic_extent` `||` `OtherExtent == dynamic_extent` `||`
126
+ `extent == OtherExtent` is `true`, and
127
+ - `is_convertible_v<OtherElementType(*)[], element_type(*)[]>` is
128
+ `true`. \[*Note 5*: The intent is to allow only qualification
129
+ conversions of the `OtherElementType` to
130
+ `element_type`. — *end note*]
131
+
132
+ *Preconditions:* If `extent` is not equal to `dynamic_extent`, then
133
+ `s.size()` is equal to `extent`.
134
+
135
+ *Effects:* Constructs a `span` that is a view over the range
136
+ \[`s.data()`, `s.data() + s.size()`).
137
+
138
+ *Ensures:* `size() == s.size() && data() == s.data()`.
139
+
140
+ *Remarks:* The expression inside `explicit` is equivalent to:
141
+
142
+ ``` cpp
143
+ extent != dynamic_extent && OtherExtent == dynamic_extent
144
+ ```
145
+
146
+ ``` cpp
147
+ constexpr span& operator=(const span& other) noexcept = default;
148
+ ```
149
+
150
+ *Ensures:* `size() == other.size() && data() == other.data()`.
151
+