Skip to content

Function operator== (proxy<F>)

friend bool operator==(const proxy& lhs, std::nullptr_t) noexcept;

Checks whether lhs contains a value by comparing it with nullptr. A proxy that does not contain a value compares equal to nullptr; otherwise, it compares non-equal.

This function is not visible to ordinary unqualified or qualified lookup. It can only be found by argument-dependent lookup when proxy<F> is an associated class of the arguments.

The != operator is synthesized from operator==.

Return Value

!lhs.has_value().

Example

#include <iostream>

#include <proxy/proxy.h>

struct AnyMovable : pro::facade_builder::build {};

int main() {
  pro::proxy<AnyMovable> p;
  std::cout << std::boolalpha << (p == nullptr) << "\n"; // Prints "true"
  std::cout << (p != nullptr) << "\n";                   // Prints "false"
  p = std::make_unique<int>(123);
  std::cout << (p == nullptr) << "\n"; // Prints "false"
  std::cout << (p != nullptr) << "\n"; // Prints "true"
}

See Also