From 2f3a6740b78600ba9f9e47fc5ac4aa43d85e8a25 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Fri, 17 Feb 2023 03:26:59 +0700 Subject: [PATCH] rewrite all "is_valid" methods to "is_empty" --- develop/singles/headers/meta.hpp/meta_all.hpp | 48 +++++++++---------- .../meta_base/fixed_function_tests.cpp | 8 ++-- .../untests/meta_base/memory_buffer_tests.cpp | 18 +++---- develop/untests/meta_states/evalue_tests.cpp | 2 +- .../untests/meta_states/function_tests.cpp | 2 +- develop/untests/meta_states/member_tests.cpp | 2 +- develop/untests/meta_states/method_tests.cpp | 2 +- develop/untests/meta_states/scope_tests.cpp | 4 +- .../untests/meta_states/variable_tests.cpp | 2 +- develop/untests/meta_types/any_type_tests.cpp | 2 +- .../untests/meta_types/array_type_tests.cpp | 2 +- .../meta_types/function_type_tests.cpp | 2 +- .../untests/meta_types/member_type_tests.cpp | 2 +- .../untests/meta_types/method_type_tests.cpp | 2 +- .../untests/meta_types/number_type_tests.cpp | 2 +- .../untests/meta_types/pointer_type_tests.cpp | 2 +- .../meta_types/reference_type_tests.cpp | 2 +- .../untests/meta_types/void_type_tests.cpp | 2 +- headers/meta.hpp/meta_base/fixed_function.hpp | 6 +-- headers/meta.hpp/meta_base/memory_buffer.hpp | 6 +-- headers/meta.hpp/meta_states.hpp | 16 +++---- headers/meta.hpp/meta_types.hpp | 16 +++---- headers/meta.hpp/meta_types/class_type.hpp | 4 +- 23 files changed, 77 insertions(+), 77 deletions(-) diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index c0edece..ab94c93 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -433,12 +433,12 @@ namespace meta_hpp::detail return *this; } - [[nodiscard]] bool is_valid() const noexcept { - return vtable_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return vtable_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { - return is_valid(); + return vtable_ != nullptr; } R operator()(Args... args) const { @@ -1080,12 +1080,12 @@ namespace meta_hpp::detail reset(); } - [[nodiscard]] bool is_valid() const noexcept { - return data_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return data_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { - return is_valid(); + return data_ != nullptr; } void reset() noexcept { @@ -2227,8 +2227,8 @@ namespace meta_hpp type_base& operator=(type_base&&) noexcept = default; type_base& operator=(const type_base&) = default; - [[nodiscard]] bool is_valid() const noexcept { - return data_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return data_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { @@ -2489,7 +2489,7 @@ namespace std template < meta_hpp::detail::type_family Type > struct hash { size_t operator()(const Type& type) const noexcept { - return type.is_valid() ? type.get_id().get_hash() : 0; + return type.is_empty() ? 0 : type.get_id().get_hash(); } }; } @@ -2498,15 +2498,15 @@ namespace meta_hpp { template < detail::type_family L, detail::type_family R > [[nodiscard]] bool operator==(const L& l, const R& r) noexcept { - return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_id() == r.get_id()); + return l.is_empty() == r.is_empty() && (l.is_empty() || 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 { - if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) { + if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) { return cmp; } - return l.is_valid() ? l.get_id() <=> r.get_id() : std::strong_ordering::equal; + return l.is_empty() ? std::strong_ordering::equal : l.get_id() <=> r.get_id(); } } @@ -2514,12 +2514,12 @@ namespace meta_hpp { template < detail::type_family L > [[nodiscard]] bool operator==(const L& l, type_id r) noexcept { - return l.is_valid() && l.get_id() == r; + return !l.is_empty() && l.get_id() == r; } template < detail::type_family L > [[nodiscard]] std::strong_ordering operator<=>(const L& l, type_id r) noexcept { - return l.is_valid() ? l.get_id() <=> r : std::strong_ordering::less; + return !l.is_empty() ? l.get_id() <=> r : std::strong_ordering::less; } } @@ -3209,8 +3209,8 @@ namespace meta_hpp state_base& operator=(state_base&&) noexcept = default; state_base& operator=(const state_base&) = default; - [[nodiscard]] bool is_valid() const noexcept { - return state_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return state_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { @@ -3466,7 +3466,7 @@ namespace std template < meta_hpp::detail::state_family State > struct hash { size_t operator()(const State& state) const noexcept { - return state.is_valid() ? state.get_index().get_hash() : 0; + return state.is_empty() ? 0 : state.get_index().get_hash(); } }; } @@ -3475,15 +3475,15 @@ namespace meta_hpp { template < detail::state_family L, detail::state_family R > [[nodiscard]] bool operator==(const L& l, const R& r) noexcept { - return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_index() == r.get_index()); + return l.is_empty() == r.is_empty() && (l.is_empty() || 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 { - if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) { + if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) { return cmp; } - return l.is_valid() ? l.get_index() <=> r.get_index() : std::strong_ordering::equal; + return l.is_empty() ? std::strong_ordering::equal : l.get_index() <=> r.get_index(); } } @@ -3491,12 +3491,12 @@ namespace meta_hpp { template < detail::state_family L, detail::index_family R > [[nodiscard]] bool operator==(const L& l, const R& r) noexcept { - return l.is_valid() && l.get_index() == r; + return !l.is_empty() && l.get_index() == r; } template < detail::state_family L, detail::index_family R > [[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept { - return l.is_valid() ? l.get_index() <=> r : std::strong_ordering::less; + return !l.is_empty() ? l.get_index() <=> r : std::strong_ordering::less; } } @@ -7602,7 +7602,7 @@ namespace meta_hpp } inline bool class_type::is_base_of(const class_type& derived) const noexcept { - if ( !is_valid() || !derived.is_valid() ) { + if ( is_empty() || derived.is_empty() ) { return false; } @@ -7626,7 +7626,7 @@ namespace meta_hpp } inline bool class_type::is_derived_from(const class_type& base) const noexcept { - if ( !is_valid() || !base.is_valid() ) { + if ( is_empty() || base.is_empty() ) { return false; } diff --git a/develop/untests/meta_base/fixed_function_tests.cpp b/develop/untests/meta_base/fixed_function_tests.cpp index ca163b8..8e32ada 100644 --- a/develop/untests/meta_base/fixed_function_tests.cpp +++ b/develop/untests/meta_base/fixed_function_tests.cpp @@ -15,12 +15,12 @@ TEST_CASE("meta/meta_base/fixed_function") { { fixed_function ff; CHECK_FALSE(ff); - CHECK_FALSE(ff.is_valid()); + CHECK(ff.is_empty()); } { fixed_function ff = []{}; CHECK(ff); - CHECK(ff.is_valid()); + CHECK_FALSE(ff.is_empty()); } } @@ -46,11 +46,11 @@ TEST_CASE("meta/meta_base/fixed_function") { ff.reset(); CHECK_FALSE(ff); - CHECK_FALSE(ff.is_valid()); + CHECK(ff.is_empty()); ff = []{return 1;}; CHECK(ff); - CHECK(ff.is_valid()); + CHECK_FALSE(ff.is_empty()); CHECK(ff() == 1); } diff --git a/develop/untests/meta_base/memory_buffer_tests.cpp b/develop/untests/meta_base/memory_buffer_tests.cpp index 286d8f1..5413695 100644 --- a/develop/untests/meta_base/memory_buffer_tests.cpp +++ b/develop/untests/meta_base/memory_buffer_tests.cpp @@ -15,7 +15,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { memory_buffer buf; CHECK(!buf); - CHECK(!buf.is_valid()); + CHECK(buf.is_empty()); CHECK(buf.get_size() == 0); CHECK(buf.get_align() == std::align_val_t{}); @@ -32,7 +32,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { { CHECK(!buf1); - CHECK(!buf1.is_valid()); + CHECK(buf1.is_empty()); CHECK(buf1.get_size() == 0); CHECK(buf1.get_align() == std::align_val_t{}); @@ -43,7 +43,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { { CHECK(buf2); - CHECK(buf2.is_valid()); + CHECK(!buf2.is_empty()); CHECK(buf2.get_size() == 10); CHECK(buf2.get_align() == std::align_val_t{32}); @@ -57,7 +57,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { memory_buffer buf{10, std::align_val_t{32}}; CHECK(buf); - CHECK(buf.is_valid()); + CHECK(!buf.is_empty()); CHECK(buf.get_size() == 10); CHECK(buf.get_align() == std::align_val_t{32}); @@ -82,7 +82,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { { CHECK(!buf1); - CHECK(!buf1.is_valid()); + CHECK(buf1.is_empty()); CHECK(buf1.get_size() == 0); CHECK(buf1.get_align() == std::align_val_t{}); @@ -93,7 +93,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { { CHECK(buf2); - CHECK(buf2.is_valid()); + CHECK(!buf2.is_empty()); CHECK(buf2.get_size() == 10); CHECK(buf2.get_align() == std::align_val_t{32}); @@ -112,7 +112,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { { CHECK(!buf1); - CHECK(!buf1.is_valid()); + CHECK(buf1.is_empty()); CHECK(buf1.get_size() == 0); CHECK(buf1.get_align() == std::align_val_t{}); @@ -123,7 +123,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { { CHECK(buf2); - CHECK(buf2.is_valid()); + CHECK(!buf2.is_empty()); CHECK(buf2.get_size() == 10); CHECK(buf2.get_align() == std::align_val_t{32}); @@ -138,7 +138,7 @@ TEST_CASE("meta/meta_base/memory_buffer") { buf.reset(); CHECK(!buf); - CHECK(!buf.is_valid()); + CHECK(buf.is_empty()); CHECK(buf.get_size() == 0); CHECK(buf.get_align() == std::align_val_t{}); diff --git a/develop/untests/meta_states/evalue_tests.cpp b/develop/untests/meta_states/evalue_tests.cpp index a6b5b42..650e50e 100644 --- a/develop/untests/meta_states/evalue_tests.cpp +++ b/develop/untests/meta_states/evalue_tests.cpp @@ -34,7 +34,7 @@ TEST_CASE("meta/meta_states/evalue") { SUBCASE("") { const meta::evalue evalue; CHECK_FALSE(evalue); - CHECK_FALSE(evalue.is_valid()); + CHECK(evalue.is_empty()); CHECK(evalue == color_type.get_evalue("non-existent-evalue")); } diff --git a/develop/untests/meta_states/function_tests.cpp b/develop/untests/meta_states/function_tests.cpp index 8fd3a42..6ae8a98 100644 --- a/develop/untests/meta_states/function_tests.cpp +++ b/develop/untests/meta_states/function_tests.cpp @@ -51,7 +51,7 @@ TEST_CASE("meta/meta_states/function") { SUBCASE("") { const meta::function func; CHECK_FALSE(func); - CHECK_FALSE(func.is_valid()); + CHECK(func.is_empty()); CHECK(func == ivec2_type.get_function("non-existent-function")); } diff --git a/develop/untests/meta_states/member_tests.cpp b/develop/untests/meta_states/member_tests.cpp index 2b338ad..d21e863 100644 --- a/develop/untests/meta_states/member_tests.cpp +++ b/develop/untests/meta_states/member_tests.cpp @@ -38,7 +38,7 @@ TEST_CASE("meta/meta_states/member") { SUBCASE("") { const meta::member member; CHECK_FALSE(member); - CHECK_FALSE(member.is_valid()); + CHECK(member.is_empty()); CHECK(member == clazz_1_type.get_member("non-existent-member")); } diff --git a/develop/untests/meta_states/method_tests.cpp b/develop/untests/meta_states/method_tests.cpp index 7896505..39378a1 100644 --- a/develop/untests/meta_states/method_tests.cpp +++ b/develop/untests/meta_states/method_tests.cpp @@ -102,7 +102,7 @@ TEST_CASE("meta/meta_states/method") { SUBCASE("") { const meta::method method; CHECK_FALSE(method); - CHECK_FALSE(method.is_valid()); + CHECK(method.is_empty()); CHECK(method == ct.get_method("non-existent-method")); } diff --git a/develop/untests/meta_states/scope_tests.cpp b/develop/untests/meta_states/scope_tests.cpp index 8be6265..d1ba989 100644 --- a/develop/untests/meta_states/scope_tests.cpp +++ b/develop/untests/meta_states/scope_tests.cpp @@ -57,7 +57,7 @@ TEST_CASE("meta/meta_states/scope") { const meta::scope math_scope = meta::resolve_scope("meta/meta_states/scope/math"); REQUIRE(math_scope); - REQUIRE(math_scope.is_valid()); + REQUIRE(!math_scope.is_empty()); CHECK(math_scope.get_name() == "meta/meta_states/scope/math"); CHECK(math_scope.get_variables().size() == 2); @@ -66,7 +66,7 @@ TEST_CASE("meta/meta_states/scope") { SUBCASE("") { const meta::scope scope; CHECK_FALSE(scope); - CHECK_FALSE(scope.is_valid()); + CHECK(scope.is_empty()); } SUBCASE("operators") { diff --git a/develop/untests/meta_states/variable_tests.cpp b/develop/untests/meta_states/variable_tests.cpp index d28e2d1..26dffbf 100644 --- a/develop/untests/meta_states/variable_tests.cpp +++ b/develop/untests/meta_states/variable_tests.cpp @@ -68,7 +68,7 @@ TEST_CASE("meta/meta_states/variable") { SUBCASE("") { const meta::variable variable; CHECK_FALSE(variable); - CHECK_FALSE(variable.is_valid()); + CHECK(variable.is_empty()); CHECK(variable == clazz_1_type.get_variable("non-existent-variable")); } diff --git a/develop/untests/meta_types/any_type_tests.cpp b/develop/untests/meta_types/any_type_tests.cpp index 1f851b0..15cfc32 100644 --- a/develop/untests/meta_types/any_type_tests.cpp +++ b/develop/untests/meta_types/any_type_tests.cpp @@ -39,7 +39,7 @@ TEST_CASE("meta/meta_types/any_type") { SUBCASE("") { const meta::any_type type{}; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); CHECK_FALSE(type.is_array()); CHECK_FALSE(type.as_array()); diff --git a/develop/untests/meta_types/array_type_tests.cpp b/develop/untests/meta_types/array_type_tests.cpp index eb46470..eb5f54d 100644 --- a/develop/untests/meta_types/array_type_tests.cpp +++ b/develop/untests/meta_types/array_type_tests.cpp @@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/array_type") { SUBCASE("") { const meta::array_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("int[]") { diff --git a/develop/untests/meta_types/function_type_tests.cpp b/develop/untests/meta_types/function_type_tests.cpp index f445018..c4fdbe1 100644 --- a/develop/untests/meta_types/function_type_tests.cpp +++ b/develop/untests/meta_types/function_type_tests.cpp @@ -30,7 +30,7 @@ TEST_CASE("meta/meta_types/function_type") { SUBCASE("") { const meta::function_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("arg_copy") { diff --git a/develop/untests/meta_types/member_type_tests.cpp b/develop/untests/meta_types/member_type_tests.cpp index 695ddbd..600930d 100644 --- a/develop/untests/meta_types/member_type_tests.cpp +++ b/develop/untests/meta_types/member_type_tests.cpp @@ -21,7 +21,7 @@ TEST_CASE("meta/meta_types/member_type") { SUBCASE("") { const meta::member_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("int") { diff --git a/develop/untests/meta_types/method_type_tests.cpp b/develop/untests/meta_types/method_type_tests.cpp index 90b982e..db14c8a 100644 --- a/develop/untests/meta_types/method_type_tests.cpp +++ b/develop/untests/meta_types/method_type_tests.cpp @@ -33,7 +33,7 @@ TEST_CASE("meta/meta_types/method_type") { SUBCASE("") { const meta::method_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("ivec2::at") { diff --git a/develop/untests/meta_types/number_type_tests.cpp b/develop/untests/meta_types/number_type_tests.cpp index d9dc437..a03731c 100644 --- a/develop/untests/meta_types/number_type_tests.cpp +++ b/develop/untests/meta_types/number_type_tests.cpp @@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/number_type") { SUBCASE("") { const meta::number_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("int") { diff --git a/develop/untests/meta_types/pointer_type_tests.cpp b/develop/untests/meta_types/pointer_type_tests.cpp index acbeff2..7fbff76 100644 --- a/develop/untests/meta_types/pointer_type_tests.cpp +++ b/develop/untests/meta_types/pointer_type_tests.cpp @@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/pointer_type") { SUBCASE("") { const meta::pointer_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("int*") { diff --git a/develop/untests/meta_types/reference_type_tests.cpp b/develop/untests/meta_types/reference_type_tests.cpp index 85b5ceb..f809b01 100644 --- a/develop/untests/meta_types/reference_type_tests.cpp +++ b/develop/untests/meta_types/reference_type_tests.cpp @@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/reference_type") { SUBCASE("") { const meta::reference_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("int&") { diff --git a/develop/untests/meta_types/void_type_tests.cpp b/develop/untests/meta_types/void_type_tests.cpp index 1d89669..855940f 100644 --- a/develop/untests/meta_types/void_type_tests.cpp +++ b/develop/untests/meta_types/void_type_tests.cpp @@ -13,7 +13,7 @@ TEST_CASE("meta/meta_types/void_type") { SUBCASE("") { const meta::void_type type; CHECK_FALSE(type); - CHECK_FALSE(type.is_valid()); + CHECK(type.is_empty()); } SUBCASE("void") { diff --git a/headers/meta.hpp/meta_base/fixed_function.hpp b/headers/meta.hpp/meta_base/fixed_function.hpp index f294d39..1a849ec 100644 --- a/headers/meta.hpp/meta_base/fixed_function.hpp +++ b/headers/meta.hpp/meta_base/fixed_function.hpp @@ -55,12 +55,12 @@ namespace meta_hpp::detail return *this; } - [[nodiscard]] bool is_valid() const noexcept { - return vtable_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return vtable_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { - return is_valid(); + return vtable_ != nullptr; } R operator()(Args... args) const { diff --git a/headers/meta.hpp/meta_base/memory_buffer.hpp b/headers/meta.hpp/meta_base/memory_buffer.hpp index 0c0155e..0838e59 100644 --- a/headers/meta.hpp/meta_base/memory_buffer.hpp +++ b/headers/meta.hpp/meta_base/memory_buffer.hpp @@ -50,12 +50,12 @@ namespace meta_hpp::detail reset(); } - [[nodiscard]] bool is_valid() const noexcept { - return data_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return data_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { - return is_valid(); + return data_ != nullptr; } void reset() noexcept { diff --git a/headers/meta.hpp/meta_states.hpp b/headers/meta.hpp/meta_states.hpp index 5c8b39e..2000cdf 100644 --- a/headers/meta.hpp/meta_states.hpp +++ b/headers/meta.hpp/meta_states.hpp @@ -132,8 +132,8 @@ namespace meta_hpp state_base& operator=(state_base&&) noexcept = default; state_base& operator=(const state_base&) = default; - [[nodiscard]] bool is_valid() const noexcept { - return state_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return state_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { @@ -389,7 +389,7 @@ namespace std template < meta_hpp::detail::state_family State > struct hash { size_t operator()(const State& state) const noexcept { - return state.is_valid() ? state.get_index().get_hash() : 0; + return state.is_empty() ? 0 : state.get_index().get_hash(); } }; } @@ -398,15 +398,15 @@ namespace meta_hpp { template < detail::state_family L, detail::state_family R > [[nodiscard]] bool operator==(const L& l, const R& r) noexcept { - return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_index() == r.get_index()); + return l.is_empty() == r.is_empty() && (l.is_empty() || 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 { - if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) { + if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) { return cmp; } - return l.is_valid() ? l.get_index() <=> r.get_index() : std::strong_ordering::equal; + return l.is_empty() ? std::strong_ordering::equal : l.get_index() <=> r.get_index(); } } @@ -414,12 +414,12 @@ namespace meta_hpp { template < detail::state_family L, detail::index_family R > [[nodiscard]] bool operator==(const L& l, const R& r) noexcept { - return l.is_valid() && l.get_index() == r; + return !l.is_empty() && l.get_index() == r; } template < detail::state_family L, detail::index_family R > [[nodiscard]] std::strong_ordering operator<=>(const L& l, const R& r) noexcept { - return l.is_valid() ? l.get_index() <=> r : std::strong_ordering::less; + return !l.is_empty() ? l.get_index() <=> r : std::strong_ordering::less; } } diff --git a/headers/meta.hpp/meta_types.hpp b/headers/meta.hpp/meta_types.hpp index 8cc0b9e..37ec974 100644 --- a/headers/meta.hpp/meta_types.hpp +++ b/headers/meta.hpp/meta_types.hpp @@ -65,8 +65,8 @@ namespace meta_hpp type_base& operator=(type_base&&) noexcept = default; type_base& operator=(const type_base&) = default; - [[nodiscard]] bool is_valid() const noexcept { - return data_ != nullptr; + [[nodiscard]] bool is_empty() const noexcept { + return data_ == nullptr; } [[nodiscard]] explicit operator bool() const noexcept { @@ -327,7 +327,7 @@ namespace std template < meta_hpp::detail::type_family Type > struct hash { size_t operator()(const Type& type) const noexcept { - return type.is_valid() ? type.get_id().get_hash() : 0; + return type.is_empty() ? 0 : type.get_id().get_hash(); } }; } @@ -336,15 +336,15 @@ namespace meta_hpp { template < detail::type_family L, detail::type_family R > [[nodiscard]] bool operator==(const L& l, const R& r) noexcept { - return l.is_valid() == r.is_valid() && (!l.is_valid() || l.get_id() == r.get_id()); + return l.is_empty() == r.is_empty() && (l.is_empty() || 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 { - if ( const std::strong_ordering cmp{l.is_valid() <=> r.is_valid()}; cmp != std::strong_ordering::equal ) { + if ( const std::strong_ordering cmp{!l.is_empty() <=> !r.is_empty()}; cmp != std::strong_ordering::equal ) { return cmp; } - return l.is_valid() ? l.get_id() <=> r.get_id() : std::strong_ordering::equal; + return l.is_empty() ? std::strong_ordering::equal : l.get_id() <=> r.get_id(); } } @@ -352,12 +352,12 @@ namespace meta_hpp { template < detail::type_family L > [[nodiscard]] bool operator==(const L& l, type_id r) noexcept { - return l.is_valid() && l.get_id() == r; + return !l.is_empty() && l.get_id() == r; } template < detail::type_family L > [[nodiscard]] std::strong_ordering operator<=>(const L& l, type_id r) noexcept { - return l.is_valid() ? l.get_id() <=> r : std::strong_ordering::less; + return !l.is_empty() ? l.get_id() <=> r : std::strong_ordering::less; } } diff --git a/headers/meta.hpp/meta_types/class_type.hpp b/headers/meta.hpp/meta_types/class_type.hpp index 7df3545..43a1055 100644 --- a/headers/meta.hpp/meta_types/class_type.hpp +++ b/headers/meta.hpp/meta_types/class_type.hpp @@ -132,7 +132,7 @@ namespace meta_hpp } inline bool class_type::is_base_of(const class_type& derived) const noexcept { - if ( !is_valid() || !derived.is_valid() ) { + if ( is_empty() || derived.is_empty() ) { return false; } @@ -156,7 +156,7 @@ namespace meta_hpp } inline bool class_type::is_derived_from(const class_type& base) const noexcept { - if ( !is_valid() || !base.is_valid() ) { + if ( is_empty() || base.is_empty() ) { return false; }