From Jason Turner

[optional.ctor]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6l70gket/{from.md → to.md} +43 -46
tmp/tmp6l70gket/{from.md → to.md} RENAMED
@@ -1,7 +1,19 @@
1
  #### Constructors <a id="optional.ctor">[[optional.ctor]]</a>
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ``` cpp
4
  constexpr optional() noexcept;
5
  constexpr optional(nullopt_t) noexcept;
6
  ```
7
 
@@ -12,15 +24,14 @@ these constructors are constexpr constructors [[dcl.constexpr]].
12
 
13
  ``` cpp
14
  constexpr optional(const optional& rhs);
15
  ```
16
 
17
- *Effects:* If `rhs` contains a value, initializes the contained value as
18
- if direct-non-list-initializing an object of type `T` with the
19
- expression `*rhs`.
20
 
21
- *Ensures:* `bool(rhs) == bool(*this)`.
22
 
23
  *Throws:* Any exception thrown by the selected constructor of `T`.
24
 
25
  *Remarks:* This constructor is defined as deleted unless
26
  `is_copy_constructible_v<T>` is `true`. If
@@ -31,31 +42,29 @@ trivial.
31
  constexpr optional(optional&& rhs) noexcept(see below);
32
  ```
33
 
34
  *Constraints:* `is_move_constructible_v<T>` is `true`.
35
 
36
- *Effects:* If `rhs` contains a value, initializes the contained value as
37
- if direct-non-list-initializing an object of type `T` with the
38
- expression `std::move(*rhs)`. `bool(rhs)` is unchanged.
39
 
40
- *Ensures:* `bool(rhs) == bool(*this)`.
41
 
42
  *Throws:* Any exception thrown by the selected constructor of `T`.
43
 
44
- *Remarks:* The expression inside `noexcept` is equivalent to
45
  `is_nothrow_move_constructible_v<T>`. If
46
  `is_trivially_move_constructible_v<T>` is `true`, this constructor is
47
  trivial.
48
 
49
  ``` cpp
50
  template<class... Args> constexpr explicit optional(in_place_t, Args&&... args);
51
  ```
52
 
53
  *Constraints:* `is_constructible_v<T, Args...>` is `true`.
54
 
55
- *Effects:* Initializes the contained value as if
56
- direct-non-list-initializing an object of type `T` with the arguments
57
  `std::forward<Args>(args)...`.
58
 
59
  *Ensures:* `*this` contains a value.
60
 
61
  *Throws:* Any exception thrown by the selected constructor of `T`.
@@ -69,12 +78,11 @@ template<class U, class... Args>
69
  ```
70
 
71
  *Constraints:* `is_constructible_v<T, initializer_list<U>&, Args...>` is
72
  `true`.
73
 
74
- *Effects:* Initializes the contained value as if
75
- direct-non-list-initializing an object of type `T` with the arguments
76
  `il, std::forward<Args>(args)...`.
77
 
78
  *Ensures:* `*this` contains a value.
79
 
80
  *Throws:* Any exception thrown by the selected constructor of `T`.
@@ -84,16 +92,19 @@ constexpr constructor, this constructor is a constexpr constructor.
84
 
85
  ``` cpp
86
  template<class U = T> constexpr explicit(see below) optional(U&& v);
87
  ```
88
 
89
- *Constraints:* `is_constructible_v<T, U>` is `true`,
90
- `is_same_v<remove_cvref_t<U>, in_place_t>` is `false`, and
91
- `is_same_v<remove_cvref_t<U>, optional>` is `false`.
92
 
93
- *Effects:* Initializes the contained value as if
94
- direct-non-list-initializing an object of type `T` with the expression
 
 
 
 
 
95
  `std::forward<U>(v)`.
96
 
97
  *Ensures:* `*this` contains a value.
98
 
99
  *Throws:* Any exception thrown by the selected constructor of `T`.
@@ -105,60 +116,46 @@ this constructor is a constexpr constructor. The expression inside
105
  ``` cpp
106
  !is_convertible_v<U, T>
107
  ```
108
 
109
  ``` cpp
110
- template<class U> explicit(see below) optional(const optional<U>& rhs);
111
  ```
