public member function
<functional>
std::swap (function)template <class Ret, class... Args> void swap (function<Ret(Args...)>& x, function<Ret(Args...)>& y);
Exchanges the targets
The target callable object held by x is exchanged with that of y.It behaves as if x.swap(y)
was called.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// swapping functions
#include <iostream> // std::cout
#include <functional> // std::function, std::plus
int main () {
std::function<int(int,int)> foo,bar;
foo = std::plus<int>();
swap(foo,bar);
std::cout << "foo is " << (foo ? "callable" : "not callable") << ".\n";
std::cout << "bar is " << (bar ? "callable" : "not callable") << ".\n";
return 0;
}
foo is not callable. bar is callable.
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