Commit 2d2801a3 by Abseil Team Committed by Copybara-Service

Move lambda from ExtractInvoker in AnyInvocable to a separate function

PiperOrigin-RevId: 512664112
Change-Id: I344fd425f52081c0662d7cd0ffa2eefd98fd18fe
parent 7b461233
......@@ -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(); \
}()); \
} \
......
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