disable different states comparing

This commit is contained in:
BlackMATov
2023-03-11 22:52:23 +07:00
parent 2866b71e87
commit debecad420
4 changed files with 33 additions and 34 deletions

View File

@@ -2840,13 +2840,13 @@ namespace std
namespace meta_hpp
{
template < detail::type_family L, detail::type_family R >
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
template < detail::type_family TypeL, detail::type_family TypeR >
[[nodiscard]] bool operator==(const TypeL& l, const TypeR& r) noexcept {
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_id() == r.get_id());
}
template < detail::type_family L, detail::type_family R >
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
template < detail::type_family TypeL, detail::type_family TypeR >
[[nodiscard]] std::strong_ordering operator<=>(const TypeL& l, const TypeR& r) noexcept {
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
return cmp;
}
@@ -2856,13 +2856,13 @@ namespace meta_hpp
namespace meta_hpp
{
template < detail::type_family L >
[[nodiscard]] bool operator==(const L& l, const typename L::id_type& r) noexcept {
template < detail::type_family Type >
[[nodiscard]] bool operator==(const Type& l, const typename Type::id_type& r) noexcept {
return l.is_valid() && l.get_id() == r;
}
template < detail::type_family L >
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const typename L::id_type& r) noexcept {
template < detail::type_family Type >
[[nodiscard]] std::strong_ordering operator<=>(const Type& l, const typename Type::id_type& r) noexcept {
return l.is_valid() ? l.get_id() <=> r : std::strong_ordering::less;
}
}
@@ -3968,13 +3968,13 @@ namespace std
namespace meta_hpp
{
template < detail::state_family L, detail::state_family R >
[[nodiscard]] bool operator==(const L& l, const R& r) noexcept {
template < detail::state_family State >
[[nodiscard]] bool operator==(const State& l, const State& r) noexcept {
return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_index() == r.get_index());
}
template < detail::state_family L, detail::state_family R >
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept {
template < detail::state_family State >
[[nodiscard]] std::strong_ordering operator<=>(const State& l, const State& r) noexcept {
if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) {
return cmp;
}
@@ -3984,13 +3984,13 @@ namespace meta_hpp
namespace meta_hpp
{
template < detail::state_family L >
[[nodiscard]] bool operator==(const L& l, const typename L::index_type& r) noexcept {
template < detail::state_family State >
[[nodiscard]] bool operator==(const State& l, const typename State::index_type& r) noexcept {
return l.is_valid() && l.get_index() == r;
}
template < detail::state_family L >
[[nodiscard]] std::strong_ordering operator<=>(const L& l, const typename L::index_type& r) noexcept {
template < detail::state_family State >
[[nodiscard]] std::strong_ordering operator<=>(const State& l, const typename State::index_type& r) noexcept {
return l.is_valid() ? l.get_index() <=> r : std::strong_ordering::less;
}
}

View File

@@ -66,8 +66,7 @@ TEST_CASE("meta/meta_types/ops") {
CHECK(ivec2_x.get_type() != meta_hpp::member_type{});
CHECK(meta_hpp::member_type{} != ivec2_x.get_type());
CHECK(ivec2_x.get_type() < ivec2_add.get_type());
CHECK_FALSE(ivec2_add.get_type() < ivec2_x.get_type());
CHECK((ivec2_x.get_type() < ivec2_add.get_type() || ivec2_add.get_type() < ivec2_x.get_type()));
CHECK_FALSE(ivec2_x.get_type() < meta_hpp::member_type{});
CHECK(meta_hpp::member_type{} < ivec2_x.get_type());