Skip to content

Commit

Permalink
Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Tessil committed Sep 14, 2024
1 parent 95df683 commit fd95fb4
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 35 deletions.
9 changes: 7 additions & 2 deletions include/tsl/bhopscotch_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ class bhopscotch_map {
return m_ht.erase(key, precalculated_hash);
}

void swap(bhopscotch_map& other) noexcept(noexcept(other.m_ht.swap(m_ht))) { other.m_ht.swap(m_ht); }
void swap(bhopscotch_map& other) noexcept(noexcept(other.m_ht.swap(m_ht))) {
other.m_ht.swap(m_ht);
}

/*
* Lookup
Expand Down Expand Up @@ -786,7 +788,10 @@ class bhopscotch_map {
return !operator==(lhs, rhs);
}

friend void swap(bhopscotch_map& lhs, bhopscotch_map& rhs) noexcept(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); }
friend void swap(bhopscotch_map& lhs,
bhopscotch_map& rhs) noexcept(noexcept(lhs.swap(rhs))) {
lhs.swap(rhs);
}

private:
ht m_ht;
Expand Down
9 changes: 7 additions & 2 deletions include/tsl/bhopscotch_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ class bhopscotch_set {
return m_ht.erase(key, precalculated_hash);
}

void swap(bhopscotch_set& other) noexcept(noexcept(other.m_ht.swap(m_ht))) { other.m_ht.swap(m_ht); }
void swap(bhopscotch_set& other) noexcept(noexcept(other.m_ht.swap(m_ht))) {
other.m_ht.swap(m_ht);
}

/*
* Lookup
Expand Down Expand Up @@ -598,7 +600,10 @@ class bhopscotch_set {
return !operator==(lhs, rhs);
}

friend void swap(bhopscotch_set& lhs, bhopscotch_set& rhs) noexcept(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); }
friend void swap(bhopscotch_set& lhs,
bhopscotch_set& rhs) noexcept(noexcept(lhs.swap(rhs))) {
lhs.swap(rhs);
}

private:
ht m_ht;
Expand Down
14 changes: 8 additions & 6 deletions include/tsl/hopscotch_growth_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,15 @@ class prime_growth_policy {
* SFINAE helper to detect growth policies which can be noexcept-initialized
* with a zero min bucket count.
*/
template<typename>
template <typename>
struct is_noexcept_on_zero_init : std::false_type {};
template<std::size_t GrowthFactor>
struct is_noexcept_on_zero_init<power_of_two_growth_policy<GrowthFactor>> : std::true_type {};
template<class GrowthFactor>
struct is_noexcept_on_zero_init<mod_growth_policy<GrowthFactor>> : std::true_type {};
template<>
template <std::size_t GrowthFactor>
struct is_noexcept_on_zero_init<power_of_two_growth_policy<GrowthFactor>>
: std::true_type {};
template <class GrowthFactor>
struct is_noexcept_on_zero_init<mod_growth_policy<GrowthFactor>>
: std::true_type {};
template <>
struct is_noexcept_on_zero_init<prime_growth_policy> : std::true_type {};

} // namespace hh
Expand Down
47 changes: 26 additions & 21 deletions include/tsl/hopscotch_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

#include "hopscotch_growth_policy.h"


