Commit 42a3c030 by Dino Radakovic Committed by Copybara-Service

Document that wrapping an empty `std::function` creates a non-empty `AnyInvocable`

PiperOrigin-RevId: 522411202
Change-Id: Ifc99f5f6a227efd697039344ea75f53c6f282e53
parent e73b9139
......@@ -269,6 +269,14 @@ class AnyInvocable : private internal_any_invocable::Impl<Sig> {
// absl::AnyInvocable::operator bool()
//
// 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 other words:
// std::function<void()> f; // empty
// absl::AnyInvocable<void()> a = std::move(f); // not empty
explicit operator bool() const noexcept { return this->HasValue(); }
// Invokes the target object of `*this`. `*this` must not be empty.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment