tmp/tmpz5ltgai6/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="any.class.general">[[any.class.general]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
class any {
|
| 6 |
+
public:
|
| 7 |
+
// [any.cons], construction and destruction
|
| 8 |
+
constexpr any() noexcept;
|
| 9 |
+
|
| 10 |
+
any(const any& other);
|
| 11 |
+
any(any&& other) noexcept;
|
| 12 |
+
|
| 13 |
+
template<class T>
|
| 14 |
+
any(T&& value);
|
| 15 |
+
|
| 16 |
+
template<class T, class... Args>
|
| 17 |
+
explicit any(in_place_type_t<T>, Args&&...);
|
| 18 |
+
template<class T, class U, class... Args>
|
| 19 |
+
explicit any(in_place_type_t<T>, initializer_list<U>, Args&&...);
|
| 20 |
+
|
| 21 |
+
~any();
|
| 22 |
+
|
| 23 |
+
// [any.assign], assignments
|
| 24 |
+
any& operator=(const any& rhs);
|
| 25 |
+
any& operator=(any&& rhs) noexcept;
|
| 26 |
+
|
| 27 |
+
template<class T>
|
| 28 |
+
any& operator=(T&& rhs);
|
| 29 |
+
|
| 30 |
+
// [any.modifiers], modifiers
|
| 31 |
+
template<class T, class... Args>
|
| 32 |
+
decay_t<T>& emplace(Args&&...);
|
| 33 |
+
template<class T, class U, class... Args>
|
| 34 |
+
decay_t<T>& emplace(initializer_list<U>, Args&&...);
|
| 35 |
+
void reset() noexcept;
|
| 36 |
+
void swap(any& rhs) noexcept;
|
| 37 |
+
|
| 38 |
+
// [any.observers], observers
|
| 39 |
+
bool has_value() const noexcept;
|
| 40 |
+
const type_info& type() const noexcept;
|
| 41 |
+
};
|
| 42 |
+
}
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
An object of class `any` stores an instance of any type that meets the
|
| 46 |
+
constructor requirements or it has no value, and this is referred to as
|
| 47 |
+
the *state* of the class `any` object. The stored instance is called the
|
| 48 |
+
*contained value*. Two states are equivalent if either they both have no
|
| 49 |
+
value, or they both have a value and the contained values are
|
| 50 |
+
equivalent.
|
| 51 |
+
|
| 52 |
+
The non-member `any_cast` functions provide type-safe access to the
|
| 53 |
+
contained value.
|
| 54 |
+
|
| 55 |
+
Implementations should avoid the use of dynamically allocated memory for
|
| 56 |
+
a small contained value. However, any such small-object optimization
|
| 57 |
+
shall only be applied to types `T` for which
|
| 58 |
+
`is_nothrow_move_constructible_v<T>` is `true`.
|
| 59 |
+
|
| 60 |
+
[*Example 1*: A contained value of type `int` could be stored in an
|
| 61 |
+
internal buffer, not in separately-allocated memory. — *end example*]
|
| 62 |
+
|