112
 
113
  *Constraints:*
114
 
115
- - `is_constructible_v<T, const U&>` is `true`,
116
- - `is_constructible_v<T, optional<U>&>` is `false`,
117
- - `is_constructible_v<T, optional<U>&&>` is `false`,
118
- - `is_constructible_v<T, const optional<U>&>` is `false`,
119
- - `is_constructible_v<T, const optional<U>&&>` is `false`,
120
- - `is_convertible_v<optional<U>&, T>` is `false`,
121
- - `is_convertible_v<optional<U>&&, T>` is `false`,
122
- - `is_convertible_v<const optional<U>&, T>` is `false`, and
123
- - `is_convertible_v<const optional<U>&&, T>` is `false`.
124
 
125
- *Effects:* If `rhs` contains a value, initializes the contained value as
126
- if direct-non-list-initializing an object of type `T` with the
127
- expression `*rhs`.
128
 
129
- *Ensures:* `bool(rhs)` == `bool(*this)`.
130
 
131
  *Throws:* Any exception thrown by the selected constructor of `T`.
132
 
133
  *Remarks:* The expression inside `explicit` is equivalent to:
134
 
135
  ``` cpp
136
  !is_convertible_v<const U&, T>
137
  ```
138
 
139
  ``` cpp
140
- template<class U> explicit(see below) optional(optional<U>&& rhs);
141
  ```
142
 
143
  *Constraints:*
144
 
145
- - `is_constructible_v<T, U>` is true,
146
- - `is_constructible_v<T, optional<U>&>` is `false`,
147
- - `is_constructible_v<T, optional<U>&&>` is `false`,
148
- - `is_constructible_v<T, const optional<U>&>` is `false`,
149
- - `is_constructible_v<T, const optional<U>&&>` is `false`,
150
- - `is_convertible_v<optional<U>&, T>` is `false`,
151
- - `is_convertible_v<optional<U>&&, T>` is `false`,
152
- - `is_convertible_v<const optional<U>&, T>` is `false`, and
153
- - `is_convertible_v<const optional<U>&&, T>` is `false`.
154
 
155
- *Effects:* If `rhs` contains a value, initializes the contained value as
156
- if direct-non-list-initializing an object of type `T` with the
157
- expression `std::move(*rhs)`. `bool(rhs)` is unchanged.
158
 
159
- *Ensures:* `bool(rhs)` == `bool(*this)`.
160
 
161
  *Throws:* Any exception thrown by the selected constructor of `T`.
162
 
163
  *Remarks:* The expression inside `explicit` is equivalent to:
164
 
 
1
  #### Constructors <a id="optional.ctor">[[optional.ctor]]</a>
2
 
3
+ The exposition-only variable template *`converts-from-any-cvref`* is
4
+ used by some constructors for `optional`.
5
+
6
+ ``` cpp
7
+ template<class T, class W>
8
+ constexpr bool converts-from-any-cvref = // exposition only
9
+ disjunction_v<is_constructible<T, W&>, is_convertible<W&, T>,
10
+ is_constructible<T, W>, is_convertible<W, T>,
11
+ is_constructible<T, const W&>, is_convertible<const W&, T>,
12
+ is_constructible<T, const W>, is_convertible<const W, T>>;
13
+ ```
14
+
15
  ``` cpp
16
  constexpr optional() noexcept;
17
  constexpr optional(nullopt_t) noexcept;
18
  ```
19
 
 
24
 
25
  ``` cpp
26
  constexpr optional(const optional& rhs);
27
  ```
28
 
29
+ *Effects:* If `rhs` contains a value, direct-non-list-initializes the
30
+ contained value with `*rhs`.
 
31
 
32
+ *Ensures:* `rhs.has_value() == this->has_value()`.
33
 
34
  *Throws:* Any exception thrown by the selected constructor of `T`.
35
 
36
  *Remarks:* This constructor is defined as deleted unless
37
  `is_copy_constructible_v<T>` is `true`. If
 
42
  constexpr optional(optional&& rhs) noexcept(see below);
