tmp/tmp5h04vzmx/{from.md → to.md}
RENAMED
|
@@ -1,91 +1,85 @@
|
|
| 1 |
-
#####
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
function() noexcept;
|
| 5 |
```
|
| 6 |
|
| 7 |
-
*
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
function(nullptr_t) noexcept;
|
| 11 |
```
|
| 12 |
|
| 13 |
-
*
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
function(const function& f);
|
| 17 |
```
|
| 18 |
|
| 19 |
-
*
|
| 20 |
`f.target()`.
|
| 21 |
|
| 22 |
-
*Throws:*
|
| 23 |
-
|
| 24 |
`bad_alloc` or any exception thrown by the copy constructor of the
|
| 25 |
stored callable object.
|
| 26 |
|
| 27 |
-
[*Note 1*: Implementations
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
-
function(function&& f);
|
| 34 |
```
|
| 35 |
|
| 36 |
-
*
|
| 37 |
-
|
| 38 |
-
|
| 39 |
|
| 40 |
-
*
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
[*Note 2*: Implementations are encouraged to avoid the use of
|
| 46 |
-
dynamically allocated memory for small callable objects, for example,
|
| 47 |
-
where `f`’s target is an object holding only a pointer or reference to
|
| 48 |
-
an object and a member function pointer. — *end note*]
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
template<class F> function(F f);
|
| 52 |
```
|
| 53 |
|
| 54 |
-
*
|
|
|
|
| 55 |
|
| 56 |
-
*
|
| 57 |
-
resolution unless `F` is Lvalue-Callable ([[func.wrap.func]]) for
|
| 58 |
-
argument types `ArgTypes...` and return type `R`.
|
| 59 |
|
| 60 |
-
*
|
| 61 |
|
| 62 |
- `f` is a null function pointer value.
|
| 63 |
- `f` is a null member pointer value.
|
| 64 |
- `F` is an instance of the `function` class template, and `!f`.
|
| 65 |
|
| 66 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 67 |
`std::move(f)`.
|
| 68 |
|
| 69 |
-
[*Note 3*: Implementations
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
*Throws:*
|
| 75 |
-
|
| 76 |
-
|
| 77 |
|
| 78 |
``` cpp
|
| 79 |
template<class F> function(F) -> function<see below>;
|
| 80 |
```
|
| 81 |
|
| 82 |
-
*
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
deduced type is `function<R(A...)>`.
|
| 87 |
|
| 88 |
[*Example 1*:
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
void f() {
|
|
@@ -116,26 +110,25 @@ function& operator=(function&& f);
|
|
| 116 |
function& operator=(nullptr_t) noexcept;
|
| 117 |
```
|
| 118 |
|
| 119 |
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 120 |
|
| 121 |
-
*
|
| 122 |
|
| 123 |
*Returns:* `*this`.
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
template<class F> function& operator=(F&& f);
|
| 127 |
```
|
| 128 |
|
|
|
|
|
|
|
|
|
|
| 129 |
*Effects:* As if by: `function(std::forward<F>(f)).swap(*this);`
|
| 130 |
|
| 131 |
*Returns:* `*this`.
|
| 132 |
|
| 133 |
-
*Remarks:* This assignment operator shall not participate in overload
|
| 134 |
-
resolution unless `decay_t<F>` is Lvalue-Callable ([[func.wrap.func]])
|
| 135 |
-
for argument types `ArgTypes...` and return type `R`.
|
| 136 |
-
|
| 137 |
``` cpp
|
| 138 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 139 |
```
|
| 140 |
|
| 141 |
*Effects:* As if by: `function(f).swap(*this);`
|
|
|
|
| 1 |
+
##### Constructors and destructor <a id="func.wrap.func.con">[[func.wrap.func.con]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
function() noexcept;
|
| 5 |
```
|
| 6 |
|
| 7 |
+
*Ensures:* `!*this`.
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
function(nullptr_t) noexcept;
|
| 11 |
```
|
| 12 |
|
| 13 |
+
*Ensures:* `!*this`.
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
function(const function& f);
|
| 17 |
```
|
| 18 |
|
| 19 |
+
*Ensures:* `!*this` if `!f`; otherwise, `*this` targets a copy of
|
| 20 |
`f.target()`.
|
| 21 |
|
| 22 |
+
*Throws:* Nothing if `f`’s target is a specialization of
|
| 23 |
+
`reference_wrapper` or a function pointer. Otherwise, may throw
|
| 24 |
`bad_alloc` or any exception thrown by the copy constructor of the
|
| 25 |
stored callable object.
|
| 26 |
|
| 27 |
+
[*Note 1*: Implementations should avoid the use of dynamically
|
| 28 |
+
allocated memory for small callable objects, for example, where `f`’s
|
| 29 |
+
target is an object holding only a pointer or reference to an object and
|
| 30 |
+
a member function pointer. — *end note*]
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
+
function(function&& f) noexcept;
|
| 34 |
```
|
| 35 |
|
| 36 |
+
*Ensures:* If `!f`, `*this` has no target; otherwise, the target of
|
| 37 |
+
`*this` is equivalent to the target of `f` before the construction, and
|
| 38 |
+
`f` is in a valid state with an unspecified value.
|
| 39 |
|
| 40 |
+
[*Note 2*: Implementations should avoid the use of dynamically
|
| 41 |
+
allocated memory for small callable objects, for example, where `f`’s
|
| 42 |
+
target is an object holding only a pointer or reference to an object and
|
| 43 |
+
a member function pointer. — *end note*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
template<class F> function(F f);
|
| 47 |
```
|
| 48 |
|
| 49 |
+
*Constraints:* `F` is Lvalue-Callable [[func.wrap.func]] for argument
|
| 50 |
+
types `ArgTypes...` and return type `R`.
|
| 51 |
|
| 52 |
+
*Preconditions:* `F` meets the *Cpp17CopyConstructible* requirements.
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
*Ensures:* `!*this` if any of the following hold:
|
| 55 |
|
| 56 |
- `f` is a null function pointer value.
|
| 57 |
- `f` is a null member pointer value.
|
| 58 |
- `F` is an instance of the `function` class template, and `!f`.
|
| 59 |
|
| 60 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 61 |
`std::move(f)`.
|
| 62 |
|
| 63 |
+
[*Note 3*: Implementations should avoid the use of dynamically
|
| 64 |
+
allocated memory for small callable objects, for example, where `f` is
|
| 65 |
+
an object holding only a pointer or reference to an object and a member
|
| 66 |
+
function pointer. — *end note*]
|
| 67 |
|
| 68 |
+
*Throws:* Nothing if `f` is a specialization of `reference_wrapper` or a
|
| 69 |
+
function pointer. Otherwise, may throw `bad_alloc` or any exception
|
| 70 |
+
thrown by `F`’s copy or move constructor.
|
| 71 |
|
| 72 |
``` cpp
|
| 73 |
template<class F> function(F) -> function<see below>;
|
| 74 |
```
|
| 75 |
|
| 76 |
+
*Constraints:* `&F::operator()` is well-formed when treated as an
|
| 77 |
+
unevaluated operand and `decltype(&F::operator())` is of the form
|
| 78 |
+
`R(G::*)(A...)` cv \\ₒₚₜ ` `noexceptₒₚₜ for a class type `G`.
|
| 79 |
+
|
| 80 |
+
*Remarks:* The deduced type is `function<R(A...)>`.
|
| 81 |
|
| 82 |
[*Example 1*:
|
| 83 |
|
| 84 |
``` cpp
|
| 85 |
void f() {
|
|
|
|
| 110 |
function& operator=(nullptr_t) noexcept;
|
| 111 |
```
|
| 112 |
|
| 113 |
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 114 |
|
| 115 |
+
*Ensures:* `!(*this)`.
|
| 116 |
|
| 117 |
*Returns:* `*this`.
|
| 118 |
|
| 119 |
``` cpp
|
| 120 |
template<class F> function& operator=(F&& f);
|
| 121 |
```
|
| 122 |
|
| 123 |
+
*Constraints:* `decay_t<F>` is Lvalue-Callable [[func.wrap.func]] for
|
| 124 |
+
argument types `ArgTypes...` and return type `R`.
|
| 125 |
+
|
| 126 |
*Effects:* As if by: `function(std::forward<F>(f)).swap(*this);`
|
| 127 |
|
| 128 |
*Returns:* `*this`.
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
``` cpp
|
| 131 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 132 |
```
|
| 133 |
|
| 134 |
*Effects:* As if by: `function(f).swap(*this);`
|