tmp/tmpiarv6av1/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##### Class template `copyable_function` <a id="func.wrap.copy.class">[[func.wrap.copy.class]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class R, class... ArgTypes>
|
| 6 |
+
class copyable_function<R(ArgTypes...) cv ref noexcept(noex)> {
|
| 7 |
+
public:
|
| 8 |
+
using result_type = R;
|
| 9 |
+
|
| 10 |
+
// [func.wrap.copy.ctor], constructors, assignments, and destructor
|
| 11 |
+
copyable_function() noexcept;
|
| 12 |
+
copyable_function(nullptr_t) noexcept;
|
| 13 |
+
copyable_function(const copyable_function&);
|
| 14 |
+
copyable_function(copyable_function&&) noexcept;
|
| 15 |
+
template<class F> copyable_function(F&&);
|
| 16 |
+
template<class T, class... Args>
|
| 17 |
+
explicit copyable_function(in_place_type_t<T>, Args&&...);
|
| 18 |
+
template<class T, class U, class... Args>
|
| 19 |
+
explicit copyable_function(in_place_type_t<T>, initializer_list<U>, Args&&...);
|
| 20 |
+
|
| 21 |
+
copyable_function& operator=(const copyable_function&);
|
| 22 |
+
copyable_function& operator=(copyable_function&&);
|
| 23 |
+
copyable_function& operator=(nullptr_t) noexcept;
|
| 24 |
+
template<class F> copyable_function& operator=(F&&);
|
| 25 |
+
|
| 26 |
+
~copyable_function();
|
| 27 |
+
|
| 28 |
+
// [func.wrap.copy.inv], invocation
|
| 29 |
+
explicit operator bool() const noexcept;
|
| 30 |
+
R operator()(ArgTypes...) cv ref noexcept(noex);
|
| 31 |
+
|
| 32 |
+
// [func.wrap.copy.util], utility
|
| 33 |
+
void swap(copyable_function&) noexcept;
|
| 34 |
+
friend void swap(copyable_function&, copyable_function&) noexcept;
|
| 35 |
+
friend bool operator==(const copyable_function&, nullptr_t) noexcept;
|
| 36 |
+
|
| 37 |
+
private:
|
| 38 |
+
template<class VT>
|
| 39 |
+
static constexpr bool is-callable-from = see below; // exposition only
|
| 40 |
+
};
|
| 41 |
+
}
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
The `copyable_function` class template provides polymorphic wrappers
|
| 45 |
+
that generalize the notion of a callable object [[func.def]]. These
|
| 46 |
+
wrappers can store, copy, move, and call arbitrary callable objects,
|
| 47 |
+
given a call signature.
|
| 48 |
+
|
| 49 |
+
*Recommended practice:* Implementations should avoid the use of
|
| 50 |
+
dynamically allocated memory for a small contained value.
|
| 51 |
+
|
| 52 |
+
[*Note 1*: Such small-object optimization can only be applied to a type
|
| 53 |
+
`T` for which `is_nothrow_move_constructible_v<T>` is
|
| 54 |
+
`true`. — *end note*]
|
| 55 |
+
|