tmp/tmp7v6642sz/{from.md → to.md}
RENAMED
|
@@ -2,11 +2,11 @@
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
void swap(any& x, any& y) noexcept;
|
| 5 |
```
|
| 6 |
|
| 7 |
-
*Effects:*
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
template<class T, class... Args>
|
| 11 |
any make_any(Args&&... args);
|
| 12 |
```
|
|
@@ -29,21 +29,19 @@ template<class T>
|
|
| 29 |
T any_cast(any& operand);
|
| 30 |
template<class T>
|
| 31 |
T any_cast(any&& operand);
|
| 32 |
```
|
| 33 |
|
| 34 |
-
Let `U` be the type `
|
| 35 |
|
| 36 |
-
*
|
| 37 |
-
`is_constructible_v<
|
| 38 |
-
overload, `is_constructible_v<
|
| 39 |
-
overload, `is_constructible_v<ValueType, U>` is `true`. Otherwise the
|
| 40 |
-
program is ill-formed.
|
| 41 |
|
| 42 |
*Returns:* For the first and second overload,
|
| 43 |
-
`static_cast<
|
| 44 |
-
|
| 45 |
|
| 46 |
*Throws:* `bad_any_cast` if
|
| 47 |
`operand.type() != typeid(remove_reference_t<T>)`.
|
| 48 |
|
| 49 |
[*Example 1*:
|
|
@@ -68,12 +66,11 @@ assert(any_cast<const string&>(x) == "Jane");
|
|
| 68 |
|
| 69 |
string cat("Meow");
|
| 70 |
const any y(cat); // const y holds string
|
| 71 |
assert(any_cast<const string&>(y) == cat);
|
| 72 |
|
| 73 |
-
any_cast<string&>(y); // error
|
| 74 |
-
// any_cast away const
|
| 75 |
```
|
| 76 |
|
| 77 |
— *end example*]
|
| 78 |
|
| 79 |
``` cpp
|
|
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
void swap(any& x, any& y) noexcept;
|
| 5 |
```
|
| 6 |
|
| 7 |
+
*Effects:* Equivalent to `x.swap(y)`.
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
template<class T, class... Args>
|
| 11 |
any make_any(Args&&... args);
|
| 12 |
```
|
|
|
|
| 29 |
T any_cast(any& operand);
|
| 30 |
template<class T>
|
| 31 |
T any_cast(any&& operand);
|
| 32 |
```
|
| 33 |
|
| 34 |
+
Let `U` be the type `remove_cvref_t<T>`.
|
| 35 |
|
| 36 |
+
*Mandates:* For the first overload, `is_constructible_v<T, const U&>` is
|
| 37 |
+
`true`. For the second overload, `is_constructible_v<T, U&>` is `true`.
|
| 38 |
+
For the third overload, `is_constructible_v<T, U>` is `true`.
|
|
|
|
|
|
|
| 39 |
|
| 40 |
*Returns:* For the first and second overload,
|
| 41 |
+
`static_cast<T>(*any_cast<U>(&operand))`. For the third overload,
|
| 42 |
+
`static_cast<T>(std::move(*any_cast<U>(&operand)))`.
|
| 43 |
|
| 44 |
*Throws:* `bad_any_cast` if
|
| 45 |
`operand.type() != typeid(remove_reference_t<T>)`.
|
| 46 |
|
| 47 |
[*Example 1*:
|
|
|
|
| 66 |
|
| 67 |
string cat("Meow");
|
| 68 |
const any y(cat); // const y holds string
|
| 69 |
assert(any_cast<const string&>(y) == cat);
|
| 70 |
|
| 71 |
+
any_cast<string&>(y); // error: cannot any_cast away const
|
|
|
|
| 72 |
```
|
| 73 |
|
| 74 |
— *end example*]
|
| 75 |
|
| 76 |
``` cpp
|