From Jason Turner

[optional.ctor]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvaew1ehc/{from.md → to.md} +62 -58
tmp/tmpvaew1ehc/{from.md → to.md} RENAMED
@@ -3,125 +3,116 @@
3
  ``` cpp
4
  constexpr optional() noexcept;
5
  constexpr optional(nullopt_t) noexcept;
6
  ```
7
 
8
- *Postconditions:* `*this` does not contain a value.
9
 
10
  *Remarks:* No contained value is initialized. For every object type `T`
11
- these constructors shall be 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
- *Postconditions:* `bool(rhs) == bool(*this)`.
22
 
23
  *Throws:* Any exception thrown by the selected constructor of `T`.
24
 
25
- *Remarks:* This constructor shall be defined as deleted unless
26
  `is_copy_constructible_v<T>` is `true`. If
27
- `is_trivially_copy_constructible_v<T>` is `true`, this constructor shall
28
- be a `constexpr` constructor.
29
 
30
  ``` cpp
31
  constexpr optional(optional&& rhs) noexcept(see below);
32
  ```
33
 
 
 
34
  *Effects:* If `rhs` contains a value, initializes the contained value as
35
  if direct-non-list-initializing an object of type `T` with the
36
  expression `std::move(*rhs)`. `bool(rhs)` is unchanged.
37
 
38
- *Postconditions:* `bool(rhs) == bool(*this)`.
39
 
40
  *Throws:* Any exception thrown by the selected constructor of `T`.
41
 
42
  *Remarks:* The expression inside `noexcept` is equivalent to
43
- `is_nothrow_move_constructible_v<T>`. This constructor shall not
44
- participate in overload resolution unless `is_move_constructible_v<T>`
45
- is `true`. If `is_trivially_move_constructible_v<T>` is `true`, this
46
- constructor shall be a `constexpr` constructor.
47
 
48
  ``` cpp
49
  template<class... Args> constexpr explicit optional(in_place_t, Args&&... args);
50
  ```
51
 
 
 
52
  *Effects:* Initializes the contained value as if
53
  direct-non-list-initializing an object of type `T` with the arguments
54
  `std::forward<Args>(args)...`.
55
 
56
- *Postconditions:* `*this` contains a value.
57
 
58
  *Throws:* Any exception thrown by the selected constructor of `T`.
59
 
60
  *Remarks:* If `T`’s constructor selected for the initialization is a
61
- constexpr constructor, this constructor shall be a constexpr
62
- constructor. This constructor shall not participate in overload
63
- resolution unless `is_constructible_v<T, Args...>` is `true`.
64
 
65
  ``` cpp
66
  template<class U, class... Args>
67
  constexpr explicit optional(in_place_t, initializer_list<U> il, Args&&... args);
68
  ```
69
 
 
 
 
70
  *Effects:* Initializes the contained value as if
71
  direct-non-list-initializing an object of type `T` with the arguments
72
  `il, std::forward<Args>(args)...`.
73
 
74
- *Postconditions:* `*this` contains a value.
75
 
76
  *Throws:* Any exception thrown by the selected constructor of `T`.
77
 
78
- *Remarks:* This constructor shall not participate in overload resolution
79
- unless `is_constructible_v<T, initializer_list<U>&, Args&&...>` is
80
- `true`. If `T`’s constructor selected for the initialization is a
81
- constexpr constructor, this constructor shall be a constexpr
82
- constructor.
83
-
84
- [*Note 1*: The following constructors are conditionally specified as
85
- explicit. This is typically implemented by declaring two such
86
- constructors, of which at most one participates in overload
87
- resolution. — *end note*]
88
 
89
  ``` cpp
90
- template <class U = T> \EXPLICIT constexpr optional(U&& v);
91
  ```
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
- *Postconditions:* `*this` contains a value.
98
 
99
  *Throws:* Any exception thrown by the selected constructor of `T`.
100
 
101
  *Remarks:* If `T`’s selected constructor is a constexpr constructor,
102
- this constructor shall be a constexpr constructor. This constructor
103
- shall not participate in overload resolution unless
104
- `is_constructible_v<T, U&&>` is `true`,
105
- `is_same_v<decay_t<U>, in_place_t>` is `false`, and
106
- `is_same_v<optional<T>, decay_t<U>>` is `false`. The constructor is
107
- explicit if and only if `is_convertible_v<U&&, T>` is `false`.
108
 
