public member function
<functional>
std::function::operator= copy (1)function& operator= (const function& rhs);move (2)
function& operator= (function&& rhs);target (3)
template <class Fn> function& operator= (Fn&& fn);template <class Fn> function& operator= (reference_wrapper<Fn> fn) noexcept;clear (4)
function& operator= (nullptr_t fn);
Assign function object
Assigns a new value to the function object, replacing its current target:The object copies
fnas its
target.
The object copies
fnas its
target.
If
fnis not callable for the arguments and return type specified as template arguments for the class, this function does not participate in overload resolution.
std::move(fn)
).
*this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// function::operator= example
#include <iostream> // std::cout
#include <functional> // std::function, std::negate
int main () {
std::function<int(int)> foo,bar;
foo = std::negate<int>(); // target
bar = foo; // copy
foo = std::function<int(int)>([](int x){return x+1;}); // move
bar = nullptr; // clear
std::cout << "foo: " << foo(100) << '\n';
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4