From Jason Turner

[range.single]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp07tcn23m/{from.md → to.md} +97 -0
tmp/tmp07tcn23m/{from.md → to.md} RENAMED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Single view <a id="range.single">[[range.single]]</a>
2
+
3
+ #### Overview <a id="range.single.overview">[[range.single.overview]]</a>
4
+
5
+ `single_view` produces a `view` that contains exactly one element of a
6
+ specified value.
7
+
8
+ The name `views::single` denotes a customization point object
9
+ [[customization.point.object]]. Given a subexpression `E`, the
10
+ expression `views::single(E)` is expression-equivalent to
11
+ `single_view{E}`.
12
+
13
+ [*Example 1*:
14
+
15
+ ``` cpp
16
+ single_view s{4};
17
+ for (int i : s)
18
+ cout << i; // prints 4
19
+ ```
20
+
21
+ — *end example*]
22
+
23
+ #### Class template `single_view` <a id="range.single.view">[[range.single.view]]</a>
24
+
25
+ ``` cpp
26
+ namespace std::ranges {
27
+ template<copy_constructible T>
28
+ requires is_object_v<T>
29
+ class single_view : public view_interface<single_view<T>> {
30
+ private:
31
+ semiregular-box<T> value_; // exposition only{} (see [range.semi.wrap])
32
+ public:
33
+ single_view() = default;
34
+ constexpr explicit single_view(const T& t);
35
+ constexpr explicit single_view(T&& t);
36
+ template<class... Args>
37
+ requires constructible_from<T, Args...>
38
+ constexpr single_view(in_place_t, Args&&... args);
39
+
40
+ constexpr T* begin() noexcept;
41
+ constexpr const T* begin() const noexcept;
42
+ constexpr T* end() noexcept;
43
+ constexpr const T* end() const noexcept;
44
+ static constexpr size_t size() noexcept;
45
+ constexpr T* data() noexcept;
46
+ constexpr const T* data() const noexcept;
47
+ };
48
+ }
49
+ ```
50
+
51
+ ``` cpp
52
+ constexpr explicit single_view(const T& t);
53
+ ```
54
+
55
+ *Effects:* Initializes *value\_* with `t`.
56
+
57
+ ``` cpp
58
+ constexpr explicit single_view(T&& t);
59
+ ```
60
+
61
+ *Effects:* Initializes *value\_* with `std::move(t)`.
62
+
63
+ ``` cpp
64
+ template<class... Args>
65
+ constexpr single_view(in_place_t, Args&&... args);
66
+ ```
67
+
68
+ *Effects:* Initializes *value\_* as if by
69
+ *`value_`*`{in_place, std::forward<Args>(args)...}`.
70
+
71
+ ``` cpp
72
+ constexpr T* begin() noexcept;
73
+ constexpr const T* begin() const noexcept;
74
+ ```
75
+
76
+ *Effects:* Equivalent to: `return data();`
77
+
78
+ ``` cpp
79
+ constexpr T* end() noexcept;
80
+ constexpr const T* end() const noexcept;
81
+ ```
82
+
83
+ *Effects:* Equivalent to: `return data() + 1;`
84
+
85
+ ``` cpp
86
+ static constexpr size_t size() noexcept;
87
+ ```
88
+
89
+ *Effects:* Equivalent to: `return 1;`
90
+
91
+ ``` cpp
92
+ constexpr T* data() noexcept;
93
+ constexpr const T* data() const noexcept;
94
+ ```
95
+
96
+ *Effects:* Equivalent to: `return `*`value_`*`.operator->();`
97
+