tmp/tmpfu6yhq7e/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
## Storage for any type <a id="any">[[any]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
operations on objects of a discriminated type.
|
| 5 |
|
| 6 |
-
[
|
|
|
|
|
|
|
|
|
|
| 7 |
but does not attempt conversion between them, i.e., `5` is held strictly
|
| 8 |
as an `int` and is not implicitly convertible either to `"5"` or to
|
| 9 |
`5.0`. This indifference to interpretation but awareness of type
|
| 10 |
effectively allows safe, generic containers of single values, with no
|
| 11 |
scope for surprises from ambiguous conversions. — *end note*]
|
|
@@ -43,15 +45,17 @@ namespace std {
|
|
| 43 |
```
|
| 44 |
|
| 45 |
### Class `bad_any_cast` <a id="any.bad.any.cast">[[any.bad.any.cast]]</a>
|
| 46 |
|
| 47 |
``` cpp
|
|
|
|
| 48 |
class bad_any_cast : public bad_cast {
|
| 49 |
public:
|
| 50 |
// see [exception] for the specification of the special member functions
|
| 51 |
const char* what() const noexcept override;
|
| 52 |
};
|
|
|
|
| 53 |
```
|
| 54 |
|
| 55 |
Objects of type `bad_any_cast` are thrown by a failed `any_cast`
|
| 56 |
[[any.nonmembers]].
|
| 57 |
|
|
@@ -61,10 +65,12 @@ const char* what() const noexcept override;
|
|
| 61 |
|
| 62 |
*Returns:* An *implementation-defined* NTBS.
|
| 63 |
|
| 64 |
### Class `any` <a id="any.class">[[any.class]]</a>
|
| 65 |
|
|
|
|
|
|
|
| 66 |
``` cpp
|
| 67 |
namespace std {
|
| 68 |
class any {
|
| 69 |
public:
|
| 70 |
// [any.cons], construction and destruction
|
|
@@ -181,13 +187,12 @@ Let `VT` be `decay_t<T>`.
|
|
| 181 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 182 |
`is_constructible_v<VT, Args...>` is `true`.
|
| 183 |
|
| 184 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 185 |
|
| 186 |
-
*Effects:*
|
| 187 |
-
|
| 188 |
-
`std::forward<Args>(args)...`.
|
| 189 |
|
| 190 |
*Ensures:* `*this` contains a value of type `VT`.
|
| 191 |
|
| 192 |
*Throws:* Any exception thrown by the selected constructor of `VT`.
|
| 193 |
|
|
@@ -201,13 +206,12 @@ Let `VT` be `decay_t<T>`.
|
|
| 201 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 202 |
`is_constructible_v<VT, initializer_list<U>&, Args...>` is `true`.
|
| 203 |
|
| 204 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 205 |
|
| 206 |
-
*Effects:*
|
| 207 |
-
|
| 208 |
-
`il, std::forward<Args>(args)...`.
|
| 209 |
|
| 210 |
*Ensures:* `*this` contains a value.
|
| 211 |
|
| 212 |
*Throws:* Any exception thrown by the selected constructor of `VT`.
|
| 213 |
|
|
@@ -235,15 +239,15 @@ contained value.
|
|
| 235 |
any& operator=(any&& rhs) noexcept;
|
| 236 |
```
|
| 237 |
|
| 238 |
*Effects:* As if by `any(std::move(rhs)).swap(*this)`.
|
| 239 |
|
| 240 |
-
*Returns:* `*this`.
|
| 241 |
-
|
| 242 |
*Ensures:* The state of `*this` is equivalent to the original state of
|
| 243 |
`rhs`.
|
| 244 |
|
|
|
|
|
|
|
| 245 |
``` cpp
|
| 246 |
template<class T>
|
| 247 |
any& operator=(T&& rhs);
|
| 248 |
```
|
| 249 |
|
|
@@ -274,13 +278,12 @@ Let `VT` be `decay_t<T>`.
|
|
| 274 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 275 |
`is_constructible_v<VT, Args...>` is `true`.
|
| 276 |
|
| 277 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 278 |
|
| 279 |
-
*Effects:* Calls `reset()`. Then initializes the
|
| 280 |
-
|
| 281 |
-
`std::forward<Args>(args)...`.
|
| 282 |
|
| 283 |
*Ensures:* `*this` contains a value.
|
| 284 |
|
| 285 |
*Returns:* A reference to the new contained value.
|
| 286 |
|
|
@@ -300,13 +303,12 @@ Let `VT` be `decay_t<T>`.
|
|
| 300 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 301 |
`is_constructible_v<VT, initializer_list<U>&, Args...>` is `true`.
|
| 302 |
|
| 303 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 304 |
|
| 305 |
-
*Effects:* Calls `reset()`. Then initializes the
|
| 306 |
-
|
| 307 |
-
`il, std::forward<Args>(args)...`.
|
| 308 |
|
| 309 |
*Ensures:* `*this` contains a value.
|
| 310 |
|
| 311 |
*Returns:* A reference to the new contained value.
|
| 312 |
|
|
|
|
| 1 |
## Storage for any type <a id="any">[[any]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="any.general">[[any.general]]</a>
|
|
|
|
| 4 |
|
| 5 |
+
Subclause [[any]] describes components that C++ programs may use to
|
| 6 |
+
perform operations on objects of a discriminated type.
|
| 7 |
+
|
| 8 |
+
[*Note 1*: The discriminated type can contain values of different types
|
| 9 |
but does not attempt conversion between them, i.e., `5` is held strictly
|
| 10 |
as an `int` and is not implicitly convertible either to `"5"` or to
|
| 11 |
`5.0`. This indifference to interpretation but awareness of type
|
| 12 |
effectively allows safe, generic containers of single values, with no
|
| 13 |
scope for surprises from ambiguous conversions. — *end note*]
|
|
|
|
| 45 |
```
|
| 46 |
|
| 47 |
### Class `bad_any_cast` <a id="any.bad.any.cast">[[any.bad.any.cast]]</a>
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
+
namespace std {
|
| 51 |
class bad_any_cast : public bad_cast {
|
| 52 |
public:
|
| 53 |
// see [exception] for the specification of the special member functions
|
| 54 |
const char* what() const noexcept override;
|
| 55 |
};
|
| 56 |
+
}
|
| 57 |
```
|
| 58 |
|
| 59 |
Objects of type `bad_any_cast` are thrown by a failed `any_cast`
|
| 60 |
[[any.nonmembers]].
|
| 61 |
|
|
|
|
| 65 |
|
| 66 |
*Returns:* An *implementation-defined* NTBS.
|
| 67 |
|
| 68 |
### Class `any` <a id="any.class">[[any.class]]</a>
|
| 69 |
|
| 70 |
+
#### General <a id="any.class.general">[[any.class.general]]</a>
|
| 71 |
+
|
| 72 |
``` cpp
|
| 73 |
namespace std {
|
| 74 |
class any {
|
| 75 |
public:
|
| 76 |
// [any.cons], construction and destruction
|
|
|
|
| 187 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 188 |
`is_constructible_v<VT, Args...>` is `true`.
|
| 189 |
|
| 190 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 191 |
|
| 192 |
+
*Effects:* Direct-non-list-initializes the contained value of type `VT`
|
| 193 |
+
with `std::forward<Args>(args)...`.
|
|
|
|
| 194 |
|
| 195 |
*Ensures:* `*this` contains a value of type `VT`.
|
| 196 |
|
| 197 |
*Throws:* Any exception thrown by the selected constructor of `VT`.
|
| 198 |
|
|
|
|
| 206 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 207 |
`is_constructible_v<VT, initializer_list<U>&, Args...>` is `true`.
|
| 208 |
|
| 209 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 210 |
|
| 211 |
+
*Effects:* Direct-non-list-initializes the contained value of type `VT`
|
| 212 |
+
with `il, std::forward<Args>(args)...`.
|
|
|
|
| 213 |
|
| 214 |
*Ensures:* `*this` contains a value.
|
| 215 |
|
| 216 |
*Throws:* Any exception thrown by the selected constructor of `VT`.
|
| 217 |
|
|
|
|
| 239 |
any& operator=(any&& rhs) noexcept;
|
| 240 |
```
|
| 241 |
|
| 242 |
*Effects:* As if by `any(std::move(rhs)).swap(*this)`.
|
| 243 |
|
|
|
|
|
|
|
| 244 |
*Ensures:* The state of `*this` is equivalent to the original state of
|
| 245 |
`rhs`.
|
| 246 |
|
| 247 |
+
*Returns:* `*this`.
|
| 248 |
+
|
| 249 |
``` cpp
|
| 250 |
template<class T>
|
| 251 |
any& operator=(T&& rhs);
|
| 252 |
```
|
| 253 |
|
|
|
|
| 278 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 279 |
`is_constructible_v<VT, Args...>` is `true`.
|
| 280 |
|
| 281 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 282 |
|
| 283 |
+
*Effects:* Calls `reset()`. Then direct-non-list-initializes the
|
| 284 |
+
contained value of type `VT` with `std::forward<Args>(args)...`.
|
|
|
|
| 285 |
|
| 286 |
*Ensures:* `*this` contains a value.
|
| 287 |
|
| 288 |
*Returns:* A reference to the new contained value.
|
| 289 |
|
|
|
|
| 303 |
*Constraints:* `is_copy_constructible_v<VT>` is `true` and
|
| 304 |
`is_constructible_v<VT, initializer_list<U>&, Args...>` is `true`.
|
| 305 |
|
| 306 |
*Preconditions:* `VT` meets the *Cpp17CopyConstructible* requirements.
|
| 307 |
|
| 308 |
+
*Effects:* Calls `reset()`. Then direct-non-list-initializes the
|
| 309 |
+
contained value of type `VT` with `il, std::forward<Args>(args)...`.
|
|
|
|
| 310 |
|
| 311 |
*Ensures:* `*this` contains a value.
|
| 312 |
|
| 313 |
*Returns:* A reference to the new contained value.
|
| 314 |
|