tmp/tmpbottwk9p/{from.md → to.md}
RENAMED
|
@@ -14,70 +14,87 @@ function(nullptr_t) noexcept;
|
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
function(const function& f);
|
| 17 |
```
|
| 18 |
|
| 19 |
-
*Ensures:* `!*this` if `!f`; otherwise, `*this`
|
| 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 |
-
|
| 28 |
-
allocated memory for small callable objects, for example,
|
| 29 |
-
target is an object holding only a pointer or reference to
|
| 30 |
-
a member function pointer.
|
| 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 |
-
|
| 41 |
-
allocated memory for small callable objects, for example,
|
| 42 |
-
target is an object holding only a pointer or reference to
|
| 43 |
-
a member function pointer.
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
-
template<class F> function(F f);
|
| 47 |
```
|
| 48 |
|
| 49 |
-
|
| 50 |
-
types `ArgTypes...` and return type `R`.
|
| 51 |
|
| 52 |
-
*
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
- `f` is a null function pointer value.
|
| 57 |
- `f` is a null member pointer value.
|
| 58 |
-
- `F` is
|
|
|
|
| 59 |
|
| 60 |
-
Otherwise, `*this`
|
| 61 |
-
`std::
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
function pointer. — *end note*]
|
| 67 |
|
| 68 |
-
*
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 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
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
*Remarks:* The deduced type is `function<R(A...)>`.
|
| 81 |
|
| 82 |
[*Example 1*:
|
| 83 |
|
|
|
|
| 14 |
|
| 15 |
``` cpp
|
| 16 |
function(const function& f);
|
| 17 |
```
|
| 18 |
|
| 19 |
+
*Ensures:* `!*this` if `!f`; otherwise, the target object of `*this` is
|
| 20 |
+
a copy of `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 |
+
*Recommended practice:* Implementations should avoid the use of
|
| 28 |
+
dynamically allocated memory for small callable objects, for example,
|
| 29 |
+
where `f`’s target is an object holding only a pointer or reference to
|
| 30 |
+
an object and a member function pointer.
|
| 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 |
+
*Recommended practice:* Implementations should avoid the use of
|
| 41 |
+
dynamically allocated memory for small callable objects, for example,
|
| 42 |
+
where `f`’s target is an object holding only a pointer or reference to
|
| 43 |
+
an object and a member function pointer.
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
+
template<class F> function(F&& f);
|
| 47 |
```
|
| 48 |
|
| 49 |
+
Let `FD` be `decay_t<F>`.
|
|
|
|
| 50 |
|
| 51 |
+
*Constraints:*
|
| 52 |
|
| 53 |
+
- `is_same_v<remove_cvref_t<F>, function>` is `false`, and
|
| 54 |
+
- `FD` is Lvalue-Callable [[func.wrap.func]] for argument types
|
| 55 |
+
`ArgTypes...` and return type `R`.
|
| 56 |
+
|
| 57 |
+
*Mandates:*
|
| 58 |
+
|
| 59 |
+
- `is_copy_constructible_v<FD>` is `true`, and
|
| 60 |
+
- `is_constructible_v<FD, F>` is `true`.
|
| 61 |
+
|
| 62 |
+
*Preconditions:* `FD` meets the *Cpp17CopyConstructible* requirements.
|
| 63 |
+
|
| 64 |
+
*Ensures:* `!*this` is `true` if any of the following hold:
|
| 65 |
|
| 66 |
- `f` is a null function pointer value.
|
| 67 |
- `f` is a null member pointer value.
|
| 68 |
+
- `remove_cvref_t<F>` is a specialization of the `function` class
|
| 69 |
+
template, and `!f` is `true`.
|
| 70 |
|
| 71 |
+
Otherwise, `*this` has a target object of type `FD`
|
| 72 |
+
direct-non-list-initialized with `std::forward<F>(f)`.
|
| 73 |
|
| 74 |
+
*Throws:* Nothing if `FD` is a specialization of `reference_wrapper` or
|
| 75 |
+
a function pointer type. Otherwise, may throw `bad_alloc` or any
|
| 76 |
+
exception thrown by the initialization of the target object.
|
|
|
|
| 77 |
|
| 78 |
+
*Recommended practice:* Implementations should avoid the use of
|
| 79 |
+
dynamically allocated memory for small callable objects, for example,
|
| 80 |
+
where `f` refers to an object holding only a pointer or reference to an
|
| 81 |
+
object and a member function pointer.
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
template<class F> function(F) -> function<see below>;
|
| 85 |
```
|
| 86 |
|
| 87 |
*Constraints:* `&F::operator()` is well-formed when treated as an
|
| 88 |
+
unevaluated operand and either
|
| 89 |
+
|
| 90 |
+
- `F::operator()` is a non-static member function and
|
| 91 |
+
`decltype(&F::operator())` is either of the form
|
| 92 |
+
`R(G::*)(A...)` cv \\ₒₚₜ ` `noexceptₒₚₜ or of the form
|
| 93 |
+
`R(*)(G, A...) `noexceptₒₚₜ for a type `G`, or
|
| 94 |
+
- `F::operator()` is a static member function and
|
| 95 |
+
`decltype(&F::operator())` is of the form `R(*)(A...) `noexceptₒₚₜ .
|
| 96 |
|
| 97 |
*Remarks:* The deduced type is `function<R(A...)>`.
|
| 98 |
|
| 99 |
[*Example 1*:
|
| 100 |
|