function template
<functional>
std::relational operators (function) (1)template <class Ret, class... Args> bool operator== (const function<Ret(Args...)>& lhs, nullptr_t rhs) noexcept;template <class Ret, class... Args> bool operator== (nullptr_t lhs, const function<Ret(Args...)>& rhs) noexcept;(2)
template <class Ret, class... Args> bool operator!= (const function<Ret(Args...)>& lhs, nullptr_t rhs) noexcept;template <class Ret, class... Args> bool operator!= (nullptr_t lhs, const function<Ret(Args...)>& rhs) noexcept;
Relational operators for function vs null pointer
Performs the appropriate comparison against null pointers:true
if the function object is an empty function (i.e., it has no target).
true
if the function object is not an empty function (i.e., it has a target).
1
2
3
4
5
6
7
8
9
10
11
12
13
// function comparisons vs nullptr
#include <iostream> // std::cout
#include <functional> // std::function, std::plus
int main () {
std::function<int(int,int)> foo = std::plus<int>();
std::function<int(int,int)> bar;
std::cout << "foo is " << (foo==nullptr ? "not callable" : "callable") << ".\n";
std::cout << "bar is " << (bar==nullptr ? "not callable" : "callable") << ".\n";
return 0;
}
foo is callable bar is not callable
true
if the condition holds, and false
otherwise.
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