explicit operator bool() const noexcept; |
// function::operator bool 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; } |
function::operator() | 调用目标对象(公共成员函数) |
function::target | 获取指向目标的指针(公共成员函数) |