Skip to content

Commit 38b61bf

Browse files
Abseil Teamcopybara-github
authored andcommitted
Make warning about wrapping empty std::function in AnyInvocable stronger.
PiperOrigin-RevId: 733331540 Change-Id: Ia77f89dfbd58fa2845c89af68976b965852d7e18
1 parent 735c861 commit 38b61bf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

absl/functional/any_invocable.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,10 @@ class AnyInvocable : private internal_any_invocable::Impl<Sig> {
279279
//
280280
// WARNING: An `AnyInvocable` that wraps an empty `std::function` is not
281281
// itself empty. This behavior is consistent with the standard equivalent
282-
// `std::move_only_function`.
283-
//
284-
// In other words:
282+
// `std::move_only_function`. In the following example, `a()` will actually
283+
// invoke `f()`, leading to an `std::bad_function_call` exception:
285284
// std::function<void()> f; // empty
286-
// absl::AnyInvocable<void()> a = std::move(f); // not empty
285+
// absl::AnyInvocable<void()> a = f; // not empty
287286
//
288287
// Invoking an empty `AnyInvocable` results in undefined behavior.
289288
explicit operator bool() const noexcept { return this->HasValue(); }

0 commit comments

Comments
 (0)