tmp/tmp2srqpavo/{from.md → to.md}
RENAMED
|
@@ -35,15 +35,15 @@ namespace std {
|
|
| 35 |
|
| 36 |
template<class R, class... ArgTypes>
|
| 37 |
class function<R(ArgTypes...)> {
|
| 38 |
public:
|
| 39 |
typedef R result_type;
|
| 40 |
-
typedef T1 argument_type; //
|
| 41 |
// the type in ArgTypes is T1
|
| 42 |
-
typedef T1 first_argument_type; //
|
| 43 |
// ArgTypes contains T1 and T2
|
| 44 |
-
typedef T2 second_argument_type; //
|
| 45 |
// ArgTypes contains T1 and T2
|
| 46 |
|
| 47 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 48 |
function() noexcept;
|
| 49 |
function(nullptr_t) noexcept;
|
|
@@ -77,12 +77,12 @@ namespace std {
|
|
| 77 |
// [func.wrap.func.inv], function invocation:
|
| 78 |
R operator()(ArgTypes...) const;
|
| 79 |
|
| 80 |
// [func.wrap.func.targ], function target access:
|
| 81 |
const std::type_info& target_type() const noexcept;
|
| 82 |
-
template
|
| 83 |
-
template
|
| 84 |
|
| 85 |
};
|
| 86 |
|
| 87 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 88 |
template <class R, class... ArgTypes>
|
|
@@ -171,20 +171,21 @@ state with an unspecified value.
|
|
| 171 |
``` cpp
|
| 172 |
template<class F> function(F f);
|
| 173 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 174 |
```
|
| 175 |
|
| 176 |
-
*Requires:* `F` shall be `CopyConstructible`.
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
|
|
|
| 180 |
|
| 181 |
*Postconditions:* `!*this` if any of the following hold:
|
| 182 |
|
| 183 |
-
- `f` is a
|
| 184 |
-
- `f` is a
|
| 185 |
-
- `F` is an instance of the `function` class template, and `!f`
|
| 186 |
|
| 187 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 188 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 189 |
dynamically allocated memory for small callable objects, for example,
|
| 190 |
where `f`’s target is an object holding only a pointer or reference to
|
|
@@ -212,11 +213,11 @@ function& operator=(function&& f);
|
|
| 212 |
|
| 213 |
``` cpp
|
| 214 |
function& operator=(nullptr_t);
|
| 215 |
```
|
| 216 |
|
| 217 |
-
*Effects:* If `*this !=
|
| 218 |
|
| 219 |
*Postconditions:* `!(*this)`.
|
| 220 |
|
| 221 |
*Returns:* `*this`
|
| 222 |
|
|
@@ -226,10 +227,15 @@ template<class F> function& operator=(F&& f);
|
|
| 226 |
|
| 227 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 228 |
|
| 229 |
*Returns:* `*this`
|
| 230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
``` cpp
|
| 232 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 233 |
```
|
| 234 |
|
| 235 |
*Effects:* `function(f).swap(*this);`
|
|
@@ -238,11 +244,11 @@ template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
|
| 238 |
|
| 239 |
``` cpp
|
| 240 |
~function();
|
| 241 |
```
|
| 242 |
|
| 243 |
-
*Effects:* If `*this !=
|
| 244 |
|
| 245 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 246 |
|
| 247 |
``` cpp
|
| 248 |
void swap(function& other) noexcept;
|
|
@@ -289,18 +295,18 @@ const std::type_info& target_type() const noexcept;
|
|
| 289 |
|
| 290 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 291 |
`typeid(void)`.
|
| 292 |
|
| 293 |
``` cpp
|
| 294 |
-
template<
|
| 295 |
-
template<
|
| 296 |
```
|
| 297 |
|
| 298 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 299 |
for parameter types `ArgTypes` and return type `R`.
|
| 300 |
|
| 301 |
-
*Returns:* If `
|
| 302 |
function target; otherwise a null pointer.
|
| 303 |
|
| 304 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 305 |
|
| 306 |
``` cpp
|
|
|
|
| 35 |
|
| 36 |
template<class R, class... ArgTypes>
|
| 37 |
class function<R(ArgTypes...)> {
|
| 38 |
public:
|
| 39 |
typedef R result_type;
|
| 40 |
+
typedef T1 argument_type; // only if sizeof...(ArgTypes) == 1 and
|
| 41 |
// the type in ArgTypes is T1
|
| 42 |
+
typedef T1 first_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 43 |
// ArgTypes contains T1 and T2
|
| 44 |
+
typedef T2 second_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 45 |
// ArgTypes contains T1 and T2
|
| 46 |
|
| 47 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 48 |
function() noexcept;
|
| 49 |
function(nullptr_t) noexcept;
|
|
|
|
| 77 |
// [func.wrap.func.inv], function invocation:
|
| 78 |
R operator()(ArgTypes...) const;
|
| 79 |
|
| 80 |
// [func.wrap.func.targ], function target access:
|
| 81 |
const std::type_info& target_type() const noexcept;
|
| 82 |
+
template<class T> T* target() noexcept;
|
| 83 |
+
template<class T> const T* target() const noexcept;
|
| 84 |
|
| 85 |
};
|
| 86 |
|
| 87 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 88 |
template <class R, class... ArgTypes>
|
|
|
|
| 171 |
``` cpp
|
| 172 |
template<class F> function(F f);
|
| 173 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 174 |
```
|
| 175 |
|
| 176 |
+
*Requires:* `F` shall be `CopyConstructible`.
|
| 177 |
+
|
| 178 |
+
*Remarks:* These constructors shall not participate in overload
|
| 179 |
+
resolution unless `f` is Callable ([[func.wrap.func]]) for argument
|
| 180 |
+
types `ArgTypes...` and return type `R`.
|
| 181 |
|
| 182 |
*Postconditions:* `!*this` if any of the following hold:
|
| 183 |
|
| 184 |
+
- `f` is a null function pointer value.
|
| 185 |
+
- `f` is a null member pointer value.
|
| 186 |
+
- `F` is an instance of the `function` class template, and `!f`.
|
| 187 |
|
| 188 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 189 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 190 |
dynamically allocated memory for small callable objects, for example,
|
| 191 |
where `f`’s target is an object holding only a pointer or reference to
|
|
|
|
| 213 |
|
| 214 |
``` cpp
|
| 215 |
function& operator=(nullptr_t);
|
| 216 |
```
|
| 217 |
|
| 218 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 219 |
|
| 220 |
*Postconditions:* `!(*this)`.
|
| 221 |
|
| 222 |
*Returns:* `*this`
|
| 223 |
|
|
|
|
| 227 |
|
| 228 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 229 |
|
| 230 |
*Returns:* `*this`
|
| 231 |
|
| 232 |
+
*Remarks:* This assignment operator shall not participate in overload
|
| 233 |
+
resolution unless `declval<typename decay<F>::type&>()` is
|
| 234 |
+
Callable ([[func.wrap.func]]) for argument types `ArgTypes...` and
|
| 235 |
+
return type `R`.
|
| 236 |
+
|
| 237 |
``` cpp
|
| 238 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 239 |
```
|
| 240 |
|
| 241 |
*Effects:* `function(f).swap(*this);`
|
|
|
|
| 244 |
|
| 245 |
``` cpp
|
| 246 |
~function();
|
| 247 |
```
|
| 248 |
|
| 249 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 250 |
|
| 251 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 252 |
|
| 253 |
``` cpp
|
| 254 |
void swap(function& other) noexcept;
|
|
|
|
| 295 |
|
| 296 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 297 |
`typeid(void)`.
|
| 298 |
|
| 299 |
``` cpp
|
| 300 |
+
template<class T> T* target() noexcept;
|
| 301 |
+
template<class T> const T* target() const noexcept;
|
| 302 |
```
|
| 303 |
|
| 304 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 305 |
for parameter types `ArgTypes` and return type `R`.
|
| 306 |
|
| 307 |
+
*Returns:* If `target_type() == typeid(T)` a pointer to the stored
|
| 308 |
function target; otherwise a null pointer.
|
| 309 |
|
| 310 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 311 |
|
| 312 |
``` cpp
|