Skip to content

Commit 9293d5c

Browse files
valdmannCommit Bot
authored and
Commit Bot
committed
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}
1 parent 21d4373 commit 9293d5c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

base/bind.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,12 @@ template <bool is_once, typename Invoker>
191191
struct InvokeFuncImpl;
192192

193193
template <typename Invoker>
194-
struct InvokeFuncImpl<true, Invoker> {
195-
static constexpr auto Value = &Invoker::RunOnce;
196-
};
194+
struct InvokeFuncImpl<true, Invoker>
195+
: std::integral_constant<decltype(&Invoker::RunOnce), &Invoker::RunOnce> {};
197196

198197
template <typename Invoker>
199-
struct InvokeFuncImpl<false, Invoker> {
200-
static constexpr auto Value = &Invoker::Run;
201-
};
198+
struct InvokeFuncImpl<false, Invoker>
199+
: std::integral_constant<decltype(&Invoker::Run), &Invoker::Run> {};
202200

203201
template <template <typename> class CallbackT,
204202
typename Functor,
@@ -229,7 +227,7 @@ decltype(auto) BindImpl(Functor&& functor, Args&&... args) {
229227
// InvokeFuncStorage, so that we can ensure its type matches to
230228
// PolymorphicInvoke, to which CallbackType will cast back.
231229
using PolymorphicInvoke = typename CallbackType::PolymorphicInvoke;
232-
PolymorphicInvoke invoke_func = InvokeFuncImpl<kIsOnce, Invoker>::Value;
230+
PolymorphicInvoke invoke_func = InvokeFuncImpl<kIsOnce, Invoker>::value;
233231

234232
using InvokeFuncStorage = internal::BindStateBase::InvokeFuncStorage;
235233
return CallbackType(BindState::Create(

0 commit comments

Comments
 (0)