diff --git a/examples/btree.cc b/examples/btree.cc index 4ff8e23..9d56419 100644 --- a/examples/btree.cc +++ b/examples/btree.cc @@ -4,7 +4,11 @@ int main() { - // initialise map with some values using an initializer_list + phmap::btree_multimap foo; + for (auto it = foo.begin(); it != foo.end(); it++) { + } + + // initialise map with some values using an initializer_list phmap::btree_map map = { { "John", 35 }, { "Jane", 32 }, diff --git a/examples/matt.cc b/examples/matt.cc index 51afcce..a19194c 100644 --- a/examples/matt.cc +++ b/examples/matt.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -14,7 +15,7 @@ class Timer { public: - Timer(std::string name) : _name(name), _start(std::chrono::high_resolution_clock::now()) {} + Timer(std::string name) : _name(std::move(name)), _start(std::chrono::high_resolution_clock::now()) {} ~Timer() { @@ -63,7 +64,7 @@ using Perturb = std::function &)>; // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- template -void test(const char *name, Perturb perturb1, Perturb /* perturb2 */) +void test(const char *name, const Perturb &perturb1, const Perturb& /* perturb2 */) { //phmap::btree_set s; Set s; diff --git a/examples/mt_word_counter.cc b/examples/mt_word_counter.cc index 78971fb..eb93a0f 100644 --- a/examples/mt_word_counter.cc +++ b/examples/mt_word_counter.cc @@ -48,6 +48,7 @@ int main() { // run 4 threads, each thread processing lines from one of the vectors // ------------------------------------------------------------------- + threads.reserve(num_threads); for (int i = 0; i < num_threads; ++i) { threads.emplace_back( [&word_counts](std::vector&& lines) { diff --git a/examples/pmr.cc b/examples/pmr.cc index 5c13524..1141696 100644 --- a/examples/pmr.cc +++ b/examples/pmr.cc @@ -16,7 +16,7 @@ struct MyStruct { template using ParallelFlatHashMap = phmap::parallel_flat_hash_map, std::equal_to, - std::pmr::polymorphic_allocator>>; + std::pmr::polymorphic_allocator>>; ParallelFlatHashMap hashMap; diff --git a/examples/serialize.cc b/examples/serialize.cc index 0d44109..4b17c74 100644 --- a/examples/serialize.cc +++ b/examples/serialize.cc @@ -55,7 +55,7 @@ public: // -------------------------------------------------------------------------- // -------------------------------------------------------------------------- -void showtime(const char *name, std::function doit) +void showtime(const char *name, const std::function& doit) { auto t1 = std::chrono::high_resolution_clock::now(); doit(); diff --git a/parallel_hashmap/btree.h b/parallel_hashmap/btree.h index f584981..5304e42 100644 --- a/parallel_hashmap/btree.h +++ b/parallel_hashmap/btree.h @@ -737,13 +737,13 @@ namespace priv { StringBtreeDefaultLess(std::less) {} // NOLINT StringBtreeDefaultLess(phmap::Less) {} // NOLINT - phmap::weak_ordering operator()(std::string_view lhs, - std::string_view rhs) const { + phmap::weak_ordering operator()(const std::string_view &lhs, + const std::string_view &rhs) const { return compare_internal::compare_result_as_ordering(lhs.compare(rhs)); } #else - phmap::weak_ordering operator()(std::string lhs, - std::string rhs) const { + phmap::weak_ordering operator()(const std::string &lhs, + const std::string &rhs) const { return compare_internal::compare_result_as_ordering(lhs.compare(rhs)); } #endif @@ -763,8 +763,8 @@ namespace priv { return compare_internal::compare_result_as_ordering(rhs.compare(lhs)); } #else - phmap::weak_ordering operator()(std::string lhs, - std::string rhs) const { + phmap::weak_ordering operator()(const std::string &lhs, + const std::string &rhs) const { return compare_internal::compare_result_as_ordering(rhs.compare(lhs)); } #endif diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index dc113a0..94dc26c 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -1190,9 +1190,9 @@ public: size_(phmap::exchange(that.size_, 0)), capacity_(phmap::exchange(that.capacity_, 0)), infoz_(phmap::exchange(that.infoz_, HashtablezInfoHandle())), - // Hash, equality and allocator are copied instead of moved because - // `that` must be left valid. If Hash is std::function, moving it - // would create a nullptr functor that cannot be called. + // Hash, equality and allocator are copied instead of moved because + // `that` must be left valid. If Hash is std::function, moving it + // would create a nullptr functor that cannot be called. settings_(that.settings_) { // growth_left was copied above, reset the one from `that`. that.growth_left() = 0; diff --git a/parallel_hashmap/phmap_base.h b/parallel_hashmap/phmap_base.h index bc9a7d4..28676d5 100644 --- a/parallel_hashmap/phmap_base.h +++ b/parallel_hashmap/phmap_base.h @@ -2047,7 +2047,7 @@ public: optional(const optional& src) = default; // Move constructor, standard semantics - optional(optional&& src) = default; + optional(optional&& src) noexcept = default; // Constructs a non-empty `optional` direct-initialized value of type `T` from // the arguments `std::forward(args)...` within the `optional`. @@ -2187,7 +2187,7 @@ public: optional& operator=(const optional& src) = default; // Move assignment operator, standard semantics - optional& operator=(optional&& src) = default; + optional& operator=(optional&& src) noexcept = default; // Value assignment operators template < @@ -4765,7 +4765,7 @@ public: DoNothing(mutex_type&, phmap::try_to_lock_t) {} template explicit DoNothing(T&&) {} DoNothing& operator=(const DoNothing&) { return *this; } - DoNothing& operator=(DoNothing&&) { return *this; } + DoNothing& operator=(DoNothing&&) noexcept { return *this; } void swap(DoNothing &) {} bool owns_lock() const noexcept { return true; } }; @@ -4796,13 +4796,13 @@ public: m_->try_lock(); } - WriteLock(WriteLock &&o) : + WriteLock(WriteLock &&o) noexcept : m_(std::move(o.m_)), locked_(std::move(o.locked_)) { o.locked_ = false; o.m_ = nullptr; } - WriteLock& operator=(WriteLock&& other) { + WriteLock& operator=(WriteLock&& other) noexcept { WriteLock temp(std::move(other)); swap(temp); return *this; @@ -4874,13 +4874,13 @@ public: m_->try_lock_shared(); } - ReadLock(ReadLock &&o) : + ReadLock(ReadLock &&o) noexcept : m_(std::move(o.m_)), locked_(std::move(o.locked_)) { o.locked_ = false; o.m_ = nullptr; } - ReadLock& operator=(ReadLock&& other) { + ReadLock& operator=(ReadLock&& other) noexcept { ReadLock temp(std::move(other)); swap(temp); return *this;