Commit 512359ed authored by Jose Dapena Paz's avatar Jose Dapena Paz Committed by Commit Bot

GCC: avoid WTF vector backed linked list template specialization

GCC refuses to compile the recently added ConstructAndNotifyElementImpl
Construct method, that gets a template specialization inside the struct
namespace. This is not working in GCC.

To avoid that, we avoid the template specialization using a new struct
for when type is garbage collected, and select the struct with
std::conditional.

Bug: 819294
Change-Id: Ibd88999c2667b1130c0132864ec692b1e0a8fbc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304575Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: José Dapena Paz <jdapena@igalia.com>
Cr-Commit-Position: refs/heads/master@{#790746}
parent af48c8e6
......@@ -107,7 +107,7 @@ class ConstructTraits<VectorBackedLinkedListNode<ValueType, Allocator>,
template <typename... Args>
static Node* ConstructAndNotifyElement(void* location, Args&&... args) {
Node* object = ConstructAndNotifyElementImpl<>::Construct(
Node* object = ConstructAndNotifyElementImpl::Construct(
location, std::forward<Args>(args)...);
NotifyNewElement(object);
return object;
......@@ -118,8 +118,7 @@ class ConstructTraits<VectorBackedLinkedListNode<ValueType, Allocator>,
}
private:
template <bool = Allocator::kIsGarbageCollected>
struct ConstructAndNotifyElementImpl {
struct ConstructAndNotifyElementImplNotGarbageCollected {
template <typename... Args>
static Node* Construct(void* location, Args&&... args) {
return ConstructTraits<Node, Traits, Allocator>::Construct(
......@@ -127,8 +126,7 @@ class ConstructTraits<VectorBackedLinkedListNode<ValueType, Allocator>,
}
};
template <>
struct ConstructAndNotifyElementImpl<true> {
struct ConstructAndNotifyElementImplGarbageCollected {
static Node* Construct(void* location, Node&& element) {
// ConstructAndNotifyElement updates an existing node which might
// also be concurrently traced while we update it. The regular ctors
......@@ -140,6 +138,11 @@ class ConstructTraits<VectorBackedLinkedListNode<ValueType, Allocator>,
return reinterpret_cast<Node*>(location);
}
};
using ConstructAndNotifyElementImpl = typename std::conditional<
Allocator::kIsGarbageCollected,
ConstructAndNotifyElementImplGarbageCollected,
ConstructAndNotifyElementImplNotGarbageCollected>::type;
};
// VectorBackedLinkedList maintains a linked list through its contents such that
......
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