absl::AnyInvocable::operator bool()

Synopsis

Declared in <absl/functional/any_invocable.h>

explicit
operator bool() const noexcept;

Description

Returns true if *this is not empty.

WARNING: An AnyInvocable that wraps an empty std::function is not itself empty. This behavior is consistent with the standard equivalent std::move_only_function. In the following example, a() will actually invoke f(), leading to an std::bad_function_call exception: std::function<void()> f; // empty absl::AnyInvocable<void()> a = f; // not empty

Invoking an empty AnyInvocable results in undefined behavior.

Return Value

true if *this is not empty.

Created with MrDocs