109
  ``` cpp
110
- template <class U> \EXPLICIT optional(const optional<U>& rhs);
111
  ```
112
 
113
- *Effects:* If `rhs` contains a value, initializes the contained value as
114
- if direct-non-list-initializing an object of type `T` with the
115
- expression `*rhs`.
116
-
117
- *Postconditions:* `bool(rhs)` == `bool(*this)`.
118
-
119
- *Throws:* Any exception thrown by the selected constructor of `T`.
120
 
121
- *Remarks:* This constructor shall not participate in overload resolution
122
- unless
123
 
124
  - `is_constructible_v<T, const U&>` is `true`,
125
  - `is_constructible_v<T, optional<U>&>` is `false`,
126
  - `is_constructible_v<T, optional<U>&&>` is `false`,
127
  - `is_constructible_v<T, const optional<U>&>` is `false`,
@@ -129,36 +120,49 @@ unless
129
  - `is_convertible_v<optional<U>&, T>` is `false`,
130
  - `is_convertible_v<optional<U>&&, T>` is `false`,
131
  - `is_convertible_v<const optional<U>&, T>` is `false`, and
132
  - `is_convertible_v<const optional<U>&&, T>` is `false`.
133
 
134
- The constructor is explicit if and only if
135
- `is_convertible_v<const U&, T>` is `false`.
136
-
137
- ``` cpp
138
- template <class U> \EXPLICIT optional(optional<U>&& rhs);
139
- ```
140
-
141
  *Effects:* If `rhs` contains a value, initializes the contained value as
142
  if direct-non-list-initializing an object of type `T` with the
143
- expression `std::move(*rhs)`. `bool(rhs)` is unchanged.
144
 
145
- *Postconditions:* `bool(rhs)` == `bool(*this)`.
146
 
147
  *Throws:* Any exception thrown by the selected constructor of `T`.
148
 
149
- *Remarks:* This constructor shall not participate in overload resolution
150
- unless
151
 
152
- - `is_constructible_v<T, U&&>` is true,
 
 
 
 
 
 
 
 
 
 
153
  - `is_constructible_v<T, optional<U>&>` is `false`,
154
  - `is_constructible_v<T, optional<U>&&>` is `false`,
155
  - `is_constructible_v<T, const optional<U>&>` is `false`,
156
  - `is_constructible_v<T, const optional<U>&&>` is `false`,
157
  - `is_convertible_v<optional<U>&, T>` is `false`,
158
  - `is_convertible_v<optional<U>&&, T>` is `false`,
159
  - `is_convertible_v<const optional<U>&, T>` is `false`, and
160
  - `is_convertible_v<const optional<U>&&, T>` is `false`.
161
 
162
- The constructor is explicit if and only if `is_convertible_v<U&&, T>` is
163
- `false`.
 
 
 
 
 
 
 
 
 
 
 
164
 
 
3
  ``` cpp
4
  constexpr optional() noexcept;
5
  constexpr optional(nullopt_t) noexcept;
6
  ```
7
 
8
+ *Ensures:* `*this` does not contain a value.
9
 
10
  *Remarks:* No contained value is initialized. For every object type `T`
11
+ 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
27
+ `is_trivially_copy_constructible_v<T>` is `true`, this constructor is
28
+ trivial.
29
 
30
  ``` cpp
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`.
62
 
63
  *Remarks:* If `T`’s constructor selected for the initialization is a
64
+ constexpr constructor, this constructor is a constexpr constructor.
 
 
65
 
66
  ``` cpp
67
  template<class U, class... Args>
68
  constexpr explicit optional(in_place_t, initializer_list<U> il, Args&&... 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`.
81
 
82
+ *Remarks:* If `T`’s constructor selected for the initialization is a
83
+ 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`.
100
 
101
  *Remarks:* If `T`’s selected constructor is a constexpr constructor,
102
+ this constructor is a constexpr constructor. The expression inside
103
+ `explicit` is equivalent to:
 
 
 
 
104
 
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`,
 
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
+
165
+ ``` cpp
166
+ !is_convertible_v<U, T>
167
+ ```
168