From 2d2801a315282e868d0695541d21f068cec22407 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 27 Feb 2023 10:23:16 -0800 Subject: Move lambda from ExtractInvoker in AnyInvocable to a separate function PiperOrigin-RevId: 512664112 Change-Id: I344fd425f52081c0662d7cd0ffa2eefd98fd18fe --- absl/functional/internal/any_invocable.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'absl/functional') diff --git a/absl/functional/internal/any_invocable.h b/absl/functional/internal/any_invocable.h index 6bfbda18..7845e17a 100644 --- a/absl/functional/internal/any_invocable.h +++ b/absl/functional/internal/any_invocable.h @@ -810,6 +810,14 @@ using CanAssignReferenceWrapper = TrueAlias< : Core(absl::in_place_type inv_quals>, \ std::forward(args)...) {} \ \ + /*Raises a fatal error when the AnyInvocable is invoked after a move*/ \ + static ReturnType InvokedAfterMove( \ + TypeErasedState*, \ + ForwardedParameterType

...) noexcept(noex) { \ + ABSL_HARDENING_ASSERT(false && "AnyInvocable use-after-move"); \ + std::terminate(); \ + } \ + \ InvokerType* ExtractInvoker() cv { \ using QualifiedTestType = int cv ref; \ auto* invoker = this->invoker_; \ @@ -817,12 +825,7 @@ using CanAssignReferenceWrapper = TrueAlias< std::is_rvalue_reference::value) { \ ABSL_HARDENING_ASSERT([this]() { \ /* We checked that this isn't const above, so const_cast is safe */ \ - const_cast(this)->invoker_ = \ - [](TypeErasedState*, \ - ForwardedParameterType

...) noexcept(noex) -> ReturnType { \ - ABSL_HARDENING_ASSERT(false && "AnyInvocable use-after-move"); \ - std::terminate(); \ - }; \ + const_cast(this)->invoker_ = InvokedAfterMove; \ return this->HasValue(); \ }()); \ } \ -- cgit v1.2.3