void swap (function& x) noexcept; |
// function::swap example #include <iostream> // std::cout #include <functional> // std::function, std::plus int main () { std::function<int(int,int)> foo,bar; foo = std::plus<int>(); foo.swap(bar); std::cout << "foo is " << (foo ? "callable" : "not callable") << ".\n"; std::cout << "bar is " << (bar ? "callable" : "not callable") << ".\n"; return 0; } |
swap(function) | 交换目标(公共成员函数) |
function::operator= | 赋值函数对象(公共成员函数) |