From 1ebd2e75edfe26f6a3b6674111989dbb388a524e Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 12 Jan 2023 09:44:55 +0700 Subject: [PATCH] implicit uvalue's ctor from value, remove all uvalue's dynamic operators --- develop/manuals/meta_manuals/class_manual.cpp | 2 +- develop/manuals/meta_manuals/enum_manual.cpp | 4 +- .../manuals/meta_manuals/inplace_manual.cpp | 6 +- .../manuals/meta_manuals/method_manual.cpp | 2 +- .../manuals/meta_manuals/scopes_manual.cpp | 16 +- .../manuals/meta_manuals/variable_manual.cpp | 2 +- develop/singles/headers/meta.hpp/meta_all.hpp | 145 +------- develop/untests/meta_states/dtor_tests.cpp | 4 +- develop/untests/meta_states/evalue_tests.cpp | 4 +- .../untests/meta_states/function_tests.cpp | 56 ++-- develop/untests/meta_states/member_tests.cpp | 104 +++--- .../untests/meta_states/metadata_tests.cpp | 130 ++++---- develop/untests/meta_states/method_tests.cpp | 312 +++++++++--------- .../untests/meta_states/variable_tests.cpp | 36 +- .../untests/meta_types/enum_type_tests.cpp | 12 +- develop/untests/meta_utilities/arg6_tests.cpp | 8 +- develop/untests/meta_utilities/arg_tests.cpp | 4 +- develop/untests/meta_utilities/inst_tests.cpp | 4 +- .../untests/meta_utilities/invoke_tests.cpp | 32 +- .../untests/meta_utilities/value_tests.cpp | 127 +++---- .../value_traits/istream_traits.hpp | 34 -- .../value_traits/ostream_traits.hpp | 34 -- headers/meta.hpp/meta_types/enum_type.hpp | 2 +- headers/meta.hpp/meta_uvalue.hpp | 5 +- headers/meta.hpp/meta_uvalue/uvalue.hpp | 92 ------ 25 files changed, 410 insertions(+), 767 deletions(-) delete mode 100644 headers/meta.hpp/meta_detail/value_traits/istream_traits.hpp delete mode 100644 headers/meta.hpp/meta_detail/value_traits/ostream_traits.hpp diff --git a/develop/manuals/meta_manuals/class_manual.cpp b/develop/manuals/meta_manuals/class_manual.cpp index 7a7c251..e740deb 100644 --- a/develop/manuals/meta_manuals/class_manual.cpp +++ b/develop/manuals/meta_manuals/class_manual.cpp @@ -79,5 +79,5 @@ TEST_CASE("meta/meta_examples/class/usage") { const meta::uvalue rectangle_v = rectangle_type.create(10, 20); // calls the method with the dynamic rectangle instance 'rectangle_v' - CHECK(rectangle_area.invoke(rectangle_v) == 200); + CHECK(rectangle_area.invoke(rectangle_v).get_as() == 200); } diff --git a/develop/manuals/meta_manuals/enum_manual.cpp b/develop/manuals/meta_manuals/enum_manual.cpp index 30dc563..f9c304a 100644 --- a/develop/manuals/meta_manuals/enum_manual.cpp +++ b/develop/manuals/meta_manuals/enum_manual.cpp @@ -38,7 +38,7 @@ TEST_CASE("meta/meta_examples/enum/type") { // prints all enumerators std::cout << "* align" << std::endl; for ( auto&& [index, evalue] : align_type.get_evalues() ) { - std::cout << " - " << index.get_name() << "/" << evalue.get_underlying_value() << std::endl; + std::cout << " - " << index.get_name() << "/" << evalue.get_underlying_value().get_as() << std::endl; } } @@ -54,5 +54,5 @@ TEST_CASE("meta/meta_examples/enum/usage") { CHECK(align_type.value_to_name(e) == "center"); // ... and back again - CHECK(align_type.name_to_value("center") == e); + CHECK(align_type.name_to_value("center").get_as() == e); } diff --git a/develop/manuals/meta_manuals/inplace_manual.cpp b/develop/manuals/meta_manuals/inplace_manual.cpp index 506bc5f..c79eca4 100644 --- a/develop/manuals/meta_manuals/inplace_manual.cpp +++ b/develop/manuals/meta_manuals/inplace_manual.cpp @@ -57,9 +57,9 @@ TEST_CASE("meta/meta_examples/inplace") { CHECK(ivec2_ptr.get_type() == meta::resolve_type()); // interacts with the created object as usual - CHECK(ivec2_x.get(ivec2_ptr) == 2); - CHECK(ivec2_y.get(ivec2_ptr) == 3); - CHECK(ivec2_length2(ivec2_ptr) == 13); + CHECK(ivec2_x.get(ivec2_ptr).get_as() == 2); + CHECK(ivec2_y.get(ivec2_ptr).get_as() == 3); + CHECK(ivec2_length2(ivec2_ptr).get_as() == 13); // you must manually call the object's destructor CHECK(ivec2_type.destroy_at(ivec2_buffer.get_memory())); diff --git a/develop/manuals/meta_manuals/method_manual.cpp b/develop/manuals/meta_manuals/method_manual.cpp index b82212d..6150d17 100644 --- a/develop/manuals/meta_manuals/method_manual.cpp +++ b/develop/manuals/meta_manuals/method_manual.cpp @@ -73,7 +73,7 @@ TEST_CASE("meta/meta_examples/method/usage") { // checks the type and value of the result CHECK(ivec2_add_result_value.get_type() == meta::resolve_type()); - CHECK(ivec2_add_result_value == ivec2{42, 21}); + CHECK(ivec2_add_result_value.get_as() == ivec2{42, 21}); // checks the result of our manipulations CHECK(v == ivec2{42, 21}); diff --git a/develop/manuals/meta_manuals/scopes_manual.cpp b/develop/manuals/meta_manuals/scopes_manual.cpp index 75ce2e5..47de3d5 100644 --- a/develop/manuals/meta_manuals/scopes_manual.cpp +++ b/develop/manuals/meta_manuals/scopes_manual.cpp @@ -72,18 +72,18 @@ TEST_CASE("meta/meta_examples/scopes/local") { const meta::function dot3_function = math_scope.get_function("dot3"); // calls and checks found functions - CHECK(dot2_function(ivec2{3,4}, ivec2{5,6}) == 39); - CHECK(dot3_function(ivec3{3,4,5}, ivec3{6,7,8}) == 86); + CHECK(dot2_function(ivec2{3,4}, ivec2{5,6}).get_as() == 39); + CHECK(dot3_function(ivec3{3,4,5}, ivec3{6,7,8}).get_as() == 86); // and free variables, of course const meta::variable unit2_variable = math_scope.get_variable("unit2"); const meta::variable unit3_variable = math_scope.get_variable("unit3"); // checks and uses found variables with functions - CHECK(unit2_variable.get() == ivec2{1,1}); - CHECK(unit3_variable.get() == ivec3{1,1,1}); - CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()) == 2); - CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()) == 3); + CHECK(unit2_variable.get().get_as() == ivec2{1,1}); + CHECK(unit3_variable.get().get_as() == ivec3{1,1,1}); + CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()).get_as() == 2); + CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).get_as() == 3); } TEST_CASE("meta/meta_examples/scopes/global") { @@ -106,6 +106,6 @@ TEST_CASE("meta/meta_examples/scopes/global") { const meta::variable unit3_variable = math_scope.get_variable("unit3"); // everything works as expected - CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()) == 2); - CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()) == 3); + CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()).get_as() == 2); + CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).get_as() == 3); } diff --git a/develop/manuals/meta_manuals/variable_manual.cpp b/develop/manuals/meta_manuals/variable_manual.cpp index 167b527..8d9a261 100644 --- a/develop/manuals/meta_manuals/variable_manual.cpp +++ b/develop/manuals/meta_manuals/variable_manual.cpp @@ -44,6 +44,6 @@ TEST_CASE("meta/meta_examples/variable/usage") { // prints all variables in the scope std::cout << "* " << constants_scope.get_name() << std::endl; for ( auto&& [index, variable] : constants_scope.get_variables() ) { - std::cout << " - " << index.get_name() << ":" << variable.get() << std::endl; + std::cout << " - " << index.get_name() << ":" << variable.get().get_as() << std::endl; } } diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index 1e4df49..ad2ba18 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -2322,7 +2322,7 @@ namespace meta_hpp && (!detail::is_in_place_type_v) && (std::is_copy_constructible_v) // NOLINTNEXTLINE(*-forwarding-reference-overload) - explicit uvalue(T&& val); + uvalue(T&& val); template < typename T, typename Tp = std::decay_t > requires (!detail::any_uvalue_kind) @@ -2380,9 +2380,6 @@ namespace meta_hpp template < typename T > [[nodiscard]] auto try_get_as() const noexcept -> std::conditional_t, T, const T*>; - - friend std::istream& operator>>(std::istream& is, uvalue& v); - friend std::ostream& operator<<(std::ostream& os, const uvalue& v); private: struct vtable_t; vtable_t* vtable_{}; @@ -5632,7 +5629,7 @@ namespace meta_hpp } for ( auto&& [_, evalue] : data_->evalues ) { - if ( evalue.get_value() == value ) { + if ( evalue.get_value().get_as() == value ) { return evalue.get_index().get_name(); } } @@ -8064,54 +8061,6 @@ namespace meta_hpp::detail }; } -namespace meta_hpp::detail -{ - template < typename T > - struct istream_traits; - - template < typename T > - concept has_istream_traits = requires(std::istream& is, T& v) { - { istream_traits{}(is, v) } -> std::convertible_to; - }; -} - -namespace meta_hpp::detail -{ - template < typename T > - requires requires(std::istream& is, T& v) { - { is >> v } -> std::convertible_to; - } - struct istream_traits { - std::istream& operator()(std::istream& is, T& v) const { - return is >> v; - } - }; -} - -namespace meta_hpp::detail -{ - template < typename T > - struct ostream_traits; - - template < typename T > - concept has_ostream_traits = requires(std::ostream& os, const T& v) { - { ostream_traits{}(os, v) } -> std::convertible_to; - }; -} - -namespace meta_hpp::detail -{ - template < typename T > - requires requires(std::ostream& os, const T& v) { - { os << v } -> std::convertible_to; - } - struct ostream_traits { - std::ostream& operator()(std::ostream& os, const T& v) const { - return os << v; - } - }; -} - namespace meta_hpp { struct uvalue::vtable_t final { @@ -8127,9 +8076,6 @@ namespace meta_hpp uvalue (*const deref)(const storage_u& from); uvalue (*const index)(const storage_u& from, std::size_t); - std::istream& (*const istream)(std::istream& is, storage_u& to); - std::ostream& (*const ostream)(std::ostream& os, const storage_u& from); - template < typename T > static T* buffer_cast(buffer_t& buffer) noexcept { // NOLINTNEXTLINE(*-reinterpret-cast) @@ -8295,22 +8241,6 @@ namespace meta_hpp detail::throw_exception_with("value type doesn't have value index traits"); } }, - - .istream = +[]([[maybe_unused]] std::istream& is, [[maybe_unused]] storage_u& to) -> std::istream& { - if constexpr ( detail::has_istream_traits && !detail::pointer_kind ) { - return detail::istream_traits{}(is, *storage_cast(to)); - } else { - detail::throw_exception_with("value type doesn't have value istream traits"); - } - }, - - .ostream = +[]([[maybe_unused]] std::ostream& os, [[maybe_unused]] const storage_u& from) -> std::ostream& { - if constexpr ( detail::has_ostream_traits && !detail::pointer_kind ) { - return detail::ostream_traits{}(os, *storage_cast(from)); - } else { - detail::throw_exception_with("value type doesn't have value ostream traits"); - } - }, }; return &table; @@ -8605,74 +8535,3 @@ namespace meta_hpp return nullptr; } } - -namespace meta_hpp -{ - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator<(const uvalue& l, const T& r) { - if ( !static_cast(l) ) { - return true; - } - - const any_type& l_type = l.get_type(); - const any_type& r_type = resolve_type(); - - return (l_type < r_type) || (l_type == r_type && l.get_as() < r); - } - - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator<(const T& l, const uvalue& r) { - if ( !static_cast(r) ) { - return false; - } - - const any_type& l_type = resolve_type(); - const any_type& r_type = r.get_type(); - - return (l_type < r_type) || (l_type == r_type && l < r.get_as()); - } -} - -namespace meta_hpp -{ - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator==(const uvalue& l, const T& r) { - if ( !static_cast(l) ) { - return false; - } - - const any_type& l_type = l.get_type(); - const any_type& r_type = resolve_type(); - - return l_type == r_type && l.get_as() == r; - } - - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator==(const T& l, const uvalue& r) { - if ( !static_cast(r) ) { - return false; - } - - const any_type& l_type = resolve_type(); - const any_type& r_type = r.get_type(); - - return l_type == r_type && l == r.get_as(); - } -} - -namespace meta_hpp -{ - inline std::istream& operator>>(std::istream& is, uvalue& v) { - assert(v && "bad operator call"); // NOLINT - return v.vtable_->istream(is, v.storage_); - } - - inline std::ostream& operator<<(std::ostream& os, const uvalue& v) { - assert(v && "bad operator call"); // NOLINT - return v.vtable_->ostream(os, v.storage_); - } -} diff --git a/develop/untests/meta_states/dtor_tests.cpp b/develop/untests/meta_states/dtor_tests.cpp index f34d79e..f201cf2 100644 --- a/develop/untests/meta_states/dtor_tests.cpp +++ b/develop/untests/meta_states/dtor_tests.cpp @@ -38,7 +38,7 @@ TEST_CASE("meta/meta_states/dtor") { meta::class_() .destructor_({ .metadata{ - {"desc", meta::uvalue{"virtual dtor"s}} + {"desc", "virtual dtor"s} } }); @@ -92,6 +92,6 @@ TEST_CASE("meta/meta_states/dtor") { CHECK(dtor.get_type().get_class_type() == meta::resolve_type()); CHECK(dtor.get_type().get_flags() == (meta::destructor_flags::is_noexcept | meta::destructor_flags::is_virtual)); - CHECK(dtor.get_metadata().at("desc") == "virtual dtor"s); + CHECK(dtor.get_metadata().at("desc").get_as() == "virtual dtor"s); } } diff --git a/develop/untests/meta_states/evalue_tests.cpp b/develop/untests/meta_states/evalue_tests.cpp index 46d1c68..ed4a69c 100644 --- a/develop/untests/meta_states/evalue_tests.cpp +++ b/develop/untests/meta_states/evalue_tests.cpp @@ -53,10 +53,10 @@ TEST_CASE("meta/meta_states/evalue") { CHECK(evalue.get_type() == meta::resolve_type()); CHECK(evalue.get_name() == "green"); - CHECK(evalue.get_value() == color::green); + CHECK(evalue.get_value().get_as() == color::green); CHECK(evalue.get_value().get_type() == color_type); - CHECK(evalue.get_underlying_value() == meta::detail::to_underlying(color::green)); + CHECK(evalue.get_underlying_value().get_as() == meta::detail::to_underlying(color::green)); CHECK(evalue.get_underlying_value().get_type() == color_type.get_underlying_type()); } } diff --git a/develop/untests/meta_states/function_tests.cpp b/develop/untests/meta_states/function_tests.cpp index eecdebe..56c6080 100644 --- a/develop/untests/meta_states/function_tests.cpp +++ b/develop/untests/meta_states/function_tests.cpp @@ -88,7 +88,7 @@ TEST_CASE("meta/meta_states/function") { CHECK_THROWS(func.invoke(ivec2{}, ivec2{}, 42)); CHECK(func.invoke(ivec2{1,2}, ivec2{3,4})); - CHECK(func.invoke(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); + CHECK(func.invoke(ivec2{1,2}, ivec2{3,4}).get_as() == ivec2{4,6}); } SUBCASE("ilength2") { @@ -113,7 +113,7 @@ TEST_CASE("meta/meta_states/function") { CHECK_THROWS(func.invoke(ivec2{}, 42)); CHECK(func.invoke(ivec2{2,3})); - CHECK(func.invoke(ivec2{2,3}) == 13); + CHECK(func.invoke(ivec2{2,3}).get_as() == 13); } SUBCASE("arg_null") { @@ -125,8 +125,8 @@ TEST_CASE("meta/meta_states/function") { CHECK(func.is_invocable_with()); int i{42}; - CHECK(func.invoke(&i) == false); - CHECK(func.invoke(nullptr) == true); + CHECK(func.invoke(&i).get_as() == false); + CHECK(func.invoke(nullptr).get_as() == true); } SUBCASE("arg_arr") { @@ -145,13 +145,13 @@ TEST_CASE("meta/meta_states/function") { CHECK_FALSE(func1.is_invocable_with()); CHECK_FALSE(func1.is_invocable_with()); - CHECK(func1.invoke(bounded_arr) == 10); - CHECK(func1.invoke(unbounded_arr) == 10); + CHECK(func1.invoke(bounded_arr).get_as() == 10); + CHECK(func1.invoke(unbounded_arr).get_as() == 10); CHECK_THROWS(func1.invoke(bounded_const_arr)); CHECK_THROWS(func1.invoke(unbounded_const_arr)); - CHECK(func1.invoke(meta::uvalue{bounded_arr}) == 10); - CHECK(func1.invoke(meta::uvalue{unbounded_arr}) == 10); + CHECK(func1.invoke(meta::uvalue{bounded_arr}).get_as() == 10); + CHECK(func1.invoke(meta::uvalue{unbounded_arr}).get_as() == 10); CHECK_THROWS(func1.invoke(meta::uvalue{bounded_const_arr})); CHECK_THROWS(func1.invoke(meta::uvalue{unbounded_const_arr})); @@ -170,13 +170,13 @@ TEST_CASE("meta/meta_states/function") { CHECK_FALSE(func2.is_invocable_with()); CHECK_FALSE(func2.is_invocable_with()); - CHECK(func2.invoke(bounded_arr) == 10); - CHECK(func2.invoke(unbounded_arr) == 10); + CHECK(func2.invoke(bounded_arr).get_as() == 10); + CHECK(func2.invoke(unbounded_arr).get_as() == 10); CHECK_THROWS(func2.invoke(bounded_const_arr)); CHECK_THROWS(func2.invoke(unbounded_const_arr)); - CHECK(func2.invoke(meta::uvalue{bounded_arr}) == 10); - CHECK(func2.invoke(meta::uvalue{unbounded_arr}) == 10); + CHECK(func2.invoke(meta::uvalue{bounded_arr}).get_as() == 10); + CHECK(func2.invoke(meta::uvalue{unbounded_arr}).get_as() == 10); CHECK_THROWS(func2.invoke(meta::uvalue{bounded_const_arr})); CHECK_THROWS(func2.invoke(meta::uvalue{unbounded_const_arr})); @@ -203,15 +203,15 @@ TEST_CASE("meta/meta_states/function") { CHECK(func1.is_invocable_with()); CHECK(func1.is_invocable_with()); - CHECK(func1.invoke(bounded_arr) == 10); - CHECK(func1.invoke(unbounded_arr) == 10); - CHECK(func1.invoke(bounded_const_arr) == 10); - CHECK(func1.invoke(unbounded_const_arr) == 10); + CHECK(func1.invoke(bounded_arr).get_as() == 10); + CHECK(func1.invoke(unbounded_arr).get_as() == 10); + CHECK(func1.invoke(bounded_const_arr).get_as() == 10); + CHECK(func1.invoke(unbounded_const_arr).get_as() == 10); - CHECK(func1.invoke(meta::uvalue{bounded_arr}) == 10); - CHECK(func1.invoke(meta::uvalue{unbounded_arr}) == 10); - CHECK(func1.invoke(meta::uvalue{bounded_const_arr}) == 10); - CHECK(func1.invoke(meta::uvalue{unbounded_const_arr}) == 10); + CHECK(func1.invoke(meta::uvalue{bounded_arr}).get_as() == 10); + CHECK(func1.invoke(meta::uvalue{unbounded_arr}).get_as() == 10); + CHECK(func1.invoke(meta::uvalue{bounded_const_arr}).get_as() == 10); + CHECK(func1.invoke(meta::uvalue{unbounded_const_arr}).get_as() == 10); static_assert(std::is_invocable_v); static_assert(std::is_invocable_v); @@ -228,15 +228,15 @@ TEST_CASE("meta/meta_states/function") { CHECK(func2.is_invocable_with()); CHECK(func2.is_invocable_with()); - CHECK(func2.invoke(bounded_arr) == 10); - CHECK(func2.invoke(unbounded_arr) == 10); - CHECK(func2.invoke(bounded_const_arr) == 10); - CHECK(func2.invoke(unbounded_const_arr) == 10); + CHECK(func2.invoke(bounded_arr).get_as() == 10); + CHECK(func2.invoke(unbounded_arr).get_as() == 10); + CHECK(func2.invoke(bounded_const_arr).get_as() == 10); + CHECK(func2.invoke(unbounded_const_arr).get_as() == 10); - CHECK(func2.invoke(meta::uvalue{bounded_arr}) == 10); - CHECK(func2.invoke(meta::uvalue{unbounded_arr}) == 10); - CHECK(func2.invoke(meta::uvalue{bounded_const_arr}) == 10); - CHECK(func2.invoke(meta::uvalue{unbounded_const_arr}) == 10); + CHECK(func2.invoke(meta::uvalue{bounded_arr}).get_as() == 10); + CHECK(func2.invoke(meta::uvalue{unbounded_arr}).get_as() == 10); + CHECK(func2.invoke(meta::uvalue{bounded_const_arr}).get_as() == 10); + CHECK(func2.invoke(meta::uvalue{unbounded_const_arr}).get_as() == 10); static_assert(std::is_invocable_v); static_assert(std::is_invocable_v); diff --git a/develop/untests/meta_states/member_tests.cpp b/develop/untests/meta_states/member_tests.cpp index 7c38a2a..b28c548 100644 --- a/develop/untests/meta_states/member_tests.cpp +++ b/develop/untests/meta_states/member_tests.cpp @@ -79,19 +79,19 @@ TEST_CASE("meta/meta_states/member") { } { - CHECK(vm.get(v) == 1); - CHECK(vm.get(&v) == 1); - CHECK(vm.get(std::as_const(v)) == 1); - CHECK(vm.get(&std::as_const(v)) == 1); - CHECK(vm.get(std::move(v)) == 1); - CHECK(vm.get(std::move(std::as_const(v))) == 1); + CHECK(vm.get(v).get_as() == 1); + CHECK(vm.get(&v).get_as() == 1); + CHECK(vm.get(std::as_const(v)).get_as() == 1); + CHECK(vm.get(&std::as_const(v)).get_as() == 1); + CHECK(vm.get(std::move(v)).get_as() == 1); + CHECK(vm.get(std::move(std::as_const(v))).get_as() == 1); - CHECK(vm(v) == 1); - CHECK(vm(&v) == 1); - CHECK(vm(std::as_const(v)) == 1); - CHECK(vm(&std::as_const(v)) == 1); - CHECK(vm(std::move(v)) == 1); - CHECK(vm(std::move(std::as_const(v))) == 1); + CHECK(vm(v).get_as() == 1); + CHECK(vm(&v).get_as() == 1); + CHECK(vm(std::as_const(v)).get_as() == 1); + CHECK(vm(&std::as_const(v)).get_as() == 1); + CHECK(vm(std::move(v)).get_as() == 1); + CHECK(vm(std::move(std::as_const(v))).get_as() == 1); CHECK_THROWS(std::ignore = vm.get(v2)); CHECK_THROWS(std::ignore = vm.get(&v2)); @@ -136,27 +136,27 @@ TEST_CASE("meta/meta_states/member") { } { - vm.set(v, 10); CHECK(vm.get(v) == 10); - vm.set(&v, 100); CHECK(vm.get(v) == 100); - CHECK_THROWS(vm.set(std::as_const(v), 11)); CHECK(vm.get(v) == 100); - CHECK_THROWS(vm.set(&std::as_const(v), 11)); CHECK(vm.get(v) == 100); + vm.set(v, 10); CHECK(vm.get(v).get_as() == 10); + vm.set(&v, 100); CHECK(vm.get(v).get_as() == 100); + CHECK_THROWS(vm.set(std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 100); + CHECK_THROWS(vm.set(&std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 100); - vm.set(std::move(v), 12); CHECK(vm.get(v) == 12); - CHECK_THROWS(vm.set(std::move(std::as_const(v)), 13)); CHECK(vm.get(v) == 12); + vm.set(std::move(v), 12); CHECK(vm.get(v).get_as() == 12); + CHECK_THROWS(vm.set(std::move(std::as_const(v)), 13)); CHECK(vm.get(v).get_as() == 12); - vm(v, 13); CHECK(vm(v) == 13); - vm(&v, 130); CHECK(vm(v) == 130); - CHECK_THROWS(vm(std::as_const(v), 14)); CHECK(vm(v) == 130); - CHECK_THROWS(vm(std::as_const(v), 14)); CHECK(vm(v) == 130); + vm(v, 13); CHECK(vm(v).get_as() == 13); + vm(&v, 130); CHECK(vm(v).get_as() == 130); + CHECK_THROWS(vm(std::as_const(v), 14)); CHECK(vm(v).get_as() == 130); + CHECK_THROWS(vm(std::as_const(v), 14)); CHECK(vm(v).get_as() == 130); - vm(std::move(v), 15); CHECK(vm(v) == 15); - CHECK_THROWS(vm(std::move(std::as_const(v)), 16)); CHECK(vm(v) == 15); + vm(std::move(v), 15); CHECK(vm(v).get_as() == 15); + CHECK_THROWS(vm(std::move(std::as_const(v)), 16)); CHECK(vm(v).get_as() == 15); CHECK_THROWS(vm.set(v2, 17)); CHECK_THROWS(vm.set(&v2, 17)); CHECK_THROWS(vm(v2, 17)); CHECK_THROWS(vm(&v2, 17)); - CHECK(vm(v) == 15); + CHECK(vm(v).get_as() == 15); } } @@ -194,19 +194,19 @@ TEST_CASE("meta/meta_states/member") { } { - CHECK(vm.get(v) == 2); - CHECK(vm.get(&v) == 2); - CHECK(vm.get(std::as_const(v)) == 2); - CHECK(vm.get(&std::as_const(v)) == 2); - CHECK(vm.get(std::move(v)) == 2); - CHECK(vm.get(std::move(std::as_const(v))) == 2); + CHECK(vm.get(v).get_as() == 2); + CHECK(vm.get(&v).get_as() == 2); + CHECK(vm.get(std::as_const(v)).get_as() == 2); + CHECK(vm.get(&std::as_const(v)).get_as() == 2); + CHECK(vm.get(std::move(v)).get_as() == 2); + CHECK(vm.get(std::move(std::as_const(v))).get_as() == 2); - CHECK(vm(v) == 2); - CHECK(vm(&v) == 2); - CHECK(vm(std::as_const(v)) == 2); - CHECK(vm(&std::as_const(v)) == 2); - CHECK(vm(std::move(v)) == 2); - CHECK(vm(std::move(std::as_const(v))) == 2); + CHECK(vm(v).get_as() == 2); + CHECK(vm(&v).get_as() == 2); + CHECK(vm(std::as_const(v)).get_as() == 2); + CHECK(vm(&std::as_const(v)).get_as() == 2); + CHECK(vm(std::move(v)).get_as() == 2); + CHECK(vm(std::move(std::as_const(v))).get_as() == 2); CHECK_THROWS(std::ignore = vm.get(v2)); CHECK_THROWS(std::ignore = vm.get(&v2)); @@ -247,25 +247,25 @@ TEST_CASE("meta/meta_states/member") { } { - CHECK_THROWS(vm.set(v, 10)); CHECK(vm.get(v) == 2); - CHECK_THROWS(vm.set(&v, 10)); CHECK(vm.get(v) == 2); - CHECK_THROWS(vm.set(std::as_const(v), 11)); CHECK(vm.get(v) == 2); - CHECK_THROWS(vm.set(&std::as_const(v), 11)); CHECK(vm.get(v) == 2); - CHECK_THROWS(vm.set(std::move(v), 12)); CHECK(vm.get(v) == 2); - CHECK_THROWS(vm.set(std::move(std::as_const(v)), 16)); CHECK(vm.get(v) == 2); + CHECK_THROWS(vm.set(v, 10)); CHECK(vm.get(v).get_as() == 2); + CHECK_THROWS(vm.set(&v, 10)); CHECK(vm.get(v).get_as() == 2); + CHECK_THROWS(vm.set(std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 2); + CHECK_THROWS(vm.set(&std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 2); + CHECK_THROWS(vm.set(std::move(v), 12)); CHECK(vm.get(v).get_as() == 2); + CHECK_THROWS(vm.set(std::move(std::as_const(v)), 16)); CHECK(vm.get(v).get_as() == 2); - CHECK_THROWS(vm(v, 13)); CHECK(vm(v) == 2); - CHECK_THROWS(vm(&v, 13)); CHECK(vm(v) == 2); - CHECK_THROWS(vm(std::as_const(v), 14)); CHECK(vm(v) == 2); - CHECK_THROWS(vm(&std::as_const(v), 14)); CHECK(vm(v) == 2); - CHECK_THROWS(vm(std::move(v), 15)); CHECK(vm(v) == 2); - CHECK_THROWS(vm(std::move(std::as_const(v)), 16)); CHECK(vm(v) == 2); + CHECK_THROWS(vm(v, 13)); CHECK(vm(v).get_as() == 2); + CHECK_THROWS(vm(&v, 13)); CHECK(vm(v).get_as() == 2); + CHECK_THROWS(vm(std::as_const(v), 14)); CHECK(vm(v).get_as() == 2); + CHECK_THROWS(vm(&std::as_const(v), 14)); CHECK(vm(v).get_as() == 2); + CHECK_THROWS(vm(std::move(v), 15)); CHECK(vm(v).get_as() == 2); + CHECK_THROWS(vm(std::move(std::as_const(v)), 16)); CHECK(vm(v).get_as() == 2); CHECK_THROWS(vm.set(v2, 17)); CHECK_THROWS(vm.set(&v2, 17)); CHECK_THROWS(vm(v2, 17)); CHECK_THROWS(vm(&v2, 17)); - CHECK(vm(v) == 2); + CHECK(vm(v).get_as() == 2); } } @@ -279,13 +279,13 @@ TEST_CASE("meta/meta_states/member") { { clazz_1 v; CHECK(vm.get(v).get_type() == meta::resolve_type*>()); - CHECK(vm.get(v) == std::addressof(v.unique_int_member)); + CHECK(vm.get(v).get_as*>() == std::addressof(v.unique_int_member)); } { const clazz_1 v; CHECK(vm.get(v).get_type() == meta::resolve_type*>()); - CHECK(vm.get(v) == std::addressof(v.unique_int_member)); + CHECK(vm.get(v).get_as*>() == std::addressof(v.unique_int_member)); } } diff --git a/develop/untests/meta_states/metadata_tests.cpp b/develop/untests/meta_states/metadata_tests.cpp index ce46995..a0e5a89 100644 --- a/develop/untests/meta_states/metadata_tests.cpp +++ b/develop/untests/meta_states/metadata_tests.cpp @@ -38,30 +38,30 @@ TEST_CASE("meta/meta_states/metadata/enum") { using namespace std::string_literals; meta::enum_({ - {"desc1", meta::uvalue{"enum-desc1"s}}, - {"desc2", meta::uvalue{"enum-desc2"s}}, + {"desc1", "enum-desc1"s}, + {"desc2", "enum-desc2"s}, }) .evalue_("red", color::red, { - .metadata{{"desc1", meta::uvalue{"red-color"s}}} + .metadata{{"desc1", "red-color"s}} }) .evalue_("green", color::green, { - .metadata{{"desc1", meta::uvalue{"green-color"s}}} + .metadata{{"desc1", "green-color"s}} }) .evalue_("blue", color::blue, { - .metadata{{"desc1", meta::uvalue{"blue-color"s}}} + .metadata{{"desc1", "blue-color"s}} }); // metadata override meta::enum_({ - {"desc2", meta::uvalue{"new-enum-desc2"s}}, - {"desc3", meta::uvalue{"new-enum-desc3"s}}, + {"desc2", "new-enum-desc2"s}, + {"desc3", "new-enum-desc3"s}, }); meta::enum_() .evalue_("red", color::red, { .metadata{ - {"desc2", meta::uvalue{"new-red-color"s}}, + {"desc2", "new-red-color"s}, } }); @@ -71,16 +71,16 @@ TEST_CASE("meta/meta_states/metadata/enum") { REQUIRE(color_type); SUBCASE("color") { - CHECK(color_type.get_metadata().at("desc1") == "enum-desc1"s); - CHECK(color_type.get_metadata().at("desc2") == "new-enum-desc2"s); - CHECK(color_type.get_metadata().at("desc3") == "new-enum-desc3"s); + CHECK(color_type.get_metadata().at("desc1").get_as() == "enum-desc1"s); + CHECK(color_type.get_metadata().at("desc2").get_as() == "new-enum-desc2"s); + CHECK(color_type.get_metadata().at("desc3").get_as() == "new-enum-desc3"s); } SUBCASE("color::red") { const meta::evalue red_evalue = color_type.get_evalue("red"); REQUIRE(red_evalue); CHECK_FALSE(red_evalue.get_metadata().contains("desc1")); - CHECK(red_evalue.get_metadata().at("desc2") == "new-red-color"s); + CHECK(red_evalue.get_metadata().at("desc2").get_as() == "new-red-color"s); } } @@ -89,55 +89,55 @@ TEST_CASE("meta/meta_states/metadata/class") { using namespace std::string_literals; meta::class_({ - {"desc1", meta::uvalue{"class-desc1"s}}, - {"desc2", meta::uvalue{"class-desc2"s}}, + {"desc1", "class-desc1"s}, + {"desc2", "class-desc2"s}, }) .constructor_({ .arguments{{ .name{"v"}, - .metadata{{"desc", meta::uvalue{"the ctor arg"s}}}, + .metadata{{"desc", "the ctor arg"s}}, }}, - .metadata{{"desc", meta::uvalue{"one arg 2d vector ctor"s}}}, + .metadata{{"desc", "one arg 2d vector ctor"s}}, }) .constructor_({ .arguments{{ .name{"x"}, - .metadata{{"desc", meta::uvalue{"the 1st ctor arg"s}}}, + .metadata{{"desc", "the 1st ctor arg"s}}, },{ .name{"y"}, - .metadata{{"desc", meta::uvalue{"the 2nd ctor arg"s}}}, + .metadata{{"desc", "the 2nd ctor arg"s}}, }}, - .metadata{{"desc", meta::uvalue{"two args 2d vector ctor"s}}} + .metadata{{"desc", "two args 2d vector ctor"s}} }) .member_("x", &ivec2::x, { - .metadata{{"desc", meta::uvalue{"x-member"s}}} + .metadata{{"desc", "x-member"s}} }) .member_("y", &ivec2::y, { - .metadata{{"desc", meta::uvalue{"y-member"s}}} + .metadata{{"desc", "y-member"s}} }) .method_("add", &ivec2::add, { .arguments{{ .name{"other"}, - .metadata{{"desc", meta::uvalue{"other-arg"s}}} + .metadata{{"desc", "other-arg"s}} }}, - .metadata{{"desc", meta::uvalue{"add-method"s}}} + .metadata{{"desc", "add-method"s}} }) .function_("iadd", &ivec2::iadd, { .arguments{{ .name{"l"}, - .metadata{{"desc", meta::uvalue{"l-arg"s}}} + .metadata{{"desc", "l-arg"s}} },{ .name{"r"}, - .metadata{{"desc", meta::uvalue{"r-arg"s}}} + .metadata{{"desc", "r-arg"s}} }}, - .metadata{{"desc", meta::uvalue{"iadd-function"s}}} + .metadata{{"desc", "iadd-function"s}} }); // metadata override meta::class_({ - {"desc2", meta::uvalue{"new-class-desc2"s}}, - {"desc3", meta::uvalue{"new-class-desc3"s}}, + {"desc2", "new-class-desc2"s}, + {"desc3", "new-class-desc3"s}, }); // @@ -146,9 +146,9 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_type); SUBCASE("ivec2") { - CHECK(ivec2_type.get_metadata().at("desc1") == "class-desc1"s); - CHECK(ivec2_type.get_metadata().at("desc2") == "new-class-desc2"s); - CHECK(ivec2_type.get_metadata().at("desc3") == "new-class-desc3"s); + CHECK(ivec2_type.get_metadata().at("desc1").get_as() == "class-desc1"s); + CHECK(ivec2_type.get_metadata().at("desc2").get_as() == "new-class-desc2"s); + CHECK(ivec2_type.get_metadata().at("desc3").get_as() == "new-class-desc3"s); } SUBCASE("ivec2(int)") { @@ -156,14 +156,14 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_ctor); REQUIRE(ivec2_ctor.get_metadata().contains("desc")); - CHECK(ivec2_ctor.get_metadata().at("desc") == "one arg 2d vector ctor"s); + CHECK(ivec2_ctor.get_metadata().at("desc").get_as() == "one arg 2d vector ctor"s); REQUIRE(ivec2_ctor.get_argument(0)); CHECK(ivec2_ctor.get_argument(0).get_name() == "v"); CHECK(ivec2_ctor.get_argument(0).get_position() == 0); CHECK(ivec2_ctor.get_argument(0).get_type() == meta::resolve_type()); REQUIRE(ivec2_ctor.get_argument(0).get_metadata().contains("desc")); - CHECK(ivec2_ctor.get_argument(0).get_metadata().at("desc") == "the ctor arg"s); + CHECK(ivec2_ctor.get_argument(0).get_metadata().at("desc").get_as() == "the ctor arg"s); REQUIRE_FALSE(ivec2_ctor.get_argument(1)); } @@ -173,21 +173,21 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_ctor); REQUIRE(ivec2_ctor.get_metadata().contains("desc")); - CHECK(ivec2_ctor.get_metadata().at("desc") == "two args 2d vector ctor"s); + CHECK(ivec2_ctor.get_metadata().at("desc").get_as() == "two args 2d vector ctor"s); REQUIRE(ivec2_ctor.get_argument(0)); CHECK(ivec2_ctor.get_argument(0).get_name() == "x"); CHECK(ivec2_ctor.get_argument(0).get_position() == 0); CHECK(ivec2_ctor.get_argument(0).get_type() == meta::resolve_type()); REQUIRE(ivec2_ctor.get_argument(0).get_metadata().contains("desc")); - CHECK(ivec2_ctor.get_argument(0).get_metadata().at("desc") == "the 1st ctor arg"s); + CHECK(ivec2_ctor.get_argument(0).get_metadata().at("desc").get_as() == "the 1st ctor arg"s); REQUIRE(ivec2_ctor.get_argument(1)); CHECK(ivec2_ctor.get_argument(1).get_name() == "y"); CHECK(ivec2_ctor.get_argument(1).get_position() == 1); CHECK(ivec2_ctor.get_argument(1).get_type() == meta::resolve_type()); REQUIRE(ivec2_ctor.get_argument(1).get_metadata().contains("desc")); - CHECK(ivec2_ctor.get_argument(1).get_metadata().at("desc") == "the 2nd ctor arg"s); + CHECK(ivec2_ctor.get_argument(1).get_metadata().at("desc").get_as() == "the 2nd ctor arg"s); REQUIRE_FALSE(ivec2_ctor.get_argument(2)); } @@ -197,7 +197,7 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_x); REQUIRE(ivec2_x.get_metadata().contains("desc")); - CHECK(ivec2_x.get_metadata().at("desc") == "x-member"s); + CHECK(ivec2_x.get_metadata().at("desc").get_as() == "x-member"s); } SUBCASE("ivec2::y") { @@ -205,7 +205,7 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_y); REQUIRE(ivec2_y.get_metadata().contains("desc")); - CHECK(ivec2_y.get_metadata().at("desc") == "y-member"s); + CHECK(ivec2_y.get_metadata().at("desc").get_as() == "y-member"s); } SUBCASE("ivec2::add") { @@ -213,11 +213,11 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_add); REQUIRE(ivec2_add.get_metadata().contains("desc")); - CHECK(ivec2_add.get_metadata().at("desc") == "add-method"s); + CHECK(ivec2_add.get_metadata().at("desc").get_as() == "add-method"s); REQUIRE(ivec2_add.get_argument(0)); REQUIRE(ivec2_add.get_argument(0).get_metadata().contains("desc")); - CHECK(ivec2_add.get_argument(0).get_metadata().at("desc") == "other-arg"s); + CHECK(ivec2_add.get_argument(0).get_metadata().at("desc").get_as() == "other-arg"s); } SUBCASE("ivec2::iadd") { @@ -225,15 +225,15 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_iadd); REQUIRE(ivec2_iadd.get_metadata().contains("desc")); - CHECK(ivec2_iadd.get_metadata().at("desc") == "iadd-function"s); + CHECK(ivec2_iadd.get_metadata().at("desc").get_as() == "iadd-function"s); REQUIRE(ivec2_iadd.get_argument(0)); REQUIRE(ivec2_iadd.get_argument(0).get_metadata().contains("desc")); - CHECK(ivec2_iadd.get_argument(0).get_metadata().at("desc") == "l-arg"s); + CHECK(ivec2_iadd.get_argument(0).get_metadata().at("desc").get_as() == "l-arg"s); REQUIRE(ivec2_iadd.get_argument(1)); REQUIRE(ivec2_iadd.get_argument(1).get_metadata().contains("desc")); - CHECK(ivec2_iadd.get_argument(1).get_metadata().at("desc") == "r-arg"s); + CHECK(ivec2_iadd.get_argument(1).get_metadata().at("desc").get_as() == "r-arg"s); } } @@ -243,16 +243,16 @@ TEST_CASE("meta/meta_states/metadata/scope") { SUBCASE("local_scope") { const meta::scope lscope = meta::local_scope_("local-scope", { - {"desc", meta::uvalue{"scope-desc"s}} + {"desc", "scope-desc"s} }); - CHECK(lscope.get_metadata().at("desc") == "scope-desc"s); + CHECK(lscope.get_metadata().at("desc").get_as() == "scope-desc"s); } SUBCASE("static_scope") { meta::static_scope_("meta/meta_states/metadata/scope/static-scope", { - {"desc", meta::uvalue{"scope-desc"s}} + {"desc", "scope-desc"s} }); - CHECK(meta::resolve_scope("meta/meta_states/metadata/scope/static-scope").get_metadata().at("desc") == "scope-desc"s); + CHECK(meta::resolve_scope("meta/meta_states/metadata/scope/static-scope").get_metadata().at("desc").get_as() == "scope-desc"s); } } @@ -262,64 +262,64 @@ TEST_CASE("meta/meta_states/metadata/other") { SUBCASE("array") { meta::array_({ - {"desc", meta::uvalue{"int[]-type"s}} + {"desc", "int[]-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "int[]-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int[]-type"s); } SUBCASE("function") { meta::function_({ - {"desc", meta::uvalue{"int->int"s}} + {"desc", "int->int"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "int->int"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int->int"s); } SUBCASE("member") { meta::member_({ - {"desc", meta::uvalue{"ivec2::int"s}} + {"desc", "ivec2::int"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "ivec2::int"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "ivec2::int"s); } SUBCASE("method") { meta::method_({ - {"desc", meta::uvalue{"ivec2(int -> int)"s}} + {"desc", "ivec2(int -> int)"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "ivec2(int -> int)"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "ivec2(int -> int)"s); } SUBCASE("nullptr") { meta::nullptr_({ - {"desc", meta::uvalue{"nullptr_t"s}} + {"desc", "nullptr_t"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "nullptr_t"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "nullptr_t"s); } SUBCASE("number") { meta::number_({ - {"desc", meta::uvalue{"int-type"s}} + {"desc", "int-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "int-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int-type"s); } SUBCASE("pointer") { meta::pointer_({ - {"desc", meta::uvalue{"int*-type"s}} + {"desc", "int*-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "int*-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int*-type"s); } SUBCASE("reference") { meta::reference_({ - {"desc", meta::uvalue{"int&-type"s}} + {"desc", "int&-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "int&-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int&-type"s); } SUBCASE("void") { meta::void_({ - {"desc", meta::uvalue{"void-type"s}} + {"desc", "void-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc") == "void-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "void-type"s); } } diff --git a/develop/untests/meta_states/method_tests.cpp b/develop/untests/meta_states/method_tests.cpp index e21e2af..cabb4ad 100644 --- a/develop/untests/meta_states/method_tests.cpp +++ b/develop/untests/meta_states/method_tests.cpp @@ -143,14 +143,14 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 1); + CHECK(mi.invoke(cl).get_as() == 1); CHECK_THROWS(mi.invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)) == 1); + CHECK(mi.invoke(std::move(cl)).get_as() == 1); CHECK_THROWS(mi.invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv) == 1); + CHECK(mi.invoke(clv).get_as() == 1); CHECK_THROWS(mi.invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)) == 1); + CHECK(mi.invoke(std::move(clv)).get_as() == 1); CHECK_THROWS(mi.invoke(std::move(std::as_const(clv)))); } @@ -163,15 +163,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 1); - CHECK(mi.invoke(std::as_const(cl1)) == 1); - CHECK(mi.invoke(std::move(cl1)) == 1); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 1); + CHECK(mi.invoke(cl1).get_as() == 1); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 1); + CHECK(mi.invoke(std::move(cl1)).get_as() == 1); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 1); - CHECK(mi.invoke(cl1v) == 1); - CHECK(mi.invoke(std::as_const(cl1v)) == 1); - CHECK(mi.invoke(std::move(cl1v)) == 1); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 1); + CHECK(mi.invoke(cl1v).get_as() == 1); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 1); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 1); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 1); CHECK_THROWS(mi.invoke(cl2)); CHECK_THROWS(mi.invoke(std::as_const(cl2))); @@ -229,14 +229,14 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 2); + CHECK(mi.invoke(cl).get_as() == 2); CHECK_THROWS(mi.invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)) == 2); + CHECK(mi.invoke(std::move(cl)).get_as() == 2); CHECK_THROWS(mi.invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv) == 2); + CHECK(mi.invoke(clv).get_as() == 2); CHECK_THROWS(mi.invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)) == 2); + CHECK(mi.invoke(std::move(clv)).get_as() == 2); CHECK_THROWS(mi.invoke(std::move(std::as_const(clv)))); } @@ -249,15 +249,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 2); - CHECK(mi.invoke(std::as_const(cl1)) == 2); - CHECK(mi.invoke(std::move(cl1)) == 2); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 2); + CHECK(mi.invoke(cl1).get_as() == 2); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 2); + CHECK(mi.invoke(std::move(cl1)).get_as() == 2); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 2); - CHECK(mi.invoke(cl1v) == 2); - CHECK(mi.invoke(std::as_const(cl1v)) == 2); - CHECK(mi.invoke(std::move(cl1v)) == 2); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 2); + CHECK(mi.invoke(cl1v).get_as() == 2); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 2); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 2); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 2); CHECK_THROWS(mi.invoke(cl2)); CHECK_THROWS(mi.invoke(std::as_const(cl2))); @@ -315,15 +315,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 3); - CHECK(mi.invoke(std::as_const(cl)) == 3); - CHECK(mi.invoke(std::move(cl)) == 3); - CHECK(mi.invoke(std::move(std::as_const(cl))) == 3); + CHECK(mi.invoke(cl).get_as() == 3); + CHECK(mi.invoke(std::as_const(cl)).get_as() == 3); + CHECK(mi.invoke(std::move(cl)).get_as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 3); - CHECK(mi.invoke(clv) == 3); - CHECK(mi.invoke(std::as_const(clv)) == 3); - CHECK(mi.invoke(std::move(clv)) == 3); - CHECK(mi.invoke(std::move(std::as_const(clv))) == 3); + CHECK(mi.invoke(clv).get_as() == 3); + CHECK(mi.invoke(std::as_const(clv)).get_as() == 3); + CHECK(mi.invoke(std::move(clv)).get_as() == 3); + CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 3); } { @@ -335,25 +335,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 3); - CHECK(mi.invoke(std::as_const(cl1)) == 3); - CHECK(mi.invoke(std::move(cl1)) == 3); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 3); + CHECK(mi.invoke(cl1).get_as() == 3); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 3); + CHECK(mi.invoke(std::move(cl1)).get_as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 3); - CHECK(mi.invoke(cl1v) == 3); - CHECK(mi.invoke(std::as_const(cl1v)) == 3); - CHECK(mi.invoke(std::move(cl1v)) == 3); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 3); + CHECK(mi.invoke(cl1v).get_as() == 3); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 3); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 3); - CHECK(mi.invoke(cl2) == 3); - CHECK(mi.invoke(std::as_const(cl2)) == 3); - CHECK(mi.invoke(std::move(cl2)) == 3); - CHECK(mi.invoke(std::move(std::as_const(cl2))) == 3); + CHECK(mi.invoke(cl2).get_as() == 3); + CHECK(mi.invoke(std::as_const(cl2)).get_as() == 3); + CHECK(mi.invoke(std::move(cl2)).get_as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl2))).get_as() == 3); - CHECK(mi.invoke(cl2v) == 3); - CHECK(mi.invoke(std::as_const(cl2v)) == 3); - CHECK(mi.invoke(std::move(cl2v)) == 3); - CHECK(mi.invoke(std::move(std::as_const(cl2v))) == 3); + CHECK(mi.invoke(cl2v).get_as() == 3); + CHECK(mi.invoke(std::as_const(cl2v)).get_as() == 3); + CHECK(mi.invoke(std::move(cl2v)).get_as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).get_as() == 3); } static_assert(std::is_invocable_v); @@ -401,15 +401,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 4); - CHECK(mi.invoke(std::as_const(cl)) == 4); - CHECK(mi.invoke(std::move(cl)) == 4); - CHECK(mi.invoke(std::move(std::as_const(cl))) == 4); + CHECK(mi.invoke(cl).get_as() == 4); + CHECK(mi.invoke(std::as_const(cl)).get_as() == 4); + CHECK(mi.invoke(std::move(cl)).get_as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 4); - CHECK(mi.invoke(clv) == 4); - CHECK(mi.invoke(std::as_const(clv)) == 4); - CHECK(mi.invoke(std::move(clv)) == 4); - CHECK(mi.invoke(std::move(std::as_const(clv))) == 4); + CHECK(mi.invoke(clv).get_as() == 4); + CHECK(mi.invoke(std::as_const(clv)).get_as() == 4); + CHECK(mi.invoke(std::move(clv)).get_as() == 4); + CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 4); } { @@ -421,25 +421,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 4); - CHECK(mi.invoke(std::as_const(cl1)) == 4); - CHECK(mi.invoke(std::move(cl1)) == 4); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 4); + CHECK(mi.invoke(cl1).get_as() == 4); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 4); + CHECK(mi.invoke(std::move(cl1)).get_as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 4); - CHECK(mi.invoke(cl1v) == 4); - CHECK(mi.invoke(std::as_const(cl1v)) == 4); - CHECK(mi.invoke(std::move(cl1v)) == 4); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 4); + CHECK(mi.invoke(cl1v).get_as() == 4); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 4); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 4); - CHECK(mi.invoke(cl2) == 4); - CHECK(mi.invoke(std::as_const(cl2)) == 4); - CHECK(mi.invoke(std::move(cl2)) == 4); - CHECK(mi.invoke(std::move(std::as_const(cl2))) == 4); + CHECK(mi.invoke(cl2).get_as() == 4); + CHECK(mi.invoke(std::as_const(cl2)).get_as() == 4); + CHECK(mi.invoke(std::move(cl2)).get_as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl2))).get_as() == 4); - CHECK(mi.invoke(cl2v) == 4); - CHECK(mi.invoke(std::as_const(cl2v)) == 4); - CHECK(mi.invoke(std::move(cl2v)) == 4); - CHECK(mi.invoke(std::move(std::as_const(cl2v))) == 4); + CHECK(mi.invoke(cl2v).get_as() == 4); + CHECK(mi.invoke(std::as_const(cl2v)).get_as() == 4); + CHECK(mi.invoke(std::move(cl2v)).get_as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).get_as() == 4); } static_assert(std::is_invocable_v); @@ -482,12 +482,12 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 5); + CHECK(mi.invoke(cl).get_as() == 5); CHECK_THROWS(mi.invoke(std::as_const(cl))); CHECK_THROWS(mi.invoke(std::move(cl))); CHECK_THROWS(mi.invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv) == 5); + CHECK(mi.invoke(clv).get_as() == 5); CHECK_THROWS(mi.invoke(std::as_const(clv))); CHECK_THROWS(mi.invoke(std::move(clv))); CHECK_THROWS(mi.invoke(std::move(std::as_const(clv)))); @@ -502,15 +502,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 5); - CHECK(mi.invoke(std::as_const(cl1)) == 5); - CHECK(mi.invoke(std::move(cl1)) == 5); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 5); + CHECK(mi.invoke(cl1).get_as() == 5); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 5); + CHECK(mi.invoke(std::move(cl1)).get_as() == 5); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 5); - CHECK(mi.invoke(cl1v) == 5); - CHECK(mi.invoke(std::as_const(cl1v)) == 5); - CHECK(mi.invoke(std::move(cl1v)) == 5); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 5); + CHECK(mi.invoke(cl1v).get_as() == 5); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 5); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 5); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 5); CHECK_THROWS(mi.invoke(cl2)); CHECK_THROWS(mi.invoke(std::as_const(cl2))); @@ -563,12 +563,12 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 6); + CHECK(mi.invoke(cl).get_as() == 6); CHECK_THROWS(mi.invoke(std::as_const(cl))); CHECK_THROWS(mi.invoke(std::move(cl))); CHECK_THROWS(mi.invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv) == 6); + CHECK(mi.invoke(clv).get_as() == 6); CHECK_THROWS(mi.invoke(std::as_const(clv))); CHECK_THROWS(mi.invoke(std::move(clv))); CHECK_THROWS(mi.invoke(std::move(std::as_const(clv)))); @@ -583,15 +583,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 6); - CHECK(mi.invoke(std::as_const(cl1)) == 6); - CHECK(mi.invoke(std::move(cl1)) == 6); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 6); + CHECK(mi.invoke(cl1).get_as() == 6); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 6); + CHECK(mi.invoke(std::move(cl1)).get_as() == 6); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 6); - CHECK(mi.invoke(cl1v) == 6); - CHECK(mi.invoke(std::as_const(cl1v)) == 6); - CHECK(mi.invoke(std::move(cl1v)) == 6); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 6); + CHECK(mi.invoke(cl1v).get_as() == 6); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 6); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 6); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 6); CHECK_THROWS(mi.invoke(cl2)); CHECK_THROWS(mi.invoke(std::as_const(cl2))); @@ -644,15 +644,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 7); - CHECK(mi.invoke(std::as_const(cl)) == 7); - CHECK(mi.invoke(std::move(cl)) == 7); - CHECK(mi.invoke(std::move(std::as_const(cl))) == 7); + CHECK(mi.invoke(cl).get_as() == 7); + CHECK(mi.invoke(std::as_const(cl)).get_as() == 7); + CHECK(mi.invoke(std::move(cl)).get_as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 7); - CHECK(mi.invoke(clv) == 7); - CHECK(mi.invoke(std::as_const(clv)) == 7); - CHECK(mi.invoke(std::move(clv)) == 7); - CHECK(mi.invoke(std::move(std::as_const(clv))) == 7); + CHECK(mi.invoke(clv).get_as() == 7); + CHECK(mi.invoke(std::as_const(clv)).get_as() == 7); + CHECK(mi.invoke(std::move(clv)).get_as() == 7); + CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 7); } { @@ -664,25 +664,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 7); - CHECK(mi.invoke(std::as_const(cl1)) == 7); - CHECK(mi.invoke(std::move(cl1)) == 7); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 7); + CHECK(mi.invoke(cl1).get_as() == 7); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 7); + CHECK(mi.invoke(std::move(cl1)).get_as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 7); - CHECK(mi.invoke(cl1v) == 7); - CHECK(mi.invoke(std::as_const(cl1v)) == 7); - CHECK(mi.invoke(std::move(cl1v)) == 7); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 7); + CHECK(mi.invoke(cl1v).get_as() == 7); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 7); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 7); - CHECK(mi.invoke(cl2) == 7); - CHECK(mi.invoke(std::as_const(cl2)) == 7); - CHECK(mi.invoke(std::move(cl2)) == 7); - CHECK(mi.invoke(std::move(std::as_const(cl2))) == 7); + CHECK(mi.invoke(cl2).get_as() == 7); + CHECK(mi.invoke(std::as_const(cl2)).get_as() == 7); + CHECK(mi.invoke(std::move(cl2)).get_as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl2))).get_as() == 7); - CHECK(mi.invoke(cl2v) == 7); - CHECK(mi.invoke(std::as_const(cl2v)) == 7); - CHECK(mi.invoke(std::move(cl2v)) == 7); - CHECK(mi.invoke(std::move(std::as_const(cl2v))) == 7); + CHECK(mi.invoke(cl2v).get_as() == 7); + CHECK(mi.invoke(std::as_const(cl2v)).get_as() == 7); + CHECK(mi.invoke(std::move(cl2v)).get_as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).get_as() == 7); } static_assert(std::is_invocable_v); @@ -725,15 +725,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl) == 8); - CHECK(mi.invoke(std::as_const(cl)) == 8); - CHECK(mi.invoke(std::move(cl)) == 8); - CHECK(mi.invoke(std::move(std::as_const(cl))) == 8); + CHECK(mi.invoke(cl).get_as() == 8); + CHECK(mi.invoke(std::as_const(cl)).get_as() == 8); + CHECK(mi.invoke(std::move(cl)).get_as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 8); - CHECK(mi.invoke(clv) == 8); - CHECK(mi.invoke(std::as_const(clv)) == 8); - CHECK(mi.invoke(std::move(clv)) == 8); - CHECK(mi.invoke(std::move(std::as_const(clv))) == 8); + CHECK(mi.invoke(clv).get_as() == 8); + CHECK(mi.invoke(std::as_const(clv)).get_as() == 8); + CHECK(mi.invoke(std::move(clv)).get_as() == 8); + CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 8); } { @@ -745,25 +745,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - CHECK(mi.invoke(cl1) == 8); - CHECK(mi.invoke(std::as_const(cl1)) == 8); - CHECK(mi.invoke(std::move(cl1)) == 8); - CHECK(mi.invoke(std::move(std::as_const(cl1))) == 8); + CHECK(mi.invoke(cl1).get_as() == 8); + CHECK(mi.invoke(std::as_const(cl1)).get_as() == 8); + CHECK(mi.invoke(std::move(cl1)).get_as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl1))).get_as() == 8); - CHECK(mi.invoke(cl1v) == 8); - CHECK(mi.invoke(std::as_const(cl1v)) == 8); - CHECK(mi.invoke(std::move(cl1v)) == 8); - CHECK(mi.invoke(std::move(std::as_const(cl1v))) == 8); + CHECK(mi.invoke(cl1v).get_as() == 8); + CHECK(mi.invoke(std::as_const(cl1v)).get_as() == 8); + CHECK(mi.invoke(std::move(cl1v)).get_as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).get_as() == 8); - CHECK(mi.invoke(cl2) == 8); - CHECK(mi.invoke(std::as_const(cl2)) == 8); - CHECK(mi.invoke(std::move(cl2)) == 8); - CHECK(mi.invoke(std::move(std::as_const(cl2))) == 8); + CHECK(mi.invoke(cl2).get_as() == 8); + CHECK(mi.invoke(std::as_const(cl2)).get_as() == 8); + CHECK(mi.invoke(std::move(cl2)).get_as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl2))).get_as() == 8); - CHECK(mi.invoke(cl2v) == 8); - CHECK(mi.invoke(std::as_const(cl2v)) == 8); - CHECK(mi.invoke(std::move(cl2v)) == 8); - CHECK(mi.invoke(std::move(std::as_const(cl2v))) == 8); + CHECK(mi.invoke(cl2v).get_as() == 8); + CHECK(mi.invoke(std::as_const(cl2v)).get_as() == 8); + CHECK(mi.invoke(std::move(cl2v)).get_as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).get_as() == 8); } static_assert(std::is_invocable_v); @@ -808,12 +808,12 @@ TEST_CASE("meta/meta_states/method") { CHECK_THROWS(mi.invoke(cl)); CHECK_THROWS(mi.invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)) == 9); + CHECK(mi.invoke(std::move(cl)).get_as() == 9); CHECK_THROWS(mi.invoke(std::move(std::as_const(cl)))); CHECK_THROWS(mi.invoke(clv)); CHECK_THROWS(mi.invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)) == 9); + CHECK(mi.invoke(std::move(clv)).get_as() == 9); CHECK_THROWS(mi.invoke(std::move(std::as_const(clv)))); } @@ -889,12 +889,12 @@ TEST_CASE("meta/meta_states/method") { CHECK_THROWS(mi.invoke(cl)); CHECK_THROWS(mi.invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)) == 10); + CHECK(mi.invoke(std::move(cl)).get_as() == 10); CHECK_THROWS(mi.invoke(std::move(std::as_const(cl)))); CHECK_THROWS(mi.invoke(clv)); CHECK_THROWS(mi.invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)) == 10); + CHECK(mi.invoke(std::move(clv)).get_as() == 10); CHECK_THROWS(mi.invoke(std::move(std::as_const(clv)))); } @@ -970,13 +970,13 @@ TEST_CASE("meta/meta_states/method") { CHECK_THROWS(mi.invoke(cl)); CHECK_THROWS(mi.invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)) == 11); - CHECK(mi.invoke(std::move(std::as_const(cl))) == 11); + CHECK(mi.invoke(std::move(cl)).get_as() == 11); + CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 11); CHECK_THROWS(mi.invoke(clv)); CHECK_THROWS(mi.invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)) == 11); - CHECK(mi.invoke(std::move(std::as_const(clv))) == 11); + CHECK(mi.invoke(std::move(clv)).get_as() == 11); + CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 11); } { @@ -1051,13 +1051,13 @@ TEST_CASE("meta/meta_states/method") { CHECK_THROWS(mi.invoke(cl)); CHECK_THROWS(mi.invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)) == 12); - CHECK(mi.invoke(std::move(std::as_const(cl))) == 12); + CHECK(mi.invoke(std::move(cl)).get_as() == 12); + CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 12); CHECK_THROWS(mi.invoke(clv)); CHECK_THROWS(mi.invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)) == 12); - CHECK(mi.invoke(std::move(std::as_const(clv))) == 12); + CHECK(mi.invoke(std::move(clv)).get_as() == 12); + CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 12); } { @@ -1117,25 +1117,25 @@ TEST_CASE("meta/meta_states/method") { { clazz cl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(cl) == -1); + CHECK(mi.invoke(cl).get_as() == -1); } { clazz cl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(&cl) == -1); + CHECK(mi.invoke(&cl).get_as() == -1); } { derived_clazz dcl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(dcl) == -2); + CHECK(mi.invoke(dcl).get_as() == -2); } { derived_clazz dcl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(&dcl) == -2); + CHECK(mi.invoke(&dcl).get_as() == -2); } } } diff --git a/develop/untests/meta_states/variable_tests.cpp b/develop/untests/meta_states/variable_tests.cpp index 25a3e3d..8f249b7 100644 --- a/develop/untests/meta_states/variable_tests.cpp +++ b/develop/untests/meta_states/variable_tests.cpp @@ -71,8 +71,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK(vm.get_type() == meta::resolve_type(&clazz_1::int_variable)); CHECK(vm.get_name() == "int_variable"); - CHECK(vm.get() == 1); - CHECK(vm() == 1); + CHECK(vm.get().get_as() == 1); + CHECK(vm().get_as() == 1); CHECK(vm.is_settable_with()); CHECK(vm.is_settable_with()); @@ -84,8 +84,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with(1.0)); - vm.set(10); CHECK(vm.get() == 10); - vm(11); CHECK(vm() == 11); + vm.set(10); CHECK(vm.get().get_as() == 10); + vm(11); CHECK(vm().get_as() == 11); } SUBCASE("const int") { @@ -95,8 +95,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK(vm.get_type() == meta::resolve_type(&clazz_1::const_int_variable)); CHECK(vm.get_name() == "const_int_variable"); - CHECK(vm.get() == 2); - CHECK(vm() == 2); + CHECK(vm.get().get_as() == 2); + CHECK(vm().get_as() == 2); CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with()); @@ -108,8 +108,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with(1.0)); - CHECK_THROWS(vm.set(10)); CHECK(vm.get() == 2); - CHECK_THROWS(vm(10)); CHECK(vm() == 2); + CHECK_THROWS(vm.set(10)); CHECK(vm.get().get_as() == 2); + CHECK_THROWS(vm(10)); CHECK(vm().get_as() == 2); } SUBCASE("ref int") { @@ -119,8 +119,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK(vm.get_type() == meta::resolve_type(&clazz_1::ref_int_variable)); CHECK(vm.get_name() == "ref_int_variable"); - CHECK(vm.get() == 11); - CHECK(vm() == 11); + CHECK(vm.get().get_as() == 11); + CHECK(vm().get_as() == 11); CHECK(vm.is_settable_with()); CHECK(vm.is_settable_with()); @@ -132,8 +132,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with(1.0)); - vm.set(20); CHECK(vm.get() == 20); - vm(21); CHECK(vm() == 21); + vm.set(20); CHECK(vm.get().get_as() == 20); + vm(21); CHECK(vm().get_as() == 21); } SUBCASE("const ref int") { @@ -143,8 +143,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK(vm.get_type() == meta::resolve_type(&clazz_1::const_ref_int_variable)); CHECK(vm.get_name() == "const_ref_int_variable"); - CHECK(vm.get() == 2); - CHECK(vm() == 2); + CHECK(vm.get().get_as() == 2); + CHECK(vm().get_as() == 2); CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with()); @@ -156,8 +156,8 @@ TEST_CASE("meta/meta_states/variable") { CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with(1.0)); - CHECK_THROWS(vm.set(10)); CHECK(vm.get() == 2); - CHECK_THROWS(vm(11)); CHECK(vm() == 2); + CHECK_THROWS(vm.set(10)); CHECK(vm.get().get_as() == 2); + CHECK_THROWS(vm(11)); CHECK(vm().get_as() == 2); } SUBCASE("unique_int_variable_as_ptr") { @@ -165,7 +165,7 @@ TEST_CASE("meta/meta_states/variable") { REQUIRE(vm); CHECK(vm.get().get_type() == meta::resolve_type*>()); - CHECK(vm.get() == std::addressof(clazz_1::unique_int_variable)); + CHECK(vm.get().get_as*>() == std::addressof(clazz_1::unique_int_variable)); { auto nv = std::make_unique(11); @@ -206,7 +206,7 @@ TEST_CASE("meta/meta_states/variable") { REQUIRE(vm); CHECK(vm.get().get_type() == meta::resolve_type*>()); - CHECK(vm.get() == std::addressof(clazz_1::const_unique_int_variable)); + CHECK(vm.get().get_as*>() == std::addressof(clazz_1::const_unique_int_variable)); { auto nv = std::make_unique(11); diff --git a/develop/untests/meta_types/enum_type_tests.cpp b/develop/untests/meta_types/enum_type_tests.cpp index c43567d..243093d 100644 --- a/develop/untests/meta_types/enum_type_tests.cpp +++ b/develop/untests/meta_types/enum_type_tests.cpp @@ -89,8 +89,8 @@ TEST_CASE("meta/meta_types/enum_type") { { const meta::evalue green_value = color_type.get_evalue("green"); REQUIRE(green_value); - CHECK(green_value.get_value() == color::green); - CHECK(green_value.get_underlying_value() == meta::detail::to_underlying(color::green)); + CHECK(green_value.get_value().get_as() == color::green); + CHECK(green_value.get_underlying_value().get_as() == meta::detail::to_underlying(color::green)); } { @@ -106,8 +106,8 @@ TEST_CASE("meta/meta_types/enum_type") { { const meta::evalue green_value = ecolor_type.get_evalue("green"); REQUIRE(green_value); - CHECK(green_value.get_value() == ecolor_green); - CHECK(green_value.get_underlying_value() == meta::detail::to_underlying(ecolor_green)); + CHECK(green_value.get_value().get_as() == ecolor_green); + CHECK(green_value.get_underlying_value().get_as() == meta::detail::to_underlying(ecolor_green)); } { @@ -140,7 +140,7 @@ TEST_CASE("meta/meta_types/enum_type") { { REQUIRE(color_type.name_to_value("blue")); - CHECK(color_type.name_to_value("blue") == color::blue); + CHECK(color_type.name_to_value("blue").get_as() == color::blue); } { @@ -154,7 +154,7 @@ TEST_CASE("meta/meta_types/enum_type") { { REQUIRE(ecolor_type.name_to_value("blue")); - CHECK(ecolor_type.name_to_value("blue") == ecolor_blue); + CHECK(ecolor_type.name_to_value("blue").get_as() == ecolor_blue); } { diff --git a/develop/untests/meta_utilities/arg6_tests.cpp b/develop/untests/meta_utilities/arg6_tests.cpp index af5b9ad..947ce73 100644 --- a/develop/untests/meta_utilities/arg6_tests.cpp +++ b/develop/untests/meta_utilities/arg6_tests.cpp @@ -48,10 +48,10 @@ TEST_CASE("meta/meta_utilities/arg6") { CHECK(f.is_invocable_with()); CHECK(f.is_invocable_with(cl, &clazz::int_member)); - CHECK(f.invoke(cl, &clazz::int_member) == 42); + CHECK(f.invoke(cl, &clazz::int_member).get_as() == 42); CHECK(f.is_invocable_with(meta::uvalue{cl}, meta::uvalue{&clazz::int_member})); - CHECK(f.invoke(meta::uvalue{cl}, meta::uvalue{&clazz::int_member}) == 42); + CHECK(f.invoke(meta::uvalue{cl}, meta::uvalue{&clazz::int_member}).get_as() == 42); } SUBCASE("int_method") { @@ -62,9 +62,9 @@ TEST_CASE("meta/meta_utilities/arg6") { CHECK(f.is_invocable_with()); CHECK(f.is_invocable_with(cl, &clazz::int_method)); - CHECK(f.invoke(cl, &clazz::int_method) == 42); + CHECK(f.invoke(cl, &clazz::int_method).get_as() == 42); CHECK(f.is_invocable_with(meta::uvalue{cl}, meta::uvalue{&clazz::int_method})); - CHECK(f.invoke(meta::uvalue{cl}, meta::uvalue{&clazz::int_method}) == 42); + CHECK(f.invoke(meta::uvalue{cl}, meta::uvalue{&clazz::int_method}).get_as() == 42); } } diff --git a/develop/untests/meta_utilities/arg_tests.cpp b/develop/untests/meta_utilities/arg_tests.cpp index d681479..c9c3c8c 100644 --- a/develop/untests/meta_utilities/arg_tests.cpp +++ b/develop/untests/meta_utilities/arg_tests.cpp @@ -78,7 +78,7 @@ namespace std::ignore = uarg{FromValue}.cast();\ \ CHECK(f_state.is_invocable_with());\ - CHECK(f_state.invoke(FromValue) == 1);\ + CHECK(f_state.invoke(FromValue).get_as() == 1);\ } else {\ CHECK_FALSE(uarg{FromValue}.can_cast_to());\ CHECK_FALSE(uarg_base{type_list{}}.can_cast_to());\ @@ -99,7 +99,7 @@ namespace if ( std::is_invocable_v ) {\ CHECK(f_state.is_invocable_with());\ CHECK(f_state.is_invocable_with(FromValue));\ - CHECK(f_state.invoke(FromValue) == 1);\ + CHECK(f_state.invoke(FromValue).get_as() == 1);\ } else {\ CHECK_FALSE(f_state.is_invocable_with());\ CHECK_FALSE(f_state.is_invocable_with(FromValue));\ diff --git a/develop/untests/meta_utilities/inst_tests.cpp b/develop/untests/meta_utilities/inst_tests.cpp index d05b361..6f79f56 100644 --- a/develop/untests/meta_utilities/inst_tests.cpp +++ b/develop/untests/meta_utilities/inst_tests.cpp @@ -38,7 +38,7 @@ namespace std::ignore = uinst{Inst}.cast();\ \ CHECK(m_state.is_invocable_with());\ - CHECK(m_state.invoke(Inst) == 1);\ + CHECK(m_state.invoke(Inst).get_as() == 1);\ } else {\ CHECK_FALSE(uinst{Inst}.can_cast_to());\ CHECK_FALSE(uinst_base{type_list{}}.can_cast_to());\ @@ -59,7 +59,7 @@ namespace if ( std::is_invocable_v ) {\ CHECK(m_state.is_invocable_with());\ CHECK(m_state.is_invocable_with(FromValue));\ - CHECK(m_state.invoke(FromValue) == 1);\ + CHECK(m_state.invoke(FromValue).get_as() == 1);\ } else {\ CHECK_FALSE(m_state.is_invocable_with());\ CHECK_FALSE(m_state.is_invocable_with(FromValue));\ diff --git a/develop/untests/meta_utilities/invoke_tests.cpp b/develop/untests/meta_utilities/invoke_tests.cpp index 3a1c27f..8405b4c 100644 --- a/develop/untests/meta_utilities/invoke_tests.cpp +++ b/develop/untests/meta_utilities/invoke_tests.cpp @@ -32,28 +32,28 @@ TEST_CASE("meta/meta_utilities/invoke") { REQUIRE((clazz_member && clazz_method && clazz_function)); { - CHECK(meta::invoke(&clazz::function, 3) == 3); - CHECK(meta::invoke(&clazz::function, meta::uvalue(3)) == 3); - CHECK(meta::invoke(clazz_function, 3) == 3); - CHECK(meta::invoke(clazz_function, meta::uvalue(3)) == 3); + CHECK(meta::invoke(&clazz::function, 3).get_as() == 3); + CHECK(meta::invoke(&clazz::function, meta::uvalue{3}).get_as() == 3); + CHECK(meta::invoke(clazz_function, 3).get_as() == 3); + CHECK(meta::invoke(clazz_function, meta::uvalue{3}).get_as() == 3); CHECK(meta::is_invocable_with(clazz_function, 3)); - CHECK(meta::is_invocable_with(clazz_function, meta::uvalue(3))); + CHECK(meta::is_invocable_with(clazz_function, meta::uvalue{3})); CHECK(meta::is_invocable_with(clazz_function)); using function_t = decltype(&clazz::function); CHECK(meta::is_invocable_with(3)); - CHECK(meta::is_invocable_with(meta::uvalue(3))); + CHECK(meta::is_invocable_with(meta::uvalue{3})); CHECK(meta::is_invocable_with()); } { clazz cl; - CHECK(meta::invoke(&clazz::member, cl) == 1); - CHECK(meta::invoke(&clazz::member, meta::uvalue{cl}) == 1); - CHECK(meta::invoke(clazz_member, cl) == 1); - CHECK(meta::invoke(clazz_member, meta::uvalue{cl}) == 1); + CHECK(meta::invoke(&clazz::member, cl).get_as() == 1); + CHECK(meta::invoke(&clazz::member, meta::uvalue{cl}).get_as() == 1); + CHECK(meta::invoke(clazz_member, cl).get_as() == 1); + CHECK(meta::invoke(clazz_member, meta::uvalue{cl}).get_as() == 1); CHECK(meta::is_invocable_with(clazz_member, cl)); CHECK(meta::is_invocable_with(clazz_member, meta::uvalue{cl})); @@ -68,18 +68,18 @@ TEST_CASE("meta/meta_utilities/invoke") { { clazz cl; - CHECK(meta::invoke(&clazz::method, cl, 2) == 2); - CHECK(meta::invoke(&clazz::method, meta::uvalue{cl}, meta::uvalue(2)) == 2); - CHECK(meta::invoke(clazz_method, cl, 2) == 2); - CHECK(meta::invoke(clazz_method, meta::uvalue{cl}, meta::uvalue(2)) == 2); + CHECK(meta::invoke(&clazz::method, cl, 2).get_as() == 2); + CHECK(meta::invoke(&clazz::method, meta::uvalue{cl}, meta::uvalue{2}).get_as() == 2); + CHECK(meta::invoke(clazz_method, cl, 2).get_as() == 2); + CHECK(meta::invoke(clazz_method, meta::uvalue{cl}, meta::uvalue{2}).get_as() == 2); CHECK(meta::is_invocable_with(clazz_method, cl, 2)); - CHECK(meta::is_invocable_with(clazz_method, meta::uvalue{cl}, meta::uvalue(2))); + CHECK(meta::is_invocable_with(clazz_method, meta::uvalue{cl}, meta::uvalue{2})); CHECK(meta::is_invocable_with(clazz_method)); using method_t = decltype(&clazz::method); CHECK(meta::is_invocable_with(cl, 2)); - CHECK(meta::is_invocable_with(meta::uvalue{cl}, meta::uvalue(2))); + CHECK(meta::is_invocable_with(meta::uvalue{cl}, meta::uvalue{2})); CHECK(meta::is_invocable_with()); } } diff --git a/develop/untests/meta_utilities/value_tests.cpp b/develop/untests/meta_utilities/value_tests.cpp index b6af9ff..ffef9c8 100644 --- a/develop/untests/meta_utilities/value_tests.cpp +++ b/develop/untests/meta_utilities/value_tests.cpp @@ -144,23 +144,6 @@ TEST_CASE("meta/meta_utilities/value") { CHECK_THROWS(std::ignore = std::move(std::as_const(val)).get_as()); } - { - CHECK_FALSE(1 < meta::uvalue{}); - CHECK(meta::uvalue{} < 1); - } - - { - CHECK_FALSE(1 == meta::uvalue{}); - CHECK_FALSE(meta::uvalue{} == 1); - } - - { - CHECK(1 != meta::uvalue{}); - CHECK(meta::uvalue{} != 1); - } - - CHECK_FALSE(meta::uvalue{} == 0); - CHECK_FALSE(meta::uvalue{} == nullptr); CHECK(meta::uvalue{}.get_type() == meta::resolve_type()); } @@ -179,7 +162,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(*static_cast(std::as_const(val).data()) == vr); CHECK(*static_cast(std::as_const(val).cdata()) == vr); - CHECK(val == ivec2{1,2}); + CHECK(val.get_as() == ivec2{1,2}); CHECK(val.get_as() == ivec2{1,2}); CHECK(std::as_const(val).get_as() == ivec2{1,2}); @@ -212,7 +195,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(*static_cast(std::as_const(val).data()) == vr); CHECK(*static_cast(std::as_const(val).cdata()) == vr); - CHECK(val == ivec2{1,2}); + CHECK(val.get_as() == ivec2{1,2}); CHECK(val.get_as() == ivec2{1,2}); CHECK(std::as_const(val).get_as() == ivec2{1,2}); @@ -239,7 +222,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(val.get_type() == meta::resolve_type()); - CHECK(val == ivec2{1,2}); + CHECK(val.get_as() == ivec2{1,2}); CHECK(val.get_as() == ivec2{1,2}); CHECK(std::as_const(val).get_as() == ivec2{1,2}); @@ -266,7 +249,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(val.get_type() == meta::resolve_type()); - CHECK(val == ivec2{1,2}); + CHECK(val.get_as() == ivec2{1,2}); CHECK(val.get_as() == ivec2{1,2}); CHECK(std::as_const(val).get_as() == ivec2{1,2}); @@ -291,7 +274,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(ivec2::copy_constructor_counter == 0); meta::uvalue val_dst{std::move(val_src)}; - CHECK(val_dst == ivec2{1,2}); + CHECK(val_dst.get_as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 2); CHECK(ivec2::copy_constructor_counter == 0); } @@ -303,11 +286,11 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(ivec2::copy_constructor_counter == 1); meta::uvalue val_dst{val_src}; - CHECK(val_dst == ivec2{1,2}); + CHECK(val_dst.get_as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 0); CHECK(ivec2::copy_constructor_counter == 2); - CHECK(val_src == ivec2{1,2}); + CHECK(val_src.get_as() == ivec2{1,2}); CHECK(val_src.data() != val_dst.data()); } @@ -315,10 +298,10 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val{10}; val = 20; - CHECK(val == 20); + CHECK(val.get_as() == 20); val = "hello"s; - CHECK(val == "hello"s); + CHECK(val.get_as() == "hello"s); } SUBCASE("value& operator=(value&&)") { @@ -330,12 +313,12 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val_dst{"hello"s}; val_dst = std::move(val_src1); - CHECK(val_dst == "world"s); + CHECK(val_dst.get_as() == "world"s); CHECK(ivec2::move_constructor_counter == 1); CHECK(ivec2::copy_constructor_counter == 0); val_dst = std::move(val_src2); - CHECK(val_dst == ivec2{1,2}); + CHECK(val_dst.get_as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 3); CHECK(ivec2::copy_constructor_counter == 0); } @@ -349,16 +332,16 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val_dst{"hello"s}; val_dst = val_src1; - CHECK(val_dst == "world"s); + CHECK(val_dst.get_as() == "world"s); CHECK(ivec2::move_constructor_counter == 1); CHECK(ivec2::copy_constructor_counter == 0); val_dst = val_src2; - CHECK(val_dst == ivec2{1,2}); + CHECK(val_dst.get_as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 2); CHECK(ivec2::copy_constructor_counter == 1); - CHECK(val_src2 == ivec2{1,2}); + CHECK(val_src2.get_as() == ivec2{1,2}); CHECK(val_src2.data() != val_dst.data()); } @@ -369,50 +352,14 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(ivec2::copy_constructor_counter == 0); val1.swap(val2); - CHECK(val1 == ivec2{1,2}); - CHECK(val2 == "world"s); + CHECK(val1.get_as() == ivec2{1,2}); + CHECK(val2.get_as() == "world"s); CHECK(ivec2::move_constructor_counter == 2); CHECK(ivec2::copy_constructor_counter == 0); swap(val1, val2); - CHECK(val1 == "world"s); - CHECK(val2 == ivec2{1,2}); - } - - SUBCASE("ostream") { - std::stringstream str_stream; - str_stream << meta::uvalue{21} << " " << meta::uvalue{42}; - CHECK_THROWS((str_stream << meta::uvalue{ivec2{1,2}})); - REQUIRE(str_stream.str() == "21 42"); - } - - SUBCASE("istream") { - std::stringstream str_stream{"21 42"}; - - meta::uvalue v{ivec2{1,2}}; - CHECK_THROWS(str_stream >> v); - - v = meta::uvalue{0}; - str_stream >> v; - CHECK(v == 21); - str_stream >> v; - CHECK(v == 42); - } - - SUBCASE("operator<") { - CHECK(meta::uvalue{ivec2{1,2}} < ivec2{1,3}); - CHECK_FALSE(meta::uvalue{ivec2{1,3}} < ivec2{1,2}); - - CHECK(ivec2{1,2} < meta::uvalue{ivec2{1,3}}); - CHECK_FALSE(ivec2{1,3} < meta::uvalue{ivec2{1,2}}); - } - - SUBCASE("operator==") { - CHECK(meta::uvalue{ivec2{1,2}} == ivec2{1,2}); - CHECK_FALSE(meta::uvalue{ivec2{1,2}} == ivec2{1,3}); - - CHECK(ivec2{1,2} == meta::uvalue{ivec2{1,2}}); - CHECK_FALSE(ivec2{1,3} == meta::uvalue{ivec2{1,2}}); + CHECK(val1.get_as() == "world"s); + CHECK(val2.get_as() == ivec2{1,2}); } SUBCASE("deref") { @@ -468,7 +415,7 @@ TEST_CASE("meta/meta_utilities/value") { } { meta::uvalue v{std::make_shared(42)}; - CHECK(*v == 42); + CHECK((*v).get_as() == 42); } } } @@ -480,51 +427,51 @@ TEST_CASE("meta/meta_utilities/value/arrays") { int arr[3]{1,2,3}; meta::uvalue v{arr}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v[0] == 1); - CHECK(v[1] == 2); - CHECK(v[2] == 3); + CHECK(v[0].get_as() == 1); + CHECK(v[1].get_as() == 2); + CHECK(v[2].get_as() == 3); } SUBCASE("const int[3]") { const int arr[3]{1,2,3}; meta::uvalue v{arr}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v[0] == 1); - CHECK(v[1] == 2); - CHECK(v[2] == 3); + CHECK(v[0].get_as() == 1); + CHECK(v[1].get_as() == 2); + CHECK(v[2].get_as() == 3); } SUBCASE("std::array") { meta::uvalue v{std::array{1,2,3}}; CHECK(v.get_type() == meta::resolve_type>()); - CHECK(v[0] == 1); - CHECK(v[1] == 2); - CHECK(v[2] == 3); + CHECK(v[0].get_as() == 1); + CHECK(v[1].get_as() == 2); + CHECK(v[2].get_as() == 3); } SUBCASE("std::string") { meta::uvalue v{std::string{"hi!"}}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v[0] == 'h'); - CHECK(v[1] == 'i'); - CHECK(v[2] == '!'); + CHECK(v[0].get_as() == 'h'); + CHECK(v[1].get_as() == 'i'); + CHECK(v[2].get_as() == '!'); } SUBCASE("std::span") { std::vector arr{1,2,3}; meta::uvalue v{std::span{arr}}; CHECK(v.get_type() == meta::resolve_type>()); - CHECK(v[0] == 1); - CHECK(v[1] == 2); - CHECK(v[2] == 3); + CHECK(v[0].get_as() == 1); + CHECK(v[1].get_as() == 2); + CHECK(v[2].get_as() == 3); } SUBCASE("std::vector") { const meta::uvalue v{std::vector{1,2,3}}; CHECK(v.get_type() == meta::resolve_type>()); - CHECK(v[0] == 1); - CHECK(v[1] == 2); - CHECK(v[2] == 3); + CHECK(v[0].get_as() == 1); + CHECK(v[1].get_as() == 2); + CHECK(v[2].get_as() == 3); } } diff --git a/headers/meta.hpp/meta_detail/value_traits/istream_traits.hpp b/headers/meta.hpp/meta_detail/value_traits/istream_traits.hpp deleted file mode 100644 index 554662e..0000000 --- a/headers/meta.hpp/meta_detail/value_traits/istream_traits.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * This file is part of the "https://github.com/blackmatov/meta.hpp" - * For conditions of distribution and use, see copyright notice in LICENSE.md - * Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com) - ******************************************************************************/ - -#pragma once - -#include "../../meta_base.hpp" -#include "../../meta_uvalue.hpp" - -namespace meta_hpp::detail -{ - template < typename T > - struct istream_traits; - - template < typename T > - concept has_istream_traits = requires(std::istream& is, T& v) { - { istream_traits{}(is, v) } -> std::convertible_to; - }; -} - -namespace meta_hpp::detail -{ - template < typename T > - requires requires(std::istream& is, T& v) { - { is >> v } -> std::convertible_to; - } - struct istream_traits { - std::istream& operator()(std::istream& is, T& v) const { - return is >> v; - } - }; -} diff --git a/headers/meta.hpp/meta_detail/value_traits/ostream_traits.hpp b/headers/meta.hpp/meta_detail/value_traits/ostream_traits.hpp deleted file mode 100644 index b0cacd1..0000000 --- a/headers/meta.hpp/meta_detail/value_traits/ostream_traits.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * This file is part of the "https://github.com/blackmatov/meta.hpp" - * For conditions of distribution and use, see copyright notice in LICENSE.md - * Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com) - ******************************************************************************/ - -#pragma once - -#include "../../meta_base.hpp" -#include "../../meta_uvalue.hpp" - -namespace meta_hpp::detail -{ - template < typename T > - struct ostream_traits; - - template < typename T > - concept has_ostream_traits = requires(std::ostream& os, const T& v) { - { ostream_traits{}(os, v) } -> std::convertible_to; - }; -} - -namespace meta_hpp::detail -{ - template < typename T > - requires requires(std::ostream& os, const T& v) { - { os << v } -> std::convertible_to; - } - struct ostream_traits { - std::ostream& operator()(std::ostream& os, const T& v) const { - return os << v; - } - }; -} diff --git a/headers/meta.hpp/meta_types/enum_type.hpp b/headers/meta.hpp/meta_types/enum_type.hpp index 094c33d..42ff81b 100644 --- a/headers/meta.hpp/meta_types/enum_type.hpp +++ b/headers/meta.hpp/meta_types/enum_type.hpp @@ -76,7 +76,7 @@ namespace meta_hpp } for ( auto&& [_, evalue] : data_->evalues ) { - if ( evalue.get_value() == value ) { + if ( evalue.get_value().get_as() == value ) { return evalue.get_index().get_name(); } } diff --git a/headers/meta.hpp/meta_uvalue.hpp b/headers/meta.hpp/meta_uvalue.hpp index 985e703..fc199f3 100644 --- a/headers/meta.hpp/meta_uvalue.hpp +++ b/headers/meta.hpp/meta_uvalue.hpp @@ -42,7 +42,7 @@ namespace meta_hpp && (!detail::is_in_place_type_v) && (std::is_copy_constructible_v) // NOLINTNEXTLINE(*-forwarding-reference-overload) - explicit uvalue(T&& val); + uvalue(T&& val); template < typename T, typename Tp = std::decay_t > requires (!detail::any_uvalue_kind) @@ -100,9 +100,6 @@ namespace meta_hpp template < typename T > [[nodiscard]] auto try_get_as() const noexcept -> std::conditional_t, T, const T*>; - - friend std::istream& operator>>(std::istream& is, uvalue& v); - friend std::ostream& operator<<(std::ostream& os, const uvalue& v); private: struct vtable_t; vtable_t* vtable_{}; diff --git a/headers/meta.hpp/meta_uvalue/uvalue.hpp b/headers/meta.hpp/meta_uvalue/uvalue.hpp index edbc36c..9b283a1 100644 --- a/headers/meta.hpp/meta_uvalue/uvalue.hpp +++ b/headers/meta.hpp/meta_uvalue/uvalue.hpp @@ -12,8 +12,6 @@ #include "../meta_detail/value_traits/deref_traits.hpp" #include "../meta_detail/value_traits/index_traits.hpp" -#include "../meta_detail/value_traits/istream_traits.hpp" -#include "../meta_detail/value_traits/ostream_traits.hpp" #include "../meta_detail/value_utilities/utraits.hpp" @@ -32,9 +30,6 @@ namespace meta_hpp uvalue (*const deref)(const storage_u& from); uvalue (*const index)(const storage_u& from, std::size_t); - std::istream& (*const istream)(std::istream& is, storage_u& to); - std::ostream& (*const ostream)(std::ostream& os, const storage_u& from); - template < typename T > static T* buffer_cast(buffer_t& buffer) noexcept { // NOLINTNEXTLINE(*-reinterpret-cast) @@ -200,22 +195,6 @@ namespace meta_hpp detail::throw_exception_with("value type doesn't have value index traits"); } }, - - .istream = +[]([[maybe_unused]] std::istream& is, [[maybe_unused]] storage_u& to) -> std::istream& { - if constexpr ( detail::has_istream_traits && !detail::pointer_kind ) { - return detail::istream_traits{}(is, *storage_cast(to)); - } else { - detail::throw_exception_with("value type doesn't have value istream traits"); - } - }, - - .ostream = +[]([[maybe_unused]] std::ostream& os, [[maybe_unused]] const storage_u& from) -> std::ostream& { - if constexpr ( detail::has_ostream_traits && !detail::pointer_kind ) { - return detail::ostream_traits{}(os, *storage_cast(from)); - } else { - detail::throw_exception_with("value type doesn't have value ostream traits"); - } - }, }; return &table; @@ -510,74 +489,3 @@ namespace meta_hpp return nullptr; } } - -namespace meta_hpp -{ - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator<(const uvalue& l, const T& r) { - if ( !static_cast(l) ) { - return true; - } - - const any_type& l_type = l.get_type(); - const any_type& r_type = resolve_type(); - - return (l_type < r_type) || (l_type == r_type && l.get_as() < r); - } - - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator<(const T& l, const uvalue& r) { - if ( !static_cast(r) ) { - return false; - } - - const any_type& l_type = resolve_type(); - const any_type& r_type = r.get_type(); - - return (l_type < r_type) || (l_type == r_type && l < r.get_as()); - } -} - -namespace meta_hpp -{ - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator==(const uvalue& l, const T& r) { - if ( !static_cast(l) ) { - return false; - } - - const any_type& l_type = l.get_type(); - const any_type& r_type = resolve_type(); - - return l_type == r_type && l.get_as() == r; - } - - template < typename T, typename Tp = std::decay_t > - requires (!detail::uvalue_kind) - [[nodiscard]] bool operator==(const T& l, const uvalue& r) { - if ( !static_cast(r) ) { - return false; - } - - const any_type& l_type = resolve_type(); - const any_type& r_type = r.get_type(); - - return l_type == r_type && l == r.get_as(); - } -} - -namespace meta_hpp -{ - inline std::istream& operator>>(std::istream& is, uvalue& v) { - assert(v && "bad operator call"); // NOLINT - return v.vtable_->istream(is, v.storage_); - } - - inline std::ostream& operator<<(std::ostream& os, const uvalue& v) { - assert(v && "bad operator call"); // NOLINT - return v.vtable_->ostream(os, v.storage_); - } -}