tmp/tmpqjydqm1o/{from.md → to.md}
RENAMED
|
@@ -6,15 +6,15 @@ namespace std {
|
|
| 6 |
|
| 7 |
template<class R, class... ArgTypes>
|
| 8 |
class function<R(ArgTypes...)> {
|
| 9 |
public:
|
| 10 |
typedef R result_type;
|
| 11 |
-
typedef T1 argument_type; //
|
| 12 |
// the type in ArgTypes is T1
|
| 13 |
-
typedef T1 first_argument_type; //
|
| 14 |
// ArgTypes contains T1 and T2
|
| 15 |
-
typedef T2 second_argument_type; //
|
| 16 |
// ArgTypes contains T1 and T2
|
| 17 |
|
| 18 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 19 |
function() noexcept;
|
| 20 |
function(nullptr_t) noexcept;
|
|
@@ -48,12 +48,12 @@ namespace std {
|
|
| 48 |
// [func.wrap.func.inv], function invocation:
|
| 49 |
R operator()(ArgTypes...) const;
|
| 50 |
|
| 51 |
// [func.wrap.func.targ], function target access:
|
| 52 |
const std::type_info& target_type() const noexcept;
|
| 53 |
-
template
|
| 54 |
-
template
|
| 55 |
|
| 56 |
};
|
| 57 |
|
| 58 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 59 |
template <class R, class... ArgTypes>
|
|
@@ -142,20 +142,21 @@ state with an unspecified value.
|
|
| 142 |
``` cpp
|
| 143 |
template<class F> function(F f);
|
| 144 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 145 |
```
|
| 146 |
|
| 147 |
-
*Requires:* `F` shall be `CopyConstructible`.
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
|
|
|
| 151 |
|
| 152 |
*Postconditions:* `!*this` if any of the following hold:
|
| 153 |
|
| 154 |
-
- `f` is a
|
| 155 |
-
- `f` is a
|
| 156 |
-
- `F` is an instance of the `function` class template, and `!f`
|
| 157 |
|
| 158 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 159 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 160 |
dynamically allocated memory for small callable objects, for example,
|
| 161 |
where `f`’s target is an object holding only a pointer or reference to
|
|
@@ -183,11 +184,11 @@ function& operator=(function&& f);
|
|
| 183 |
|
| 184 |
``` cpp
|
| 185 |
function& operator=(nullptr_t);
|
| 186 |
```
|
| 187 |
|
| 188 |
-
*Effects:* If `*this !=
|
| 189 |
|
| 190 |
*Postconditions:* `!(*this)`.
|
| 191 |
|
| 192 |
*Returns:* `*this`
|
| 193 |
|
|
@@ -197,10 +198,15 @@ template<class F> function& operator=(F&& f);
|
|
| 197 |
|
| 198 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 199 |
|
| 200 |
*Returns:* `*this`
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
``` cpp
|
| 203 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 204 |
```
|
| 205 |
|
| 206 |
*Effects:* `function(f).swap(*this);`
|
|
@@ -209,11 +215,11 @@ template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
|
| 209 |
|
| 210 |
``` cpp
|
| 211 |
~function();
|
| 212 |
```
|
| 213 |
|
| 214 |
-
*Effects:* If `*this !=
|
| 215 |
|
| 216 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 217 |
|
| 218 |
``` cpp
|
| 219 |
void swap(function& other) noexcept;
|
|
@@ -260,18 +266,18 @@ const std::type_info& target_type() const noexcept;
|
|
| 260 |
|
| 261 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 262 |
`typeid(void)`.
|
| 263 |
|
| 264 |
``` cpp
|
| 265 |
-
template<
|
| 266 |
-
template<
|
| 267 |
```
|
| 268 |
|
| 269 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 270 |
for parameter types `ArgTypes` and return type `R`.
|
| 271 |
|
| 272 |
-
*Returns:* If `
|
| 273 |
function target; otherwise a null pointer.
|
| 274 |
|
| 275 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 276 |
|
| 277 |
``` cpp
|
|
|
|
| 6 |
|
| 7 |
template<class R, class... ArgTypes>
|
| 8 |
class function<R(ArgTypes...)> {
|
| 9 |
public:
|
| 10 |
typedef R result_type;
|
| 11 |
+
typedef T1 argument_type; // only if sizeof...(ArgTypes) == 1 and
|
| 12 |
// the type in ArgTypes is T1
|
| 13 |
+
typedef T1 first_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 14 |
// ArgTypes contains T1 and T2
|
| 15 |
+
typedef T2 second_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 16 |
// ArgTypes contains T1 and T2
|
| 17 |
|
| 18 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 19 |
function() noexcept;
|
| 20 |
function(nullptr_t) noexcept;
|
|
|
|
| 48 |
// [func.wrap.func.inv], function invocation:
|
| 49 |
R operator()(ArgTypes...) const;
|
| 50 |
|
| 51 |
// [func.wrap.func.targ], function target access:
|
| 52 |
const std::type_info& target_type() const noexcept;
|
| 53 |
+
template<class T> T* target() noexcept;
|
| 54 |
+
template<class T> const T* target() const noexcept;
|
| 55 |
|
| 56 |
};
|
| 57 |
|
| 58 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 59 |
template <class R, class... ArgTypes>
|
|
|
|
| 142 |
``` cpp
|
| 143 |
template<class F> function(F f);
|
| 144 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 145 |
```
|
| 146 |
|
| 147 |
+
*Requires:* `F` shall be `CopyConstructible`.
|
| 148 |
+
|
| 149 |
+
*Remarks:* These constructors shall not participate in overload
|
| 150 |
+
resolution unless `f` is Callable ([[func.wrap.func]]) for argument
|
| 151 |
+
types `ArgTypes...` and return type `R`.
|
| 152 |
|
| 153 |
*Postconditions:* `!*this` if any of the following hold:
|
| 154 |
|
| 155 |
+
- `f` is a null function pointer value.
|
| 156 |
+
- `f` is a null member pointer value.
|
| 157 |
+
- `F` is an instance of the `function` class template, and `!f`.
|
| 158 |
|
| 159 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 160 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 161 |
dynamically allocated memory for small callable objects, for example,
|
| 162 |
where `f`’s target is an object holding only a pointer or reference to
|
|
|
|
| 184 |
|
| 185 |
``` cpp
|
| 186 |
function& operator=(nullptr_t);
|
| 187 |
```
|
| 188 |
|
| 189 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 190 |
|
| 191 |
*Postconditions:* `!(*this)`.
|
| 192 |
|
| 193 |
*Returns:* `*this`
|
| 194 |
|
|
|
|
| 198 |
|
| 199 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 200 |
|
| 201 |
*Returns:* `*this`
|
| 202 |
|
| 203 |
+
*Remarks:* This assignment operator shall not participate in overload
|
| 204 |
+
resolution unless `declval<typename decay<F>::type&>()` is
|
| 205 |
+
Callable ([[func.wrap.func]]) for argument types `ArgTypes...` and
|
| 206 |
+
return type `R`.
|
| 207 |
+
|
| 208 |
``` cpp
|
| 209 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 210 |
```
|
| 211 |
|
| 212 |
*Effects:* `function(f).swap(*this);`
|
|
|
|
| 215 |
|
| 216 |
``` cpp
|
| 217 |
~function();
|
| 218 |
```
|
| 219 |
|
| 220 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 221 |
|
| 222 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 223 |
|
| 224 |
``` cpp
|
| 225 |
void swap(function& other) noexcept;
|
|
|
|
| 266 |
|
| 267 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 268 |
`typeid(void)`.
|
| 269 |
|
| 270 |
``` cpp
|
| 271 |
+
template<class T> T* target() noexcept;
|
| 272 |
+
template<class T> const T* target() const noexcept;
|
| 273 |
```
|
| 274 |
|
| 275 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 276 |
for parameter types `ArgTypes` and return type `R`.
|
| 277 |
|
| 278 |
+
*Returns:* If `target_type() == typeid(T)` a pointer to the stored
|
| 279 |
function target; otherwise a null pointer.
|
| 280 |
|
| 281 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 282 |
|
| 283 |
``` cpp
|