diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h b/chromium/third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h new file mode 100644 index 00000000000..47b58a73115 --- /dev/null +++ b/chromium/third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h @@ -0,0 +1,45 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_SET_H_ +#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_SET_H_ + +#include "third_party/blink/renderer/platform/heap/heap.h" +#include "third_party/blink/renderer/platform/heap/heap_allocator_impl.h" +#include "third_party/blink/renderer/platform/heap/visitor.h" +#include "third_party/blink/renderer/platform/wtf/hash_set.h" + +namespace blink { + +template <typename ValueArg, + typename HashArg = typename DefaultHash<ValueArg>::Hash, + typename TraitsArg = HashTraits<ValueArg>> +class HeapHashSet final + : public GarbageCollected<HeapHashSet<ValueArg, HashArg, TraitsArg>>, + public HashSet<ValueArg, HashArg, TraitsArg, HeapAllocator> { + DISALLOW_NEW(); + + public: + HeapHashSet() = default; + + void Trace(Visitor* visitor) const { + CheckType(); + HashSet<ValueArg, HashArg, TraitsArg, HeapAllocator>::Trace(visitor); + } + + private: + static constexpr void CheckType() { + static_assert(WTF::IsMemberOrWeakMemberType<ValueArg>::value, + "HeapHashSet supports only Member and WeakMember."); + static_assert(std::is_trivially_destructible<HeapHashSet>::value, + "HeapHashSet must be trivially destructible."); + static_assert(WTF::IsTraceable<ValueArg>::value, + "For hash sets without traceable elements, use HashSet<> " + "instead of HeapHashSet<>."); + } +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_COLLECTION_SUPPORT_HEAP_HASH_SET_H_ |