From Jason Turner

[span.sub]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3g7w5ewf/{from.md → to.md} +95 -0
tmp/tmp3g7w5ewf/{from.md → to.md} RENAMED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Subviews <a id="span.sub">[[span.sub]]</a>
2
+
3
+ ``` cpp
4
+ template<size_t Count> constexpr span<element_type, Count> first() const;
5
+ ```
6
+
7
+ *Mandates:* `Count <= Extent` is `true`.
8
+
9
+ *Preconditions:* `Count <= size()` is `true`.
10
+
11
+ *Effects:* Equivalent to: `return R{data(), Count};` where `R` is the
12
+ return type.
13
+
14
+ ``` cpp
15
+ template<size_t Count> constexpr span<element_type, Count> last() const;
16
+ ```
17
+
18
+ *Mandates:* `Count <= Extent` is `true`.
19
+
20
+ *Preconditions:* `Count <= size()` is `true`.
21
+
22
+ *Effects:* Equivalent to: `return R{data() + (size() - Count), Count};`
23
+ where `R` is the return type.
24
+
25
+ ``` cpp
26
+ template<size_t Offset, size_t Count = dynamic_extent>
27
+ constexpr span<element_type, see below> subspan() const;
28
+ ```
29
+
30
+ *Mandates:*
31
+
32
+ ``` cpp
33
+ Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset)
34
+ ```
35
+
36
+ is `true`.
37
+
38
+ *Preconditions:*
39
+
40
+ ``` cpp
41
+ Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset)
42
+ ```
43
+
44
+ is `true`.
45
+
46
+ *Effects:* Equivalent to:
47
+
48
+ ``` cpp
49
+ return span<ElementType, see below>(
50
+ data() + Offset, Count != dynamic_extent ? Count : size() - Offset);
51
+ ```
52
+
53
+ *Remarks:* The second template argument of the returned `span` type is:
54
+
55
+ ``` cpp
56
+ Count != dynamic_extent ? Count
57
+ : (Extent != dynamic_extent ? Extent - Offset
58
+ : dynamic_extent)
59
+ ```
60
+
61
+ ``` cpp
62
+ constexpr span<element_type, dynamic_extent> first(size_type count) const;
63
+ ```
64
+
65
+ *Preconditions:* `count <= size()` is `true`.
66
+
67
+ *Effects:* Equivalent to: `return {data(), count};`
68
+
69
+ ``` cpp
70
+ constexpr span<element_type, dynamic_extent> last(size_type count) const;
71
+ ```
72
+
73
+ *Preconditions:* `count <= size()` is `true`.
74
+
75
+ *Effects:* Equivalent to: `return {data() + (size() - count), count};`
76
+
77
+ ``` cpp
78
+ constexpr span<element_type, dynamic_extent> subspan(
79
+ size_type offset, size_type count = dynamic_extent) const;
80
+ ```
81
+
82
+ *Preconditions:*
83
+
84
+ ``` cpp
85
+ offset <= size() && (count == dynamic_extent || count <= size() - offset)
86
+ ```
87
+
88
+ is `true`.
89
+
90
+ *Effects:* Equivalent to:
91
+
92
+ ``` cpp
93
+ return {data() + offset, count == dynamic_extent ? size() - offset : count};
94
+ ```
95
+