summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Dino Radakovic <dinor@google.com>2023-04-06 12:51:34 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-04-06 12:52:26 -0700
commit42a3c030c958e6e099162b746ada04792b3a1c67 (patch)
treea51ff6e6ed69cce834b17b7a8429f752e17313c1 /absl
parente73b9139ee9b853a4bd7812531442c138da09084 (diff)
Document that wrapping an empty `std::function` creates a non-empty `AnyInvocable`
PiperOrigin-RevId: 522411202 Change-Id: Ifc99f5f6a227efd697039344ea75f53c6f282e53
Diffstat (limited to 'absl')
-rw-r--r--absl/functional/any_invocable.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/absl/functional/any_invocable.h b/absl/functional/any_invocable.h
index 788bc1af..68d88253 100644
--- a/absl/functional/any_invocable.h
+++ b/absl/functional/any_invocable.h
@@ -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.