Skip to content

Commit 262db73

Browse files
committed
Fix gcc compilation
1 parent 8a1cc5c commit 262db73

2 files changed

Lines changed: 24 additions & 31 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"cmake.configureArgs": [
3-
// "-DSANITIZER:BOOL=ON" // ou undefined, thread, leak, etc.
3+
"-DSANITIZER:BOOL=ON" // ou undefined, thread, leak, etc.
44
]
55
}

test/hashmap/hashmap_remove.cpp

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,35 @@
22

33
namespace hud_test
44
{
5-
struct collided_key
6-
: hud_test::non_bitwise_type
5+
struct colliding_hasher
76
{
8-
using super = hud_test::non_bitwise_type;
9-
using super::super;
10-
11-
#if defined(HD_COMPILER_GCC)
12-
virtual constexpr ~collided_key() noexcept
7+
/**
8+
* Operator to hash the value and combine it with the current hasher value.
9+
* This function uses variadic templates to accept multiple arguments.
10+
* @tparam type_t Types of the arguments to hash.
11+
* @param values Arguments to hash.
12+
* @return A 64-bit hash value.
13+
*/
14+
[[nodiscard]] constexpr u64 operator()(const hud_test::non_bitwise_type &custom) noexcept
1315
{
14-
super::~super();
16+
return hud::hash_64<i64> {}(custom.id() / 3);
1517
}
16-
#endif
17-
};
18-
} // namespace hud_test
1918

20-
namespace hud
21-
{
22-
template<>
23-
struct hash_32<hud_test::collided_key>
24-
{
25-
[[nodiscard]] constexpr u32 operator()(const hud_test::collided_key &custom) const
19+
/**
20+
* Function to hash the value and combine it with the current hasher value.
21+
* This function uses variadic templates to accept multiple arguments.
22+
* @tparam type_t Types of the arguments to hash.
23+
* @param values Arguments to hash.
24+
* @return A 64-bit hash value.
25+
*/
26+
template<typename... type_t>
27+
[[nodiscard]] constexpr u64 hash(type_t &&...values) noexcept
2628
{
27-
return hud::hash_32<i32> {}(custom.id() / 3);
29+
return (*this)(hud::forward<type_t>(values)...);
2830
}
2931
};
3032

31-
template<>
32-
struct hash_64<hud_test::collided_key>
33-
{
34-
[[nodiscard]] constexpr u64 operator()(const hud_test::collided_key &custom) const
35-
{
36-
return hud::hash_64<i32> {}(custom.id() / 3);
37-
}
38-
};
39-
40-
} // namespace hud
33+
} // namespace hud_test
4134

4235
GTEST_TEST(hashmap, remove_non_trivial_type)
4336
{
@@ -202,9 +195,9 @@ GTEST_TEST(hashmap, remove_non_trivial_type)
202195

203196
GTEST_TEST(hashmap, remove_collided_key)
204197
{
205-
using key_type = hud_test::collided_key;
198+
using key_type = hud_test::non_bitwise_type;
206199
using value_type = hud_test::non_bitwise_type;
207-
using hashmap_type = hud::hashmap<key_type, value_type>;
200+
using hashmap_type = hud::hashmap<key_type, value_type, hud_test::colliding_hasher>;
208201

209202
// This test add 128 value remove every y elements check the map,
210203
// then readd the removed elements and re check again the map by iterating over values

0 commit comments

Comments
 (0)