You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chromium/chromium-79-gcc-permissive....

80 lines
2.9 KiB

From 528e9a3e1f25bd264549c4c7779748abfd16bb1c Mon Sep 17 00:00:00 2001
From: Jan Wilken Dörrie <jdoerrie@chromium.org>
Date: Fri, 18 Oct 2019 11:45:24 +0000
Subject: [PATCH] Reland "GCC: Fix base::internal::InvokeFuncImpl"
This is a reland of 9293d5c86eec1c34fc00716645400b44a14e764e
Original change's description:
> GCC: Fix base::internal::InvokeFuncImpl
>
> GCC doesn't like that the Value data member has no out-of-line
> definition. The problem is triggered specifically only when compiling
>
> components/services/leveldb/leveldb_database_impl.cc
>
> which has lambda functions returning locally-defined classes.
>
> The current code works as-is in C++17 mode which introduces the concept
> of inline variables, but in C++14 we need either an explicit out-of-line
> definition or a function member instead of a data member.
>
> Use std::integral_constant for defining the value.
>
> Bug: 819294
> Change-Id: I5c68e14ce3fa9d8b4d8a2cb42d7f9b53938aabf3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862451
> Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Commit-Queue: Jüri Valdmann <juri.valdmann@qt.io>
> Cr-Commit-Position: refs/heads/master@{#706384}
Bug: 819294
Change-Id: I3d5a52ddc6815516e2239f9347c60de06bf765a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865212
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707329}
---
diff --git a/base/bind.h b/base/bind.h
index 7a400af..1070ce6 100644
--- a/base/bind.h
+++ b/base/bind.h
@@ -187,18 +187,15 @@
// well-formed. Using `Invoker::Run` with a OnceCallback triggers a
// static_assert, which is why the ternary expression does not compile.
// TODO(crbug.com/752720): Remove this indirection once we have `if constexpr`.
-template <bool is_once, typename Invoker>
-struct InvokeFuncImpl;
+template <typename Invoker>
+constexpr auto GetInvokeFunc(std::true_type) {
+ return Invoker::RunOnce;
+}
template <typename Invoker>
-struct InvokeFuncImpl<true, Invoker> {
- static constexpr auto Value = &Invoker::RunOnce;
-};
-
-template <typename Invoker>
-struct InvokeFuncImpl<false, Invoker> {
- static constexpr auto Value = &Invoker::Run;
-};
+constexpr auto GetInvokeFunc(std::false_type) {
+ return Invoker::Run;
+}
template <template <typename> class CallbackT,
typename Functor,
@@ -229,7 +226,8 @@
// InvokeFuncStorage, so that we can ensure its type matches to
// PolymorphicInvoke, to which CallbackType will cast back.
using PolymorphicInvoke = typename CallbackType::PolymorphicInvoke;
- PolymorphicInvoke invoke_func = InvokeFuncImpl<kIsOnce, Invoker>::Value;
+ PolymorphicInvoke invoke_func =
+ GetInvokeFunc<Invoker>(std::integral_constant<bool, kIsOnce>());
using InvokeFuncStorage = internal::BindStateBase::InvokeFuncStorage;
return CallbackType(BindState::Create(