From dc44b95ab0cc988afd225d0eb9f7021f96fcd2b6 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 6 Mar 2023 10:26:02 -0800 Subject: Support lvalue references to incomplete types as `FunctionRef` parameters. PiperOrigin-RevId: 514451518 Change-Id: Ic1391374c7bff08ba437ac0410631d1f701bb9ed --- absl/functional/internal/function_ref.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'absl/functional/internal/function_ref.h') diff --git a/absl/functional/internal/function_ref.h b/absl/functional/internal/function_ref.h index b5bb8b43..a1ddbb0c 100644 --- a/absl/functional/internal/function_ref.h +++ b/absl/functional/internal/function_ref.h @@ -40,18 +40,21 @@ union VoidPtr { // Chooses the best type for passing T as an argument. // Attempt to be close to SystemV AMD64 ABI. Objects with trivial copy ctor are // passed by value. +template ::value> +struct PassByValue : std::false_type {}; + template -constexpr bool PassByValue() { - return !std::is_lvalue_reference::value && - absl::is_trivially_copy_constructible::value && - absl::is_trivially_copy_assignable< - typename std::remove_cv::type>::value && - std::is_trivially_destructible::value && - sizeof(T) <= 2 * sizeof(void*); -} +struct PassByValue + : std::integral_constant::value && + absl::is_trivially_copy_assignable< + typename std::remove_cv::type>::value && + std::is_trivially_destructible::value && + sizeof(T) <= 2 * sizeof(void*)> {}; template -struct ForwardT : std::conditional(), T, T&&> {}; +struct ForwardT : std::conditional::value, T, T&&> {}; // An Invoker takes a pointer to the type-erased invokable object, followed by // the arguments that the invokable object expects. -- cgit v1.2.3