Broom 1.0.0
A thread-local C++ Garbage Collector
Loading...
Searching...
No Matches
broom-unordered-map.h
Go to the documentation of this file.
1#pragma once
2
3#include <unordered_map>
4
5#include "broom.h"
6#include "impl/broom-containers.h"
7
8#define UNORDERED_MAP_METHODS(X_) \
9 CPP11_UNORDERED_MAP_METHODS(X_) \
10 CPP14_UNORDERED_MAP_METHODS(X_) \
11 CPP17_UNORDERED_MAP_METHODS(X_) \
12 CPP20_UNORDERED_MAP_METHODS(X_) \
13 CPP23_UNORDERED_MAP_METHODS(X_)
14
15namespace broom {
28// XXX(gc): Implement via forwarding instead?
29template <typename Key, typename T, typename Hash = std::hash<Key>,
30 typename KeyEqual = std::equal_to<Key>,
31 typename Allocator = std::allocator<std::pair<const Key, T>>>
33 : private std::unordered_map<Key, T, Hash, KeyEqual, Allocator>,
34 public BroomValue {
35 using Base = std::unordered_map<Key, T, Hash, KeyEqual, Allocator>;
36
37 public:
38 // TODO(gc): We probably need some more explicit constructors to make this
39 // work in all cases.
43 : Base(il), BroomValue() {}
44 unordered_map(std::initializer_list<std::pair<const Key, T>> il,
45 typename Base::size_type bucket_count,
46 const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(),
47 const Allocator& alloc = Allocator())
48 : Base(il, bucket_count, hash, equal, alloc), BroomValue() {}
52 for (const auto& [k, v] : *this) {
54 VISIT_HELPER(v, T);
55 }
56 }
57};
58} // namespace broom
59
60#undef UNORDERED_MAP_METHODS
61
62#include "impl/broom-undef.h"
#define UNORDERED_MAP_METHODS(X_)
unordered_map(std::initializer_list< std::pair< const Key, T > > il, typename Base::size_type bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
virtual void Visit(Visitor *visitor) const
std::queue< T, broom::deque< T > > queue
Definition broom-queue.h:12