# operator==,!=(std::experimental::function)

> C++ Atlas: `cppatlas.com/w/cpp/experimental/function/operator_cmp` | Source: https://en.cppreference.com/w/cpp/experimental/function/operator_cmp | Domain: Technical specifications | Standards: C++20

Compares a std::experimental::function with a null pointer. Empty functions (that is, functions without a callable target) compare equal, non-empty functions compare non-equal.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <experimental/functional>

template< class R, class... ArgTypes >
bool operator==( const std::experimental::function<R(ArgTypes...)>& f,
                 std::nullptr_t ) noexcept; // (1) (library fundamentals TS)

template< class R, class... ArgTypes >
bool operator==( std::nullptr_t,
                 const std::experimental::function<R(ArgTypes...)>& f ) noexcept; // (2) (library fundamentals TS) (removed in library fundamentals TS v3)

template< class R, class... ArgTypes >
bool operator!=( const std::experimental::function<R(ArgTypes...)>& f,
                 std::nullptr_t ) noexcept; // (3) (library fundamentals TS) (removed in library fundamentals TS v3)

template< class R, class... ArgTypes >
bool operator!=( std::nullptr_t,
                 const std::experimental::function<R(ArgTypes...)>& f ) noexcept; // (4) (library fundamentals TS) (removed in library fundamentals TS v3)
```

Compares a `std::experimental::function` with a null pointer. Empty functions (that is, functions without a callable target) compare equal, non-empty functions compare non-equal.

The `!=` operator is synthesized from `operator==`. (library fundamentals TS v3)

### Parameters

- `f` - `std::experimental::function` to compare

### Return value

1,2) `!f`

3,4) `(bool) f`

### See also

- [`operator==`](https://en.cppreference.com/w/cpp/utility/functional/function/operator_cmp), [`operator!=`](https://en.cppreference.com/w/cpp/utility/functional/function/operator_cmp) (removed in C++20): compares a `std::function` with `nullptr` (function template)

---
Attribution: content from https://en.cppreference.com/w/cpp/experimental/function/operator_cmp (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.