43
  ```
44
 
45
  *Constraints:* `is_move_constructible_v<T>` is `true`.
46
 
47
+ *Effects:* If `rhs` contains a value, direct-non-list-initializes the
48
+ contained value with `std::move(*rhs)`. `rhs.has_value()` is unchanged.
 
49
 
50
+ *Ensures:* `rhs.has_value() == this->has_value()`.
51
 
52
  *Throws:* Any exception thrown by the selected constructor of `T`.
53
 
54
+ *Remarks:* The exception specification is equivalent to
55
  `is_nothrow_move_constructible_v<T>`. If
56
  `is_trivially_move_constructible_v<T>` is `true`, this constructor is
57
  trivial.
58
 
59
  ``` cpp
60
  template<class... Args> constexpr explicit optional(in_place_t, Args&&... args);
61
  ```
62
 
63
  *Constraints:* `is_constructible_v<T, Args...>` is `true`.
64
 
65
+ *Effects:* Direct-non-list-initializes the contained value with
 
66
  `std::forward<Args>(args)...`.
67
 
68
  *Ensures:* `*this` contains a value.
69
 
70
  *Throws:* Any exception thrown by the selected constructor of `T`.
 
78
  ```
79
 
80
  *Constraints:* `is_constructible_v<T, initializer_list<U>&, Args...>` is
81
  `true`.
82
 
83
+ *Effects:* Direct-non-list-initializes the contained value with
 
84
  `il, std::forward<Args>(args)...`.
85
 
86
  *Ensures:* `*this` contains a value.
87
 
88
  *Throws:* Any exception thrown by the selected constructor of `T`.
 
92
 
93
  ``` cpp
94
  template<class U = T> constexpr explicit(see below) optional(U&& v);
95
  ```
96
 
97
+ *Constraints:*
 
 
98
 
99
+ - `is_constructible_v<T, U>` is `true`,
100
+ - `is_same_v<remove_cvref_t<U>, in_place_t>` is `false`,
101
+ - `is_same_v<remove_cvref_t<U>, optional>` is `false`, and
102
+ - if `T` is cv `bool`, `remove_cvref_t<U>` is not a specialization of
103
+ `optional`.
104
+
105
+ *Effects:* Direct-non-list-initializes the contained value with
106
  `std::forward<U>(v)`.
107
 
108
  *Ensures:* `*this` contains a value.
109
 
110
  *Throws:* Any exception thrown by the selected constructor of `T`.
 
116
  ``` cpp
117
  !is_convertible_v<U, T>
118
  ```
119
 
120
  ``` cpp
121
+ template<class U> constexpr explicit(see below) optional(const optional<U>& rhs);
122
  ```
123
 
124
  *Constraints:*
125
 
126
+ - `is_constructible_v<T, const U&>` is `true`, and
127
+ - if `T` is not cv `bool`, *`converts-from-any-cvref`*`<T, optional<U>>`
128
+ is `false`.
 
 
 
 
 
 
129
 
130
+ *Effects:* If `rhs` contains a value, direct-non-list-initializes the
131
+ contained value with `*rhs`.
 
132
 
133
+ *Ensures:* `rhs.has_value() == this->has_value()`.
134
 
135
  *Throws:* Any exception thrown by the selected constructor of `T`.
136
 
137
  *Remarks:* The expression inside `explicit` is equivalent to:
138
 
139
  ``` cpp
140
  !is_convertible_v<const U&, T>
141
  ```
142
 
143
  ``` cpp
144
+ template<class U> constexpr explicit(see below) optional(optional<U>&& rhs);
145
  ```
146
 
147
  *Constraints:*
148
 
149
+ - `is_constructible_v<T, U>` is `true`, and
150
+ - if `T` is not cv `bool`, *`converts-from-any-cvref`*`<T, optional<U>>`
151
+ is `false`.
 
 
 
 
 
 
152
 
153
+ *Effects:* If `rhs` contains a value, direct-non-list-initializes the
154
+ contained value with `std::move(*rhs)`. `rhs.has_value()` is unchanged.
 
155
 
156
+ *Ensures:* `rhs.has_value() == this->has_value()`.
157
 
158
  *Throws:* Any exception thrown by the selected constructor of `T`.
159
 
160
  *Remarks:* The expression inside `explicit` is equivalent to:
161