namespace tsl {
namespace detail_hopscotch_hash {

Expand Down Expand Up @@ -585,13 +584,15 @@ class hopscotch_hash : private Hash, private KeyEqual, private GrowthPolicy {
template <
class OC = OverflowContainer,
typename std::enable_if<!has_key_compare<OC>::value>::type* = nullptr>
hopscotch_hash() noexcept(hopscotch_hash::DEFAULT_INIT_BUCKETS_SIZE == 0 &&
std::is_nothrow_default_constructible<Hash>::value &&
std::is_nothrow_default_constructible<KeyEqual>::value &&
std::is_nothrow_default_constructible<Allocator>::value &&
(std::is_nothrow_constructible<GrowthPolicy, std::size_t&>::value ||
hh::is_noexcept_on_zero_init<GrowthPolicy>::value))
: hopscotch_hash(DEFAULT_INIT_BUCKETS_SIZE, Hash(), KeyEqual(), Allocator(), DEFAULT_MAX_LOAD_FACTOR) {}
hopscotch_hash() noexcept(
hopscotch_hash::DEFAULT_INIT_BUCKETS_SIZE == 0 &&
std::is_nothrow_default_constructible<Hash>::value &&
std::is_nothrow_default_constructible<KeyEqual>::value &&
std::is_nothrow_default_constructible<Allocator>::value &&
(std::is_nothrow_constructible<GrowthPolicy, std::size_t&>::value ||
hh::is_noexcept_on_zero_init<GrowthPolicy>::value))
: hopscotch_hash(DEFAULT_INIT_BUCKETS_SIZE, Hash(), KeyEqual(),
Allocator(), DEFAULT_MAX_LOAD_FACTOR) {}

template <
class OC = OverflowContainer,
Expand Down Expand Up @@ -633,13 +634,16 @@ class hopscotch_hash : private Hash, private KeyEqual, private GrowthPolicy {
template <
class OC = OverflowContainer,
typename std::enable_if<has_key_compare<OC>::value>::type* = nullptr>
hopscotch_hash() noexcept(hopscotch_hash::DEFAULT_INIT_BUCKETS_SIZE == 0 &&
std::is_nothrow_default_constructible<Hash>::value &&
std::is_nothrow_default_constructible<KeyEqual>::value &&
std::is_nothrow_default_constructible<Allocator>::value &&
(std::is_nothrow_constructible<GrowthPolicy, std::size_t&>::value ||
hh::is_noexcept_on_zero_init<GrowthPolicy>::value))
: hopscotch_hash(DEFAULT_INIT_BUCKETS_SIZE, Hash(), KeyEqual(), Allocator(), DEFAULT_MAX_LOAD_FACTOR, typename OC::key_compare()) {}
hopscotch_hash() noexcept(
hopscotch_hash::DEFAULT_INIT_BUCKETS_SIZE == 0 &&
std::is_nothrow_default_constructible<Hash>::value &&
std::is_nothrow_default_constructible<KeyEqual>::value &&
std::is_nothrow_default_constructible<Allocator>::value &&
(std::is_nothrow_constructible<GrowthPolicy, std::size_t&>::value ||
hh::is_noexcept_on_zero_init<GrowthPolicy>::value))
: hopscotch_hash(DEFAULT_INIT_BUCKETS_SIZE, Hash(), KeyEqual(),
Allocator(), DEFAULT_MAX_LOAD_FACTOR,
typename OC::key_compare()) {}

template <
class OC = OverflowContainer,
Expand Down Expand Up @@ -741,7 +745,8 @@ class hopscotch_hash : private Hash, private KeyEqual, private GrowthPolicy {
return *this;
}

hopscotch_hash& operator=(hopscotch_hash&& other) noexcept(noexcept(other.swap(*this))) {
hopscotch_hash& operator=(hopscotch_hash&& other) noexcept(
noexcept(other.swap(*this))) {
other.swap(*this);
other.clear();

Expand Down Expand Up @@ -1046,11 +1051,11 @@ class hopscotch_hash : private Hash, private KeyEqual, private GrowthPolicy {
return 0;
}

void swap(hopscotch_hash& other) noexcept(std::is_nothrow_swappable<Hash>::value &&
std::is_nothrow_swappable<KeyEqual>::value &&
std::is_nothrow_swappable<GrowthPolicy>::value &&
std::is_nothrow_swappable<buckets_container_type>::value &&
std::is_nothrow_swappable<overflow_container_type>::value) {
void swap(hopscotch_hash& other) noexcept(
std::is_nothrow_swappable<Hash>::value&& std::is_nothrow_swappable<
KeyEqual>::value&& std::is_nothrow_swappable<GrowthPolicy>::value&&
std::is_nothrow_swappable<buckets_container_type>::value&&
std::is_nothrow_swappable<overflow_container_type>::value) {
using std::swap;

swap(static_cast<Hash&>(*this), static_cast<Hash&>(other));
Expand Down
9 changes: 7 additions & 2 deletions include/tsl/hopscotch_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ class hopscotch_map {
return m_ht.erase(key, precalculated_hash);
}

void swap(hopscotch_map& other) noexcept(noexcept(other.m_ht.swap(m_ht))) { other.m_ht.swap(m_ht); }
void swap(hopscotch_map& other) noexcept(noexcept(other.m_ht.swap(m_ht))) {
other.m_ht.swap(m_ht);
}

/*
* Lookup
Expand Down Expand Up @@ -784,7 +786,10 @@ class hopscotch_map {
return !operator==(lhs, rhs);
}

friend void swap(hopscotch_map& lhs, hopscotch_map& rhs) noexcept(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); }
friend void swap(hopscotch_map& lhs,
hopscotch_map& rhs) noexcept(noexcept(lhs.swap(rhs))) {
lhs.swap(rhs);
}

private:
ht m_ht;
Expand Down
9 changes: 7 additions & 2 deletions include/tsl/hopscotch_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ class hopscotch_set {
return m_ht.erase(key, precalculated_hash);
}

void swap(hopscotch_set& other) noexcept(noexcept(other.m_ht.swap(m_ht))) { other.m_ht.swap(m_ht); }
void swap(hopscotch_set& other) noexcept(noexcept(other.m_ht.swap(m_ht))) {
other.m_ht.swap(m_ht);
}

/*
* Lookup
Expand Down Expand Up @@ -601,7 +603,10 @@ class hopscotch_set {
return !operator==(lhs, rhs);
}

friend void swap(hopscotch_set& lhs, hopscotch_set& rhs) noexcept(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); }
friend void swap(hopscotch_set& lhs,
hopscotch_set& rhs) noexcept(noexcept(lhs.swap(rhs))) {
lhs.swap(rhs);
}

private:
ht m_ht;
Expand Down

0 comments on commit fd95fb4

Please sign in to comment.