Skip to content

Commit 4b0c435

Browse files
author
Julian LALU
committed
Add more hashmap test
1 parent 84a3c4b commit 4b0c435

File tree

3 files changed

+425
-401
lines changed

3 files changed

+425
-401
lines changed

interface/core/containers/hashmap.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ namespace hud
1212
using key_type = key_t;
1313
using value_type = value_t;
1414

15-
constexpr explicit slot(const key_type &key, const value_type &value) noexcept
15+
template<typename u_key_t, typename u_value_t>
16+
requires(hud::is_constructible_v<hud::pair<key_type, value_type>, u_key_t, u_value_t>)
17+
constexpr explicit slot(const u_key_t &key, const u_value_t &value) noexcept
1618
: element_(key, value)
1719
{
1820
}
@@ -24,6 +26,21 @@ namespace hud
2426
{
2527
}
2628

29+
constexpr explicit(!(hud::is_convertible_v<const hud::pair<key_type, value_type> &, hud::pair<key_type, value_type>>))
30+
slot(const slot &other) noexcept
31+
requires(hud::is_nothrow_copy_constructible_v<hud::pair<key_type, value_type>>)
32+
= default;
33+
34+
template<typename u_key_t = key_t, typename u_value_t = value_t>
35+
requires(hud::is_copy_constructible_v<hud::pair<key_type, value_type>, hud::pair<u_key_t, u_value_t>>)
36+
constexpr explicit(!(hud::is_convertible_v<const hud::pair<key_type, value_type> &, hud::pair<u_key_t, u_value_t>>))
37+
slot(const slot<u_key_t, u_value_t> &other) noexcept
38+
: element_(other.element_)
39+
{
40+
static_assert(hud::is_nothrow_copy_constructible_v<key_t, u_key_t>, "key_t(const u_key_t&) copy constructor is throwable. slot is not designed to allow throwable copy constructible components");
41+
static_assert(hud::is_nothrow_copy_constructible_v<value_t, u_value_t>, "value_t(const u_value_t&) copy constructor is throwable. slot is not designed to allow throwable copy constructible components");
42+
}
43+
2744
[[nodiscard]] constexpr const key_type &key() noexcept
2845
{
2946
return hud::get<0>(element_);
@@ -74,6 +91,10 @@ namespace hud
7491
return hud::get<idx_to_reach>(hud::forward<const slot>(s).element_);
7592
}
7693

94+
private:
95+
template<typename u_key_t, typename u_value_t>
96+
friend struct slot;
97+
7798
private:
7899
hud::pair<key_type, value_type> element_;
79100
};

interface/core/traits/is_convertible.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ namespace hud
4444

4545
#endif
4646

47-
/** Equivalent of hud::is_convertible<from_t,to_t>::value. */
47+
/**
48+
* Checks whether from_t is implicitly convertible to to_t.
49+
* Equivalent of hud::is_convertible<from_t,to_t>::value.
50+
* */
4851
template<typename from_t, typename to_t>
4952
inline constexpr bool is_convertible_v = hud::is_convertible<from_t, to_t>::value;
5053

0 commit comments

Comments
 (0)