public member function
<functional>
std::function::operator boolexplicit operator bool() const noexcept;
Check if callable
Returns whether the object is callable.A function object is callable if it is not an empty function (i.e., if it has a callable object as target).
true
if the object is callable.
false
otherwise (the object is an empty function).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 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;
}
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