diff options
author | Abseil Team <absl-team@google.com> | 2023-02-27 10:23:16 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-02-27 10:24:05 -0800 |
commit | 2d2801a315282e868d0695541d21f068cec22407 (patch) | |
tree | 5b7a0879301d2011b82e4735982020512e1a5565 /absl | |
parent | 7b46123329a756ea2ba59fde56af5f7c214364a3 (diff) |
Move lambda from ExtractInvoker in AnyInvocable to a separate function
PiperOrigin-RevId: 512664112
Change-Id: I344fd425f52081c0662d7cd0ffa2eefd98fd18fe
Diffstat (limited to 'absl')
-rw-r--r-- | absl/functional/internal/any_invocable.h | 15 |
1 files changed, 9 insertions, 6 deletions
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<absl::decay_t<T> inv_quals>, \ std::forward<Args>(args)...) {} \ \ + /*Raises a fatal error when the AnyInvocable is invoked after a move*/ \ + static ReturnType InvokedAfterMove( \ + TypeErasedState*, \ + ForwardedParameterType<P>...) noexcept(noex) { \ + ABSL_HARDENING_ASSERT(false && "AnyInvocable use-after-move"); \ + std::terminate(); \ + } \ + \ InvokerType<noex, ReturnType, P...>* ExtractInvoker() cv { \ using QualifiedTestType = int cv ref; \ auto* invoker = this->invoker_; \ @@ -817,12 +825,7 @@ using CanAssignReferenceWrapper = TrueAlias< std::is_rvalue_reference<QualifiedTestType>::value) { \ ABSL_HARDENING_ASSERT([this]() { \ /* We checked that this isn't const above, so const_cast is safe */ \ - const_cast<Impl*>(this)->invoker_ = \ - [](TypeErasedState*, \ - ForwardedParameterType<P>...) noexcept(noex) -> ReturnType { \ - ABSL_HARDENING_ASSERT(false && "AnyInvocable use-after-move"); \ - std::terminate(); \ - }; \ + const_cast<Impl*>(this)->invoker_ = InvokedAfterMove; \ return this->HasValue(); \ }()); \ } \ |