operator==,!=(std::function) (3) - Linux Manuals
operator==,!=(std::function): operator==,!=(std::function)
Command to display operator==,!=(std::function)
manual in Linux: $ man 3 operator==,!=(std::function)
NAME
operator==,!=(std::function) - operator==,!=(std::function)
Synopsis
template< class R, class... ArgTypes > (1) (since C++11)
bool operator==( const std::function<R(ArgTypes...)>& f, std::nullptr_t ) noexcept;
template< class R, class... ArgTypes > (2) (since C++11)
bool operator==( std::nullptr_t, const std::function<R(ArgTypes...)>& f ) noexcept;
template< class R, class... ArgTypes > (3) (since C++11)
bool operator!=( const std::function<R(ArgTypes...)>& f, std::nullptr_t ) noexcept;
template< class R, class... ArgTypes > (4) (since C++11)
bool operator!=( std::nullptr_t, const std::function<R(ArgTypes...)>& f ) noexcept;
Compares a std::function with a null pointer. Empty functions (that is, functions without a callable target) compare equal, non-empty functions compare non-equal.
Parameters
f - std::function to compare
Return value
1-2) !f
3-4) (bool) f
Example
// Run this code
#include <functional>
#include <iostream>
using SomeVoidFunc = std::function<void(int)>;
class C {
public:
C(SomeVoidFunc void_func = nullptr) :
void_func_(void_func)
{
if (void_func_ == nullptr) { // specialized compare with nullptr
void_func_ = std::bind(&C::default_func, this, std::placeholders::_1);
}
void_func_(7);
}
void default_func(int i) { std::cout << i << '\n'; };
private:
SomeVoidFunc void_func_;
};
void user_func(int i)
{
std::cout << (i + 1) << '\n';
}
int main()
{
C c1;
C c2(user_func);
}
Output:
7
8
Pages related to operator==,!=(std::function)
- operator==,!=(std::fisher_f_distribution) (3) - operator==,!=(std::fisher_f_distribution)
- operator==,!=(std::allocator) (3) - operator==,!=(std::allocator)
- operator==,!=(std::bernoulli_distribution) (3) - operator==,!=(std::bernoulli_distribution)
- operator==,!=(std::binomial_distribution) (3) - operator==,!=(std::binomial_distribution)
- operator==,!=(std::bitset) (3) - operator==,!=(std::bitset)
- operator==,!=(std::cauchy_distribution) (3) - operator==,!=(std::cauchy_distribution)
- operator==,!=(std::chi_squared_distribution) (3) - operator==,!=(std::chi_squared_distribution)
- operator==,!=(std::complex) (3) - operator==,!=(std::complex)
- operator==,!=(std::discard_block_engine) (3) - operator==,!=(std::discard_block_engine)
- operator==,!=(std::discrete_distribution) (3) - operator==,!=(std::discrete_distribution)
- operator==,!=(std::experimental::function) (3) - operator==,!=(std::experimental::function)
- operator==,!=(std::experimental::pmr::polymorphic_allocator) (3) - operator==,!=(std::experimental::pmr::polymorphic_allocator)
- operator==,!=(std::exponential_distribution) (3) - operator==,!=(std::exponential_distribution)
- operator==,!=(std::extreme_value_distribution) (3) - operator==,!=(std::extreme_value_distribution)
- operator==,!=(std::gamma_distribution) (3) - operator==,!=(std::gamma_distribution)
- operator==,!=(std::geometric_distribution) (3) - operator==,!=(std::geometric_distribution)
- operator==,!=(std::independent_bits_engine) (3) - operator==,!=(std::independent_bits_engine)
- operator==,!=(std::istream_iterator) (3) - operator==,!=(std::istream_iterator)
- operator==,!=(std::istreambuf_iterator) (3) - operator==,!=(std::istreambuf_iterator)
- operator==,!=(std::linear_congruential_engine) (3) - operator==,!=(std::linear_congruential_engine)
- operator==,!=(std::lognormal_distribution) (3) - operator==,!=(std::lognormal_distribution)
- operator==,!=(std::match_results) (3) - operator==,!=(std::match_results)
- operator==,!=(std::mersenne_twister_engine) (3) - operator==,!=(std::mersenne_twister_engine)