mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 03:45:30 +07:00
compare ops hashed_string with string_view
This commit is contained in:
@@ -77,12 +77,17 @@ TEST_CASE("meta/meta_base/hashed_string") {
|
||||
constexpr hashed_string hs2{"hello"};
|
||||
static_assert(!(hs1 < hs2) && !(hs2 < hs1));
|
||||
static_assert(hs1 < hashed_string{"world"} || hashed_string{"world"} < hs1);
|
||||
static_assert((hs1 < "world" || hs1 > "world"));
|
||||
static_assert(("world" < hs1 || "world" > hs1));
|
||||
}
|
||||
|
||||
SUBCASE("operator==") {
|
||||
constexpr hashed_string hs1{"hello"};
|
||||
static_assert(hs1 == hashed_string{"hello"});
|
||||
static_assert(hs1 != hashed_string{"world"});
|
||||
static_assert(hs1 == "hello");
|
||||
static_assert("hello" == hs1);
|
||||
static_assert("world" != hs1);
|
||||
}
|
||||
|
||||
SUBCASE("swap") {
|
||||
|
||||
@@ -45,6 +45,12 @@ namespace meta_hpp::detail
|
||||
};
|
||||
|
||||
constexpr void swap(hashed_string& l, hashed_string& r) noexcept { l.swap(r); }
|
||||
|
||||
[[nodiscard]] constexpr bool operator==(hashed_string l, std::string_view r) noexcept { return l == hashed_string{r}; }
|
||||
[[nodiscard]] constexpr bool operator==(std::string_view l, hashed_string r) noexcept { return hashed_string{l} == r; }
|
||||
|
||||
[[nodiscard]] constexpr std::strong_ordering operator<=>(hashed_string l, std::string_view r) noexcept { return l <=> hashed_string{r}; }
|
||||
[[nodiscard]] constexpr std::strong_ordering operator<=>(std::string_view l, hashed_string r) noexcept { return hashed_string{l} <=> r; }
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace meta_hpp::detail
|
||||
return id;
|
||||
}
|
||||
};
|
||||
|
||||
inline void swap(type_id& l, type_id& r) noexcept { l.swap(r); }
|
||||
}
|
||||
|
||||
namespace std
|
||||
|
||||
Reference in New Issue
Block a user