From e3b82ca382ffe7881dc2a773ecf7c6913a30ff9b Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sat, 18 Feb 2023 01:29:47 +0700 Subject: [PATCH] rename "uvalue::get_as" to "uvalue::as" --- develop/manuals/meta_manuals/class_manual.cpp | 2 +- develop/manuals/meta_manuals/enum_manual.cpp | 4 +- .../manuals/meta_manuals/function_manual.cpp | 2 +- .../manuals/meta_manuals/inplace_manual.cpp | 6 +- .../manuals/meta_manuals/member_manual.cpp | 2 +- .../manuals/meta_manuals/metadata_manual.cpp | 6 +- .../manuals/meta_manuals/method_manual.cpp | 2 +- .../manuals/meta_manuals/scopes_manual.cpp | 16 +- .../manuals/meta_manuals/uvalue_manual.cpp | 22 +- .../manuals/meta_manuals/variable_manual.cpp | 4 +- develop/singles/headers/meta.hpp/meta_all.hpp | 59 ++-- .../untests/meta_features/diamond_tests.cpp | 30 +- develop/untests/meta_states/ctor_tests.cpp | 32 +- develop/untests/meta_states/dtor_tests.cpp | 2 +- develop/untests/meta_states/evalue_tests.cpp | 4 +- .../untests/meta_states/function_tests.cpp | 56 ++-- develop/untests/meta_states/member_tests.cpp | 96 +++--- .../untests/meta_states/metadata_tests.cpp | 60 ++-- develop/untests/meta_states/method_tests.cpp | 312 +++++++++--------- .../untests/meta_states/variable_tests.cpp | 40 +-- .../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 | 24 +- .../untests/meta_utilities/result_tests.cpp | 40 +-- .../untests/meta_utilities/value2_tests.cpp | 36 +- .../untests/meta_utilities/value3_tests.cpp | 180 +++++----- .../untests/meta_utilities/value4_tests.cpp | 40 +-- .../untests/meta_utilities/value_tests.cpp | 258 +++++++-------- headers/meta.hpp/meta_base/exceptions.hpp | 6 - headers/meta.hpp/meta_states.hpp | 3 - headers/meta.hpp/meta_types/enum_type.hpp | 2 +- headers/meta.hpp/meta_uvalue.hpp | 12 +- headers/meta.hpp/meta_uvalue/uvalue.hpp | 36 +- 35 files changed, 702 insertions(+), 720 deletions(-) diff --git a/develop/manuals/meta_manuals/class_manual.cpp b/develop/manuals/meta_manuals/class_manual.cpp index fc335d7..ad440b1 100644 --- a/develop/manuals/meta_manuals/class_manual.cpp +++ b/develop/manuals/meta_manuals/class_manual.cpp @@ -87,5 +87,5 @@ TEST_CASE("meta/meta_manuals/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).get_as() == 200); + CHECK(rectangle_area.invoke(rectangle_v).as() == 200); } diff --git a/develop/manuals/meta_manuals/enum_manual.cpp b/develop/manuals/meta_manuals/enum_manual.cpp index e83fd4b..0bfcf9c 100644 --- a/develop/manuals/meta_manuals/enum_manual.cpp +++ b/develop/manuals/meta_manuals/enum_manual.cpp @@ -41,7 +41,7 @@ TEST_CASE("meta/meta_manuals/enum/type") { for ( const meta::evalue& evalue : align_type.get_evalues() ) { fmt::print(" - {}/{}\n", evalue.get_name(), - evalue.get_underlying_value().get_as()); + evalue.get_underlying_value().as()); } // Output: @@ -63,5 +63,5 @@ TEST_CASE("meta/meta_manuals/enum/usage") { CHECK(align_type.value_to_name(e) == "center"); // ... and back again - CHECK(align_type.name_to_value("center").get_as() == e); + CHECK(align_type.name_to_value("center").as() == e); } diff --git a/develop/manuals/meta_manuals/function_manual.cpp b/develop/manuals/meta_manuals/function_manual.cpp index 64d1f08..f669518 100644 --- a/develop/manuals/meta_manuals/function_manual.cpp +++ b/develop/manuals/meta_manuals/function_manual.cpp @@ -68,7 +68,7 @@ TEST_CASE("meta/meta_manuals/function/usage") { CHECK(sub_result_value.get_type() == meta::resolve_type()); // casts the dynamic returned value to the typed value - const int sub_function_typed_result = sub_result_value.get_as(); + const int sub_function_typed_result = sub_result_value.as(); // here is our typed result CHECK(sub_function_typed_result == 42); diff --git a/develop/manuals/meta_manuals/inplace_manual.cpp b/develop/manuals/meta_manuals/inplace_manual.cpp index 427de8c..e311406 100644 --- a/develop/manuals/meta_manuals/inplace_manual.cpp +++ b/develop/manuals/meta_manuals/inplace_manual.cpp @@ -60,9 +60,9 @@ TEST_CASE("meta/meta_manuals/inplace") { CHECK(ivec2_ptr.get_type() == meta::resolve_type()); // interacts with the created object as usual - 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); + CHECK(ivec2_x.get(ivec2_ptr).as() == 2); + CHECK(ivec2_y.get(ivec2_ptr).as() == 3); + CHECK(ivec2_length2(ivec2_ptr).as() == 13); // you must manually call the object's destructor CHECK(ivec2_type.destroy_at(ivec2_buffer.get_data())); diff --git a/develop/manuals/meta_manuals/member_manual.cpp b/develop/manuals/meta_manuals/member_manual.cpp index 0d61fa9..b77fa7a 100644 --- a/develop/manuals/meta_manuals/member_manual.cpp +++ b/develop/manuals/meta_manuals/member_manual.cpp @@ -59,7 +59,7 @@ TEST_CASE("meta/meta_manuals/member/usage") { CHECK(ivec2_x_value.get_type() == meta::resolve_type()); // casts the dynamic value to the typed value - const int ivec2_x_typed_value = ivec2_x_value.get_as(); + const int ivec2_x_typed_value = ivec2_x_value.as(); // here is our member typed value CHECK(ivec2_x_typed_value == 42); diff --git a/develop/manuals/meta_manuals/metadata_manual.cpp b/develop/manuals/meta_manuals/metadata_manual.cpp index 120eb11..0d2bfc4 100644 --- a/develop/manuals/meta_manuals/metadata_manual.cpp +++ b/develop/manuals/meta_manuals/metadata_manual.cpp @@ -71,14 +71,14 @@ TEST_CASE("meta/meta_manuals/metadata") { fmt::print("{} ({})\n", type_name, - class_metadata.at("tooltip").get_as()); + class_metadata.at("tooltip").as()); for ( const meta::member& member : class_type.get_members() ) { const meta::metadata_map& member_metadata = member.get_metadata(); fmt::print(" - {} ({})\n", member.get_name(), - member_metadata.at("tooltip").get_as()); + member_metadata.at("tooltip").as()); } } @@ -88,7 +88,7 @@ TEST_CASE("meta/meta_manuals/metadata") { fmt::print(" + {}/{} ({})\n", function.get_name(), function.get_type().get_arity(), - function_metadata.at("tooltip").get_as()); + function_metadata.at("tooltip").as()); for ( const meta::argument& argument : function.get_arguments() ) { fmt::print(" ({}) : {}\n", diff --git a/develop/manuals/meta_manuals/method_manual.cpp b/develop/manuals/meta_manuals/method_manual.cpp index 7c32250..1398b24 100644 --- a/develop/manuals/meta_manuals/method_manual.cpp +++ b/develop/manuals/meta_manuals/method_manual.cpp @@ -76,7 +76,7 @@ TEST_CASE("meta/meta_manuals/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.get_as() == ivec2{42, 21}); + CHECK(ivec2_add_result_value.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 7bc627f..c1453f9 100644 --- a/develop/manuals/meta_manuals/scopes_manual.cpp +++ b/develop/manuals/meta_manuals/scopes_manual.cpp @@ -71,18 +71,18 @@ TEST_CASE("meta/meta_manuals/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}).get_as() == 39); - CHECK(dot3_function(ivec3{3,4,5}, ivec3{6,7,8}).get_as() == 86); + CHECK(dot2_function(ivec2{3,4}, ivec2{5,6}).as() == 39); + CHECK(dot3_function(ivec3{3,4,5}, ivec3{6,7,8}).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().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); + CHECK(unit2_variable.get().as() == ivec2{1,1}); + CHECK(unit3_variable.get().as() == ivec3{1,1,1}); + CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()).as() == 2); + CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).as() == 3); } TEST_CASE("meta/meta_manuals/scopes/global") { @@ -105,6 +105,6 @@ TEST_CASE("meta/meta_manuals/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()).get_as() == 2); - CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).get_as() == 3); + CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()).as() == 2); + CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).as() == 3); } diff --git a/develop/manuals/meta_manuals/uvalue_manual.cpp b/develop/manuals/meta_manuals/uvalue_manual.cpp index 691bb7f..e3fb7cd 100644 --- a/develop/manuals/meta_manuals/uvalue_manual.cpp +++ b/develop/manuals/meta_manuals/uvalue_manual.cpp @@ -68,34 +68,34 @@ TEST_CASE("meta/meta_manuals/uvalue/usage") { CHECK(val.get_type() == meta::resolve_type()); // we can get a reference to the stored data and even change it - val.get_as() = 21; - CHECK(val.get_as() == 21); + val.as() = 21; + CHECK(val.as() == 21); // uvalue can be copied, assigned, and moved val = rectangle{10, 20}; CHECK(val.get_type() == meta::resolve_type()); // also, it supports upcasting for registered types - CHECK(val.get_as().get_area() == 200); + CHECK(val.as().get_area() == 200); // an exception will be thrown if we try to get a wrong type - CHECK_THROWS(std::ignore = val.get_as()); + CHECK_THROWS(std::ignore = val.as()); - // but we can use try_get_as for safe access - CHECK(val.try_get_as()); - if ( shape* s = val.try_get_as() ) { + // but we can use try_as for safe access + CHECK(val.try_as()); + if ( shape* s = val.try_as() ) { CHECK(s->get_area() == 200); } // also, upcasting is supported for pointers rectangle rect{3, 5}; val = ▭ - CHECK(val.get_as()->get_area() == 15); + CHECK(val.as()->get_area() == 15); CHECK(val.get_type() == meta::resolve_type()); - // and we can use try_get_as for pointers too - CHECK(val.try_get_as()); - if ( shape* s = val.try_get_as() ) { + // and we can use try_as for pointers too + CHECK(val.try_as()); + if ( shape* s = val.try_as() ) { CHECK(s->get_area() == 15); } } diff --git a/develop/manuals/meta_manuals/variable_manual.cpp b/develop/manuals/meta_manuals/variable_manual.cpp index 9dbcbbf..6c92204 100644 --- a/develop/manuals/meta_manuals/variable_manual.cpp +++ b/develop/manuals/meta_manuals/variable_manual.cpp @@ -37,7 +37,7 @@ TEST_CASE("meta/meta_manuals/variable/usage") { CHECK(pi_variable_value.get_type() == meta::resolve_type()); // checks the typed variable value - CHECK(pi_variable_value.get_as() == doctest::Approx(3.14).epsilon(0.01)); + CHECK(pi_variable_value.as() == doctest::Approx(3.14).epsilon(0.01)); // we can change variable values, but only non-const CHECK_FALSE(pi_variable.try_set(6.0)); @@ -47,7 +47,7 @@ TEST_CASE("meta/meta_manuals/variable/usage") { for ( const meta::variable& variable : constants_scope.get_variables() ) { fmt::print(" - {} : {}\n", variable.get_name(), - variable.get().get_as()); + variable.get().as()); } // Output: diff --git a/develop/singles/headers/meta.hpp/meta_all.hpp b/develop/singles/headers/meta.hpp/meta_all.hpp index 2b2c3ab..ba44d52 100644 --- a/develop/singles/headers/meta.hpp/meta_all.hpp +++ b/develop/singles/headers/meta.hpp/meta_all.hpp @@ -320,9 +320,7 @@ namespace meta_hpp::detail bad_const_access, bad_uvalue_access, - bad_uresult_access, - bad_uvalue_cast, bad_argument_cast, bad_instance_cast, @@ -339,10 +337,6 @@ namespace meta_hpp::detail return "bad const access"; case error_code::bad_uvalue_access: return "bad uvalue access"; - case error_code::bad_uresult_access: - return "bad uresult access"; - case error_code::bad_uvalue_cast: - return "bad uvalue cast"; case error_code::bad_argument_cast: return "bad argument cast"; case error_code::bad_instance_cast: @@ -2935,26 +2929,26 @@ namespace meta_hpp [[nodiscard]] bool has_unmap_op() const noexcept; template < typename T > - [[nodiscard]] T get_as() &&; + [[nodiscard]] T as() &&; template < typename T > - [[nodiscard]] auto get_as() & // + [[nodiscard]] auto as() & // -> std::conditional_t, T, T&>; template < typename T > - [[nodiscard]] auto get_as() const& // + [[nodiscard]] auto as() const& // -> std::conditional_t, T, const T&>; template < typename T > - [[nodiscard]] auto get_as() const&& // + [[nodiscard]] auto as() const&& // -> std::conditional_t, T, const T&&>; template < typename T > - [[nodiscard]] auto try_get_as() noexcept // + [[nodiscard]] auto try_as() noexcept // -> std::conditional_t, T, T*>; template < typename T > - [[nodiscard]] auto try_get_as() const noexcept // + [[nodiscard]] auto try_as() const noexcept // -> std::conditional_t, T, const T*>; private: @@ -3486,9 +3480,6 @@ namespace meta_hpp template < typename Instance > [[nodiscard]] uresult try_get(Instance&& instance) const; - template < typename T, typename Instance > - [[nodiscard]] T get_as(Instance&& instance) const; - template < typename Instance > [[nodiscard]] uvalue operator()(Instance&& instance) const; @@ -7477,7 +7468,7 @@ namespace meta_hpp } for ( const evalue& evalue : data_->evalues ) { - if ( evalue.get_value().get_as() == value ) { + if ( evalue.get_value().as() == value ) { return evalue.get_name(); } } @@ -8980,76 +8971,76 @@ namespace meta_hpp } template < typename T > - T uvalue::get_as() && { + T uvalue::as() && { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( T* ptr = try_get_as() ) { + if ( T* ptr = try_as() ) { return std::move(*ptr); } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > - auto uvalue::get_as() & -> std::conditional_t, T, T&> { + auto uvalue::as() & -> std::conditional_t, T, T&> { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( T* ptr = try_get_as() ) { + if ( T* ptr = try_as() ) { return *ptr; } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > - auto uvalue::get_as() const& -> std::conditional_t, T, const T&> { + auto uvalue::as() const& -> std::conditional_t, T, const T&> { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( const T* ptr = try_get_as() ) { + if ( const T* ptr = try_as() ) { return *ptr; } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > - auto uvalue::get_as() const&& -> std::conditional_t, T, const T&&> { + auto uvalue::as() const&& -> std::conditional_t, T, const T&&> { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( const T* ptr = try_get_as() ) { + if ( const T* ptr = try_as() ) { return std::move(*ptr); } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > // NOLINTNEXTLINE(*-cognitive-complexity) - auto uvalue::try_get_as() noexcept -> std::conditional_t, T, T*> { + auto uvalue::try_as() noexcept -> std::conditional_t, T, T*> { static_assert(std::is_same_v>); using detail::type_registry; @@ -9117,7 +9108,7 @@ namespace meta_hpp template < typename T > // NOLINTNEXTLINE(*-cognitive-complexity) - auto uvalue::try_get_as() const noexcept -> std::conditional_t, T, const T*> { + auto uvalue::try_as() const noexcept -> std::conditional_t, T, const T*> { static_assert(std::is_same_v>); using detail::type_registry; diff --git a/develop/untests/meta_features/diamond_tests.cpp b/develop/untests/meta_features/diamond_tests.cpp index 51d1312..11384af 100644 --- a/develop/untests/meta_features/diamond_tests.cpp +++ b/develop/untests/meta_features/diamond_tests.cpp @@ -258,7 +258,7 @@ TEST_CASE("meta/meta_features/diamond") { CHECK_FALSE(a_inst.can_cast_to(r)); CHECK_FALSE(a_inst.can_cast_to(r)); - CHECK(&a_inst.cast(r) == &a_val.get_as()); + CHECK(&a_inst.cast(r) == &a_val.as()); } { meta::uvalue b_val{B{}}; @@ -270,10 +270,10 @@ TEST_CASE("meta/meta_features/diamond") { CHECK_FALSE(b_inst.can_cast_to(r)); CHECK_FALSE(b_inst.can_cast_to(r)); - CHECK(&b_inst.cast(r) == &b_val.get_as()); - CHECK(&b_inst.cast(r) == &b_val.get_as()); + CHECK(&b_inst.cast(r) == &b_val.as()); + CHECK(&b_inst.cast(r) == &b_val.as()); - CHECK(&b_inst.cast(r) == &b_val.get_as()); + CHECK(&b_inst.cast(r) == &b_val.as()); } { meta::uvalue c_val{C{}}; @@ -285,8 +285,8 @@ TEST_CASE("meta/meta_features/diamond") { CHECK_FALSE(c_inst.can_cast_to(r)); CHECK_FALSE(c_inst.can_cast_to(r)); - CHECK(&c_inst.cast(r) == &c_val.get_as()); - CHECK(&c_inst.cast(r) == &c_val.get_as()); + CHECK(&c_inst.cast(r) == &c_val.as()); + CHECK(&c_inst.cast(r) == &c_val.as()); } { meta::uvalue d_val{D{}}; @@ -298,15 +298,15 @@ TEST_CASE("meta/meta_features/diamond") { CHECK(d_inst.can_cast_to(r)); CHECK_FALSE(d_inst.can_cast_to(r)); - CHECK(&d_inst.cast(r) == &d_val.get_as()); - CHECK(&d_inst.cast(r) == &d_val.get_as()); - CHECK(&d_inst.cast(r) == &d_val.get_as()); - CHECK(&d_inst.cast(r) == &d_val.get_as()); + CHECK(&d_inst.cast(r) == &d_val.as()); + CHECK(&d_inst.cast(r) == &d_val.as()); + CHECK(&d_inst.cast(r) == &d_val.as()); + CHECK(&d_inst.cast(r) == &d_val.as()); - CHECK(&d_inst.cast(r) == &d_val.get_as()); - CHECK(&d_inst.cast(r) == &d_val.get_as()); - CHECK(&d_inst.cast(r) == &d_val.get_as()); - CHECK(&d_inst.cast(r) == &d_val.get_as()); + CHECK(&d_inst.cast(r) == &d_val.as()); + CHECK(&d_inst.cast(r) == &d_val.as()); + CHECK(&d_inst.cast(r) == &d_val.as()); + CHECK(&d_inst.cast(r) == &d_val.as()); } { meta::uvalue e_val{E{}}; @@ -318,7 +318,7 @@ TEST_CASE("meta/meta_features/diamond") { CHECK_FALSE(e_inst.can_cast_to(r)); CHECK(e_inst.can_cast_to(r)); - CHECK(&e_inst.cast(r) == &e_val.get_as()); + CHECK(&e_inst.cast(r) == &e_val.as()); } } diff --git a/develop/untests/meta_states/ctor_tests.cpp b/develop/untests/meta_states/ctor_tests.cpp index 211c92a..9c8d25e 100644 --- a/develop/untests/meta_states/ctor_tests.cpp +++ b/develop/untests/meta_states/ctor_tests.cpp @@ -93,7 +93,7 @@ TEST_CASE("meta/meta_states/ctor/noncopyable") { { const meta::uvalue v = clazz_type.create(42); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); CHECK(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -112,7 +112,7 @@ TEST_CASE("meta/meta_states/ctor/noncopyable") { clazz_t o{42}; const meta::uvalue v = clazz_type.create(std::move(o)); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); CHECK(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -153,7 +153,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { { const meta::uvalue v = clazz_type.create(42); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 42); + CHECK(v.as().i == 42); CHECK_FALSE(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -177,7 +177,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { CHECK(clazz_t::constructor_counter == 1); CHECK(r.get_value().get_type() == meta::resolve_type()); - CHECK(r.get_value().get_as().i == 42); + CHECK(r.get_value().as().i == 42); } } @@ -188,7 +188,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { .create_at(clazz_mem, 42); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); clazz_type.get_destructor().destroy_at(clazz_mem); } @@ -213,7 +213,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { CHECK(clazz_t::constructor_counter == 1); CHECK(r.get_value().get_type() == meta::resolve_type()); - CHECK(r.get_value().get_as()->i == 42); + CHECK(r.get_value().as()->i == 42); } } @@ -229,7 +229,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { clazz_t o{42}; const meta::uvalue v = clazz_type.create(std::move(o)); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 42); + CHECK(v.as().i == 42); CHECK_FALSE(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -246,7 +246,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { .create_at(clazz_mem, std::move(o)); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); clazz_type.get_destructor().destroy_at(clazz_mem); } @@ -266,7 +266,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { clazz_t o{42}; const meta::uvalue v = clazz_type.create(std::as_const(o)); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 42); + CHECK(v.as().i == 42); CHECK_FALSE(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -283,7 +283,7 @@ TEST_CASE("meta/meta_states/ctor/as_object") { .create_at(clazz_mem, std::as_const(o)); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); clazz_type.get_destructor().destroy_at(clazz_mem); } @@ -321,7 +321,7 @@ TEST_CASE("meta/meta_states/ctor/as_raw_pointer") { { const meta::uvalue v = clazz_type.create(42); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); CHECK(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -340,7 +340,7 @@ TEST_CASE("meta/meta_states/ctor/as_raw_pointer") { clazz_t o{42}; const meta::uvalue v = clazz_type.create(std::move(o)); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); CHECK(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -359,7 +359,7 @@ TEST_CASE("meta/meta_states/ctor/as_raw_pointer") { clazz_t o{42}; const meta::uvalue v = clazz_type.create(std::as_const(o)); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as()->i == 42); + CHECK(v.as()->i == 42); CHECK(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -396,7 +396,7 @@ TEST_CASE("meta/meta_states/ctor/as_shared_pointer") { { const meta::uvalue v = clazz_type.create(42); CHECK(v.get_type() == meta::resolve_type>()); - CHECK(v.get_as>()->i == 42); + CHECK(v.as>()->i == 42); CHECK_FALSE(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -415,7 +415,7 @@ TEST_CASE("meta/meta_states/ctor/as_shared_pointer") { clazz_t o{42}; const meta::uvalue v = clazz_type.create(std::move(o)); CHECK(v.get_type() == meta::resolve_type>()); - CHECK(v.get_as>()->i == 42); + CHECK(v.as>()->i == 42); CHECK_FALSE(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); @@ -434,7 +434,7 @@ TEST_CASE("meta/meta_states/ctor/as_shared_pointer") { clazz_t o{42}; const meta::uvalue v = clazz_type.create(std::as_const(o)); CHECK(v.get_type() == meta::resolve_type>()); - CHECK(v.get_as>()->i == 42); + CHECK(v.as>()->i == 42); CHECK_FALSE(clazz_type.destroy(v)); } CHECK(clazz_t::constructor_counter == 1); diff --git a/develop/untests/meta_states/dtor_tests.cpp b/develop/untests/meta_states/dtor_tests.cpp index e7c1fbb..ea0ec3d 100644 --- a/develop/untests/meta_states/dtor_tests.cpp +++ b/develop/untests/meta_states/dtor_tests.cpp @@ -100,6 +100,6 @@ TEST_CASE("meta/meta_states/dtor") { CHECK(dtor.get_type().get_owner_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").get_as() == "virtual dtor"s); + CHECK(dtor.get_metadata().at("desc").as() == "virtual dtor"s); } } diff --git a/develop/untests/meta_states/evalue_tests.cpp b/develop/untests/meta_states/evalue_tests.cpp index c938d59..ecd13e6 100644 --- a/develop/untests/meta_states/evalue_tests.cpp +++ b/develop/untests/meta_states/evalue_tests.cpp @@ -56,10 +56,10 @@ TEST_CASE("meta/meta_states/evalue") { CHECK(evalue.get_type() == meta::resolve_type()); CHECK(evalue.get_name() == "green"); - CHECK(evalue.get_value().get_as() == color::green); + CHECK(evalue.get_value().as() == color::green); CHECK(evalue.get_value().get_type() == color_type); - CHECK(evalue.get_underlying_value().get_as() == meta::detail::to_underlying(color::green)); + CHECK(evalue.get_underlying_value().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 a9d4ed9..bbc6297 100644 --- a/develop/untests/meta_states/function_tests.cpp +++ b/develop/untests/meta_states/function_tests.cpp @@ -89,7 +89,7 @@ TEST_CASE("meta/meta_states/function") { CHECK_FALSE(func.try_invoke(ivec2{}, ivec2{}, 42)); CHECK(func.invoke(ivec2{1,2}, ivec2{3,4})); - CHECK(func.invoke(ivec2{1,2}, ivec2{3,4}).get_as() == ivec2{4,6}); + CHECK(func.invoke(ivec2{1,2}, ivec2{3,4}).as() == ivec2{4,6}); } SUBCASE("ilength2") { @@ -114,7 +114,7 @@ TEST_CASE("meta/meta_states/function") { CHECK_FALSE(func.try_invoke(ivec2{}, 42)); CHECK(func.invoke(ivec2{2,3})); - CHECK(func.invoke(ivec2{2,3}).get_as() == 13); + CHECK(func.invoke(ivec2{2,3}).as() == 13); } SUBCASE("arg_null") { @@ -126,8 +126,8 @@ TEST_CASE("meta/meta_states/function") { CHECK(func.is_invocable_with()); int i{42}; - CHECK(func.invoke(&i).get_as() == false); - CHECK(func.invoke(nullptr).get_as() == true); + CHECK(func.invoke(&i).as() == false); + CHECK(func.invoke(nullptr).as() == true); } SUBCASE("arg_arr") { @@ -146,13 +146,13 @@ TEST_CASE("meta/meta_states/function") { CHECK_FALSE(func1.is_invocable_with()); CHECK_FALSE(func1.is_invocable_with()); - CHECK(func1.invoke(bounded_arr).get_as() == 10); - CHECK(func1.invoke(unbounded_arr).get_as() == 10); + CHECK(func1.invoke(bounded_arr).as() == 10); + CHECK(func1.invoke(unbounded_arr).as() == 10); CHECK_FALSE(func1.try_invoke(bounded_const_arr)); CHECK_FALSE(func1.try_invoke(unbounded_const_arr)); - 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_arr}).as() == 10); + CHECK(func1.invoke(meta::uvalue{unbounded_arr}).as() == 10); CHECK_FALSE(func1.try_invoke(meta::uvalue{bounded_const_arr})); CHECK_FALSE(func1.try_invoke(meta::uvalue{unbounded_const_arr})); @@ -171,13 +171,13 @@ TEST_CASE("meta/meta_states/function") { CHECK_FALSE(func2.is_invocable_with()); CHECK_FALSE(func2.is_invocable_with()); - CHECK(func2.invoke(bounded_arr).get_as() == 10); - CHECK(func2.invoke(unbounded_arr).get_as() == 10); + CHECK(func2.invoke(bounded_arr).as() == 10); + CHECK(func2.invoke(unbounded_arr).as() == 10); CHECK_FALSE(func2.try_invoke(bounded_const_arr)); CHECK_FALSE(func2.try_invoke(unbounded_const_arr)); - 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_arr}).as() == 10); + CHECK(func2.invoke(meta::uvalue{unbounded_arr}).as() == 10); CHECK_FALSE(func2.try_invoke(meta::uvalue{bounded_const_arr})); CHECK_FALSE(func2.try_invoke(meta::uvalue{unbounded_const_arr})); @@ -204,15 +204,15 @@ TEST_CASE("meta/meta_states/function") { CHECK(func1.is_invocable_with()); CHECK(func1.is_invocable_with()); - 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(bounded_arr).as() == 10); + CHECK(func1.invoke(unbounded_arr).as() == 10); + CHECK(func1.invoke(bounded_const_arr).as() == 10); + CHECK(func1.invoke(unbounded_const_arr).as() == 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); + CHECK(func1.invoke(meta::uvalue{bounded_arr}).as() == 10); + CHECK(func1.invoke(meta::uvalue{unbounded_arr}).as() == 10); + CHECK(func1.invoke(meta::uvalue{bounded_const_arr}).as() == 10); + CHECK(func1.invoke(meta::uvalue{unbounded_const_arr}).as() == 10); static_assert(std::is_invocable_v); static_assert(std::is_invocable_v); @@ -229,15 +229,15 @@ TEST_CASE("meta/meta_states/function") { CHECK(func2.is_invocable_with()); CHECK(func2.is_invocable_with()); - 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(bounded_arr).as() == 10); + CHECK(func2.invoke(unbounded_arr).as() == 10); + CHECK(func2.invoke(bounded_const_arr).as() == 10); + CHECK(func2.invoke(unbounded_const_arr).as() == 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); + CHECK(func2.invoke(meta::uvalue{bounded_arr}).as() == 10); + CHECK(func2.invoke(meta::uvalue{unbounded_arr}).as() == 10); + CHECK(func2.invoke(meta::uvalue{bounded_const_arr}).as() == 10); + CHECK(func2.invoke(meta::uvalue{unbounded_const_arr}).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 c001986..168e207 100644 --- a/develop/untests/meta_states/member_tests.cpp +++ b/develop/untests/meta_states/member_tests.cpp @@ -84,19 +84,19 @@ TEST_CASE("meta/meta_states/member") { } { - 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.get(v).as() == 1); + CHECK(vm.get(&v).as() == 1); + CHECK(vm.get(std::as_const(v)).as() == 1); + CHECK(vm.get(&std::as_const(v)).as() == 1); + CHECK(vm.get(std::move(v)).as() == 1); + CHECK(vm.get(std::move(std::as_const(v))).as() == 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(vm(v).as() == 1); + CHECK(vm(&v).as() == 1); + CHECK(vm(std::as_const(v)).as() == 1); + CHECK(vm(&std::as_const(v)).as() == 1); + CHECK(vm(std::move(v)).as() == 1); + CHECK(vm(std::move(std::as_const(v))).as() == 1); CHECK_FALSE(vm.try_get(v2)); CHECK_FALSE(vm.try_get(&v2)); @@ -139,22 +139,22 @@ TEST_CASE("meta/meta_states/member") { } { - vm.set(v, 10); CHECK(vm.get(v).get_as() == 10); - vm.set(&v, 100); CHECK(vm.get(v).get_as() == 100); - CHECK_FALSE(vm.try_set(std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 100); - CHECK_FALSE(vm.try_set(&std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 100); + vm.set(v, 10); CHECK(vm.get(v).as() == 10); + vm.set(&v, 100); CHECK(vm.get(v).as() == 100); + CHECK_FALSE(vm.try_set(std::as_const(v), 11)); CHECK(vm.get(v).as() == 100); + CHECK_FALSE(vm.try_set(&std::as_const(v), 11)); CHECK(vm.get(v).as() == 100); - vm.set(std::move(v), 12); CHECK(vm.get(v).get_as() == 12); - CHECK_FALSE(vm.try_set(std::move(std::as_const(v)), 13)); CHECK(vm.get(v).get_as() == 12); + vm.set(std::move(v), 12); CHECK(vm.get(v).as() == 12); + CHECK_FALSE(vm.try_set(std::move(std::as_const(v)), 13)); CHECK(vm.get(v).as() == 12); - vm(v, 13); CHECK(vm(v).get_as() == 13); - vm(&v, 130); CHECK(vm(v).get_as() == 130); + vm(v, 13); CHECK(vm(v).as() == 13); + vm(&v, 130); CHECK(vm(v).as() == 130); - vm(std::move(v), 15); CHECK(vm(v).get_as() == 15); + vm(std::move(v), 15); CHECK(vm(v).as() == 15); CHECK_FALSE(vm.try_set(v2, 17)); CHECK_FALSE(vm.try_set(&v2, 17)); - CHECK(vm(v).get_as() == 15); + CHECK(vm(v).as() == 15); } } @@ -192,19 +192,19 @@ TEST_CASE("meta/meta_states/member") { } { - 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.get(v).as() == 2); + CHECK(vm.get(&v).as() == 2); + CHECK(vm.get(std::as_const(v)).as() == 2); + CHECK(vm.get(&std::as_const(v)).as() == 2); + CHECK(vm.get(std::move(v)).as() == 2); + CHECK(vm.get(std::move(std::as_const(v))).as() == 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(vm(v).as() == 2); + CHECK(vm(&v).as() == 2); + CHECK(vm(std::as_const(v)).as() == 2); + CHECK(vm(&std::as_const(v)).as() == 2); + CHECK(vm(std::move(v)).as() == 2); + CHECK(vm(std::move(std::as_const(v))).as() == 2); CHECK_FALSE(vm.try_get(v2)); CHECK_FALSE(vm.try_get(&v2)); @@ -243,16 +243,16 @@ TEST_CASE("meta/meta_states/member") { } { - CHECK_FALSE(vm.try_set(v, 10)); CHECK(vm.get(v).get_as() == 2); - CHECK_FALSE(vm.try_set(&v, 10)); CHECK(vm.get(v).get_as() == 2); - CHECK_FALSE(vm.try_set(std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 2); - CHECK_FALSE(vm.try_set(&std::as_const(v), 11)); CHECK(vm.get(v).get_as() == 2); - CHECK_FALSE(vm.try_set(std::move(v), 12)); CHECK(vm.get(v).get_as() == 2); - CHECK_FALSE(vm.try_set(std::move(std::as_const(v)), 16)); CHECK(vm.get(v).get_as() == 2); + CHECK_FALSE(vm.try_set(v, 10)); CHECK(vm.get(v).as() == 2); + CHECK_FALSE(vm.try_set(&v, 10)); CHECK(vm.get(v).as() == 2); + CHECK_FALSE(vm.try_set(std::as_const(v), 11)); CHECK(vm.get(v).as() == 2); + CHECK_FALSE(vm.try_set(&std::as_const(v), 11)); CHECK(vm.get(v).as() == 2); + CHECK_FALSE(vm.try_set(std::move(v), 12)); CHECK(vm.get(v).as() == 2); + CHECK_FALSE(vm.try_set(std::move(std::as_const(v)), 16)); CHECK(vm.get(v).as() == 2); CHECK_FALSE(vm.try_set(v2, 17)); CHECK_FALSE(vm.try_set(&v2, 17)); - CHECK(vm(v).get_as() == 2); + CHECK(vm(v).as() == 2); } } @@ -266,13 +266,13 @@ TEST_CASE("meta/meta_states/member") { { clazz_1 v; CHECK(vm.get(v).get_type() == meta::resolve_type*>()); - CHECK(vm.get(v).get_as*>() == std::addressof(v.unique_int_member)); + CHECK(vm.get(v).as*>() == std::addressof(v.unique_int_member)); } { const clazz_1 v; CHECK(vm.get(v).get_type() == meta::resolve_type*>()); - CHECK(vm.get(v).get_as*>() == std::addressof(v.unique_int_member)); + CHECK(vm.get(v).as*>() == std::addressof(v.unique_int_member)); } } @@ -287,14 +287,14 @@ TEST_CASE("meta/meta_states/member") { clazz_1 v; using ref_t = std::reference_wrapper>; CHECK(vm.get(v).get_type() == meta::resolve_type()); - CHECK(vm.get(v).get_as().get() == v.unique_int_member); + CHECK(vm.get(v).as().get() == v.unique_int_member); } { const clazz_1 v; using ref_t = std::reference_wrapper>; CHECK(vm.get(v).get_type() == meta::resolve_type()); - CHECK(vm.get(v).get_as().get() == v.unique_int_member); + CHECK(vm.get(v).as().get() == v.unique_int_member); } } @@ -306,7 +306,7 @@ TEST_CASE("meta/meta_states/member") { clazz_2 v2; CHECK(vm.try_get(v)); - CHECK(vm.try_get(v).get_value().get_as() == 1); + CHECK(vm.try_get(v).get_value().as() == 1); CHECK_FALSE(vm.try_get(v2)); } @@ -318,10 +318,10 @@ TEST_CASE("meta/meta_states/member") { clazz_2 v2; CHECK(vm.try_set(v, 10)); - CHECK(vm.get(v).get_as() == 10); + CHECK(vm.get(v).as() == 10); CHECK_FALSE(vm.try_set(v, 20.0)); CHECK_FALSE(vm.try_set(v2, 20)); - CHECK(vm.get(v).get_as() == 10); + CHECK(vm.get(v).as() == 10); } } diff --git a/develop/untests/meta_states/metadata_tests.cpp b/develop/untests/meta_states/metadata_tests.cpp index 36bde09..292ce57 100644 --- a/develop/untests/meta_states/metadata_tests.cpp +++ b/develop/untests/meta_states/metadata_tests.cpp @@ -72,16 +72,16 @@ TEST_CASE("meta/meta_states/metadata/enum") { REQUIRE(color_type); SUBCASE("color") { - 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); + CHECK(color_type.get_metadata().at("desc1").as() == "enum-desc1"s); + CHECK(color_type.get_metadata().at("desc2").as() == "new-enum-desc2"s); + CHECK(color_type.get_metadata().at("desc3").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").get_as() == "new-red-color"s); + CHECK(red_evalue.get_metadata().at("desc2").as() == "new-red-color"s); } } @@ -147,9 +147,9 @@ TEST_CASE("meta/meta_states/metadata/class") { REQUIRE(ivec2_type); SUBCASE("ivec2") { - 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); + CHECK(ivec2_type.get_metadata().at("desc1").as() == "class-desc1"s); + CHECK(ivec2_type.get_metadata().at("desc2").as() == "new-class-desc2"s); + CHECK(ivec2_type.get_metadata().at("desc3").as() == "new-class-desc3"s); } SUBCASE("ivec2(int)") { @@ -157,14 +157,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").get_as() == "one arg 2d vector ctor"s); + CHECK(ivec2_ctor.get_metadata().at("desc").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").get_as() == "the ctor arg"s); + CHECK(ivec2_ctor.get_argument(0).get_metadata().at("desc").as() == "the ctor arg"s); REQUIRE_FALSE(ivec2_ctor.get_argument(1)); } @@ -174,21 +174,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").get_as() == "two args 2d vector ctor"s); + CHECK(ivec2_ctor.get_metadata().at("desc").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").get_as() == "the 1st ctor arg"s); + CHECK(ivec2_ctor.get_argument(0).get_metadata().at("desc").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").get_as() == "the 2nd ctor arg"s); + CHECK(ivec2_ctor.get_argument(1).get_metadata().at("desc").as() == "the 2nd ctor arg"s); REQUIRE_FALSE(ivec2_ctor.get_argument(2)); } @@ -198,7 +198,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").get_as() == "x-member"s); + CHECK(ivec2_x.get_metadata().at("desc").as() == "x-member"s); } SUBCASE("ivec2::y") { @@ -206,7 +206,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").get_as() == "y-member"s); + CHECK(ivec2_y.get_metadata().at("desc").as() == "y-member"s); } SUBCASE("ivec2::add") { @@ -214,11 +214,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").get_as() == "add-method"s); + CHECK(ivec2_add.get_metadata().at("desc").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").get_as() == "other-arg"s); + CHECK(ivec2_add.get_argument(0).get_metadata().at("desc").as() == "other-arg"s); } SUBCASE("ivec2::iadd") { @@ -226,15 +226,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").get_as() == "iadd-function"s); + CHECK(ivec2_iadd.get_metadata().at("desc").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").get_as() == "l-arg"s); + CHECK(ivec2_iadd.get_argument(0).get_metadata().at("desc").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").get_as() == "r-arg"s); + CHECK(ivec2_iadd.get_argument(1).get_metadata().at("desc").as() == "r-arg"s); } } @@ -246,14 +246,14 @@ TEST_CASE("meta/meta_states/metadata/scope") { const meta::scope lscope = meta::local_scope_("local-scope", { {"desc", "scope-desc"s} }); - CHECK(lscope.get_metadata().at("desc").get_as() == "scope-desc"s); + CHECK(lscope.get_metadata().at("desc").as() == "scope-desc"s); } SUBCASE("static_scope") { meta::static_scope_("meta/meta_states/metadata/scope/static-scope", { {"desc", "scope-desc"s} }); - CHECK(meta::resolve_scope("meta/meta_states/metadata/scope/static-scope").get_metadata().at("desc").get_as() == "scope-desc"s); + CHECK(meta::resolve_scope("meta/meta_states/metadata/scope/static-scope").get_metadata().at("desc").as() == "scope-desc"s); } } @@ -265,62 +265,62 @@ TEST_CASE("meta/meta_states/metadata/other") { meta::array_({ {"desc", "int[]-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int[]-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "int[]-type"s); } SUBCASE("function") { meta::function_({ {"desc", "int->int"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int->int"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "int->int"s); } SUBCASE("member") { meta::member_({ {"desc", "ivec2::int"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "ivec2::int"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "ivec2::int"s); } SUBCASE("method") { meta::method_({ {"desc", "ivec2(int -> int)"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "ivec2(int -> int)"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "ivec2(int -> int)"s); } SUBCASE("nullptr") { meta::nullptr_({ {"desc", "nullptr_t"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "nullptr_t"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "nullptr_t"s); } SUBCASE("number") { meta::number_({ {"desc", "int-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "int-type"s); } SUBCASE("pointer") { meta::pointer_({ {"desc", "int*-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int*-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "int*-type"s); } SUBCASE("reference") { meta::reference_({ {"desc", "int&-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "int&-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "int&-type"s); } SUBCASE("void") { meta::void_({ {"desc", "void-type"s} }); - CHECK(meta::resolve_type().get_metadata().at("desc").get_as() == "void-type"s); + CHECK(meta::resolve_type().get_metadata().at("desc").as() == "void-type"s); } } diff --git a/develop/untests/meta_states/method_tests.cpp b/develop/untests/meta_states/method_tests.cpp index 4672eda..8cd0dab 100644 --- a/develop/untests/meta_states/method_tests.cpp +++ b/develop/untests/meta_states/method_tests.cpp @@ -148,14 +148,14 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl).get_as() == 1); + CHECK(mi.invoke(cl).as() == 1); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)).get_as() == 1); + CHECK(mi.invoke(std::move(cl)).as() == 1); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv).get_as() == 1); + CHECK(mi.invoke(clv).as() == 1); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)).get_as() == 1); + CHECK(mi.invoke(std::move(clv)).as() == 1); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(clv)))); } @@ -168,15 +168,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 1); + CHECK(mi.invoke(std::as_const(cl1)).as() == 1); + CHECK(mi.invoke(std::move(cl1)).as() == 1); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(mi.invoke(cl1v).as() == 1); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 1); + CHECK(mi.invoke(std::move(cl1v)).as() == 1); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 1); CHECK_FALSE(mi.try_invoke(cl2)); CHECK_FALSE(mi.try_invoke(std::as_const(cl2))); @@ -234,14 +234,14 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl).get_as() == 2); + CHECK(mi.invoke(cl).as() == 2); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)).get_as() == 2); + CHECK(mi.invoke(std::move(cl)).as() == 2); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv).get_as() == 2); + CHECK(mi.invoke(clv).as() == 2); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)).get_as() == 2); + CHECK(mi.invoke(std::move(clv)).as() == 2); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(clv)))); } @@ -254,15 +254,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 2); + CHECK(mi.invoke(std::as_const(cl1)).as() == 2); + CHECK(mi.invoke(std::move(cl1)).as() == 2); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(mi.invoke(cl1v).as() == 2); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 2); + CHECK(mi.invoke(std::move(cl1v)).as() == 2); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 2); CHECK_FALSE(mi.try_invoke(cl2)); CHECK_FALSE(mi.try_invoke(std::as_const(cl2))); @@ -320,15 +320,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - 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(cl).as() == 3); + CHECK(mi.invoke(std::as_const(cl)).as() == 3); + CHECK(mi.invoke(std::move(cl)).as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl))).as() == 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); + CHECK(mi.invoke(clv).as() == 3); + CHECK(mi.invoke(std::as_const(clv)).as() == 3); + CHECK(mi.invoke(std::move(clv)).as() == 3); + CHECK(mi.invoke(std::move(std::as_const(clv))).as() == 3); } { @@ -340,25 +340,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 3); + CHECK(mi.invoke(std::as_const(cl1)).as() == 3); + CHECK(mi.invoke(std::move(cl1)).as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(cl1v).as() == 3); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 3); + CHECK(mi.invoke(std::move(cl1v)).as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 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(cl2).as() == 3); + CHECK(mi.invoke(std::as_const(cl2)).as() == 3); + CHECK(mi.invoke(std::move(cl2)).as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl2))).as() == 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); + CHECK(mi.invoke(cl2v).as() == 3); + CHECK(mi.invoke(std::as_const(cl2v)).as() == 3); + CHECK(mi.invoke(std::move(cl2v)).as() == 3); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).as() == 3); } static_assert(std::is_invocable_v); @@ -406,15 +406,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - 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(cl).as() == 4); + CHECK(mi.invoke(std::as_const(cl)).as() == 4); + CHECK(mi.invoke(std::move(cl)).as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl))).as() == 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); + CHECK(mi.invoke(clv).as() == 4); + CHECK(mi.invoke(std::as_const(clv)).as() == 4); + CHECK(mi.invoke(std::move(clv)).as() == 4); + CHECK(mi.invoke(std::move(std::as_const(clv))).as() == 4); } { @@ -426,25 +426,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 4); + CHECK(mi.invoke(std::as_const(cl1)).as() == 4); + CHECK(mi.invoke(std::move(cl1)).as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(cl1v).as() == 4); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 4); + CHECK(mi.invoke(std::move(cl1v)).as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 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(cl2).as() == 4); + CHECK(mi.invoke(std::as_const(cl2)).as() == 4); + CHECK(mi.invoke(std::move(cl2)).as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl2))).as() == 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); + CHECK(mi.invoke(cl2v).as() == 4); + CHECK(mi.invoke(std::as_const(cl2v)).as() == 4); + CHECK(mi.invoke(std::move(cl2v)).as() == 4); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).as() == 4); } static_assert(std::is_invocable_v); @@ -487,12 +487,12 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl).get_as() == 5); + CHECK(mi.invoke(cl).as() == 5); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); CHECK_FALSE(mi.try_invoke(std::move(cl))); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv).get_as() == 5); + CHECK(mi.invoke(clv).as() == 5); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); CHECK_FALSE(mi.try_invoke(std::move(clv))); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(clv)))); @@ -507,15 +507,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 5); + CHECK(mi.invoke(std::as_const(cl1)).as() == 5); + CHECK(mi.invoke(std::move(cl1)).as() == 5); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(mi.invoke(cl1v).as() == 5); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 5); + CHECK(mi.invoke(std::move(cl1v)).as() == 5); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 5); CHECK_FALSE(mi.try_invoke(cl2)); CHECK_FALSE(mi.try_invoke(std::as_const(cl2))); @@ -568,12 +568,12 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - CHECK(mi.invoke(cl).get_as() == 6); + CHECK(mi.invoke(cl).as() == 6); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); CHECK_FALSE(mi.try_invoke(std::move(cl))); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(cl)))); - CHECK(mi.invoke(clv).get_as() == 6); + CHECK(mi.invoke(clv).as() == 6); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); CHECK_FALSE(mi.try_invoke(std::move(clv))); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(clv)))); @@ -588,15 +588,15 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 6); + CHECK(mi.invoke(std::as_const(cl1)).as() == 6); + CHECK(mi.invoke(std::move(cl1)).as() == 6); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(mi.invoke(cl1v).as() == 6); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 6); + CHECK(mi.invoke(std::move(cl1v)).as() == 6); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 6); CHECK_FALSE(mi.try_invoke(cl2)); CHECK_FALSE(mi.try_invoke(std::as_const(cl2))); @@ -649,15 +649,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - 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(cl).as() == 7); + CHECK(mi.invoke(std::as_const(cl)).as() == 7); + CHECK(mi.invoke(std::move(cl)).as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl))).as() == 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); + CHECK(mi.invoke(clv).as() == 7); + CHECK(mi.invoke(std::as_const(clv)).as() == 7); + CHECK(mi.invoke(std::move(clv)).as() == 7); + CHECK(mi.invoke(std::move(std::as_const(clv))).as() == 7); } { @@ -669,25 +669,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 7); + CHECK(mi.invoke(std::as_const(cl1)).as() == 7); + CHECK(mi.invoke(std::move(cl1)).as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(cl1v).as() == 7); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 7); + CHECK(mi.invoke(std::move(cl1v)).as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 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(cl2).as() == 7); + CHECK(mi.invoke(std::as_const(cl2)).as() == 7); + CHECK(mi.invoke(std::move(cl2)).as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl2))).as() == 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); + CHECK(mi.invoke(cl2v).as() == 7); + CHECK(mi.invoke(std::as_const(cl2v)).as() == 7); + CHECK(mi.invoke(std::move(cl2v)).as() == 7); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).as() == 7); } static_assert(std::is_invocable_v); @@ -730,15 +730,15 @@ TEST_CASE("meta/meta_states/method") { derived_clazz cl; meta::uvalue clv{cl}; - 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(cl).as() == 8); + CHECK(mi.invoke(std::as_const(cl)).as() == 8); + CHECK(mi.invoke(std::move(cl)).as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl))).as() == 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); + CHECK(mi.invoke(clv).as() == 8); + CHECK(mi.invoke(std::as_const(clv)).as() == 8); + CHECK(mi.invoke(std::move(clv)).as() == 8); + CHECK(mi.invoke(std::move(std::as_const(clv))).as() == 8); } { @@ -750,25 +750,25 @@ TEST_CASE("meta/meta_states/method") { meta::uvalue cl1v{cl1}; meta::uvalue cl2v{cl2}; - 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(cl1).as() == 8); + CHECK(mi.invoke(std::as_const(cl1)).as() == 8); + CHECK(mi.invoke(std::move(cl1)).as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl1))).as() == 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(cl1v).as() == 8); + CHECK(mi.invoke(std::as_const(cl1v)).as() == 8); + CHECK(mi.invoke(std::move(cl1v)).as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl1v))).as() == 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(cl2).as() == 8); + CHECK(mi.invoke(std::as_const(cl2)).as() == 8); + CHECK(mi.invoke(std::move(cl2)).as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl2))).as() == 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); + CHECK(mi.invoke(cl2v).as() == 8); + CHECK(mi.invoke(std::as_const(cl2v)).as() == 8); + CHECK(mi.invoke(std::move(cl2v)).as() == 8); + CHECK(mi.invoke(std::move(std::as_const(cl2v))).as() == 8); } static_assert(std::is_invocable_v); @@ -813,12 +813,12 @@ TEST_CASE("meta/meta_states/method") { CHECK_FALSE(mi.try_invoke(cl)); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)).get_as() == 9); + CHECK(mi.invoke(std::move(cl)).as() == 9); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(cl)))); CHECK_FALSE(mi.try_invoke(clv)); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)).get_as() == 9); + CHECK(mi.invoke(std::move(clv)).as() == 9); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(clv)))); } @@ -894,12 +894,12 @@ TEST_CASE("meta/meta_states/method") { CHECK_FALSE(mi.try_invoke(cl)); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)).get_as() == 10); + CHECK(mi.invoke(std::move(cl)).as() == 10); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(cl)))); CHECK_FALSE(mi.try_invoke(clv)); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)).get_as() == 10); + CHECK(mi.invoke(std::move(clv)).as() == 10); CHECK_FALSE(mi.try_invoke(std::move(std::as_const(clv)))); } @@ -975,13 +975,13 @@ TEST_CASE("meta/meta_states/method") { CHECK_FALSE(mi.try_invoke(cl)); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)).get_as() == 11); - CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 11); + CHECK(mi.invoke(std::move(cl)).as() == 11); + CHECK(mi.invoke(std::move(std::as_const(cl))).as() == 11); CHECK_FALSE(mi.try_invoke(clv)); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)).get_as() == 11); - CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 11); + CHECK(mi.invoke(std::move(clv)).as() == 11); + CHECK(mi.invoke(std::move(std::as_const(clv))).as() == 11); } { @@ -1056,13 +1056,13 @@ TEST_CASE("meta/meta_states/method") { CHECK_FALSE(mi.try_invoke(cl)); CHECK_FALSE(mi.try_invoke(std::as_const(cl))); - CHECK(mi.invoke(std::move(cl)).get_as() == 12); - CHECK(mi.invoke(std::move(std::as_const(cl))).get_as() == 12); + CHECK(mi.invoke(std::move(cl)).as() == 12); + CHECK(mi.invoke(std::move(std::as_const(cl))).as() == 12); CHECK_FALSE(mi.try_invoke(clv)); CHECK_FALSE(mi.try_invoke(std::as_const(clv))); - CHECK(mi.invoke(std::move(clv)).get_as() == 12); - CHECK(mi.invoke(std::move(std::as_const(clv))).get_as() == 12); + CHECK(mi.invoke(std::move(clv)).as() == 12); + CHECK(mi.invoke(std::move(std::as_const(clv))).as() == 12); } { @@ -1122,25 +1122,25 @@ TEST_CASE("meta/meta_states/method") { { clazz cl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(cl).get_as() == -1); + CHECK(mi.invoke(cl).as() == -1); } { clazz cl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(&cl).get_as() == -1); + CHECK(mi.invoke(&cl).as() == -1); } { derived_clazz dcl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(dcl).get_as() == -2); + CHECK(mi.invoke(dcl).as() == -2); } { derived_clazz dcl; CHECK(mi.is_invocable_with()); - CHECK(mi.invoke(&dcl).get_as() == -2); + CHECK(mi.invoke(&dcl).as() == -2); } } } diff --git a/develop/untests/meta_states/variable_tests.cpp b/develop/untests/meta_states/variable_tests.cpp index 4b491de..d661047 100644 --- a/develop/untests/meta_states/variable_tests.cpp +++ b/develop/untests/meta_states/variable_tests.cpp @@ -87,8 +87,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().get_as() == 1); - CHECK(vm().get_as() == 1); + CHECK(vm.get().as() == 1); + CHECK(vm().as() == 1); CHECK(vm.is_settable_with()); CHECK(vm.is_settable_with()); @@ -100,8 +100,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().get_as() == 10); - vm(11); CHECK(vm().get_as() == 11); + vm.set(10); CHECK(vm.get().as() == 10); + vm(11); CHECK(vm().as() == 11); } SUBCASE("const int") { @@ -111,8 +111,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().get_as() == 2); - CHECK(vm().get_as() == 2); + CHECK(vm.get().as() == 2); + CHECK(vm().as() == 2); CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with()); @@ -124,7 +124,7 @@ TEST_CASE("meta/meta_states/variable") { CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with(1.0)); - CHECK_FALSE(vm.try_set(10)); CHECK(vm.get().get_as() == 2); + CHECK_FALSE(vm.try_set(10)); CHECK(vm.get().as() == 2); } SUBCASE("ref int") { @@ -134,8 +134,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().get_as() == 1); - CHECK(vm().get_as() == 1); + CHECK(vm.get().as() == 1); + CHECK(vm().as() == 1); CHECK(vm.is_settable_with()); CHECK(vm.is_settable_with()); @@ -147,8 +147,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().get_as() == 20); - vm(21); CHECK(vm().get_as() == 21); + vm.set(20); CHECK(vm.get().as() == 20); + vm(21); CHECK(vm().as() == 21); } SUBCASE("const ref int") { @@ -158,8 +158,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().get_as() == 2); - CHECK(vm().get_as() == 2); + CHECK(vm.get().as() == 2); + CHECK(vm().as() == 2); CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with()); @@ -171,7 +171,7 @@ TEST_CASE("meta/meta_states/variable") { CHECK_FALSE(vm.is_settable_with()); CHECK_FALSE(vm.is_settable_with(1.0)); - CHECK_FALSE(vm.try_set(10)); CHECK(vm.get().get_as() == 2); + CHECK_FALSE(vm.try_set(10)); CHECK(vm.get().as() == 2); } SUBCASE("unique_int_variable_as_ptr") { @@ -179,7 +179,7 @@ TEST_CASE("meta/meta_states/variable") { REQUIRE(vm); CHECK(vm.get().get_type() == meta::resolve_type()); - CHECK(vm.get().get_as() == std::addressof(clazz_1::unique_int_variable)); + CHECK(vm.get().as() == std::addressof(clazz_1::unique_int_variable)); { unique_int nv{11}; @@ -200,7 +200,7 @@ TEST_CASE("meta/meta_states/variable") { using ref_t = std::reference_wrapper; CHECK(vm.get().get_type() == meta::resolve_type()); - CHECK(&vm.get().get_as().get() == &clazz_1::unique_int_variable); + CHECK(&vm.get().as().get() == &clazz_1::unique_int_variable); { unique_int nv{13}; @@ -220,7 +220,7 @@ TEST_CASE("meta/meta_states/variable") { REQUIRE(vm); CHECK(vm.get().get_type() == meta::resolve_type()); - CHECK(vm.get().get_as() == std::addressof(clazz_1::const_unique_int_variable)); + CHECK(vm.get().as() == std::addressof(clazz_1::const_unique_int_variable)); { unique_int nv{11}; @@ -236,7 +236,7 @@ TEST_CASE("meta/meta_states/variable") { using ref_t = std::reference_wrapper; CHECK(vm.get().get_type() == meta::resolve_type()); - CHECK(&vm.get().get_as().get() == &clazz_1::const_unique_int_variable); + CHECK(&vm.get().as().get() == &clazz_1::const_unique_int_variable); { unique_int nv{12}; @@ -251,9 +251,9 @@ TEST_CASE("meta/meta_states/variable") { REQUIRE(vm); CHECK(vm.try_set(10)); - CHECK(vm.get().get_as() == 10); + CHECK(vm.get().as() == 10); CHECK_FALSE(vm.try_set(unique_int{})); - CHECK(vm.get().get_as() == 10); + CHECK(vm.get().as() == 10); } } diff --git a/develop/untests/meta_types/enum_type_tests.cpp b/develop/untests/meta_types/enum_type_tests.cpp index b6a8c7a..8ecbe7f 100644 --- a/develop/untests/meta_types/enum_type_tests.cpp +++ b/develop/untests/meta_types/enum_type_tests.cpp @@ -91,8 +91,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().get_as() == color::green); - CHECK(green_value.get_underlying_value().get_as() == meta::detail::to_underlying(color::green)); + CHECK(green_value.get_value().as() == color::green); + CHECK(green_value.get_underlying_value().as() == meta::detail::to_underlying(color::green)); } { @@ -109,8 +109,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().get_as() == ecolor_green); - CHECK(green_value.get_underlying_value().get_as() == meta::detail::to_underlying(ecolor_green)); + CHECK(green_value.get_value().as() == ecolor_green); + CHECK(green_value.get_underlying_value().as() == meta::detail::to_underlying(ecolor_green)); } { @@ -143,7 +143,7 @@ TEST_CASE("meta/meta_types/enum_type") { { REQUIRE(color_type.name_to_value("blue")); - CHECK(color_type.name_to_value("blue").get_as() == color::blue); + CHECK(color_type.name_to_value("blue").as() == color::blue); } { @@ -157,7 +157,7 @@ TEST_CASE("meta/meta_types/enum_type") { { REQUIRE(ecolor_type.name_to_value("blue")); - CHECK(ecolor_type.name_to_value("blue").get_as() == ecolor_blue); + CHECK(ecolor_type.name_to_value("blue").as() == ecolor_blue); } { diff --git a/develop/untests/meta_utilities/arg6_tests.cpp b/develop/untests/meta_utilities/arg6_tests.cpp index 2aa7561..741fe50 100644 --- a/develop/untests/meta_utilities/arg6_tests.cpp +++ b/develop/untests/meta_utilities/arg6_tests.cpp @@ -49,10 +49,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).get_as() == 42); + CHECK(f.invoke(cl, &clazz::int_member).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}).get_as() == 42); + CHECK(f.invoke(meta::uvalue{cl}, meta::uvalue{&clazz::int_member}).as() == 42); } SUBCASE("int_method") { @@ -63,9 +63,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).get_as() == 42); + CHECK(f.invoke(cl, &clazz::int_method).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}).get_as() == 42); + CHECK(f.invoke(meta::uvalue{cl}, meta::uvalue{&clazz::int_method}).as() == 42); } } diff --git a/develop/untests/meta_utilities/arg_tests.cpp b/develop/untests/meta_utilities/arg_tests.cpp index 9a9ab08..3da3cd1 100644 --- a/develop/untests/meta_utilities/arg_tests.cpp +++ b/develop/untests/meta_utilities/arg_tests.cpp @@ -79,7 +79,7 @@ namespace std::ignore = uarg{r, FromValue}.cast(r);\ \ CHECK(f_state.is_invocable_with());\ - CHECK(f_state.invoke(FromValue).get_as() == 1);\ + CHECK(f_state.invoke(FromValue).as() == 1);\ } else {\ CHECK_FALSE(uarg{r, FromValue}.can_cast_to(r));\ CHECK_FALSE(uarg_base{r, type_list{}}.can_cast_to(r));\ @@ -100,7 +100,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).get_as() == 1);\ + CHECK(f_state.invoke(FromValue).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 6b534e6..fae933b 100644 --- a/develop/untests/meta_utilities/inst_tests.cpp +++ b/develop/untests/meta_utilities/inst_tests.cpp @@ -39,7 +39,7 @@ namespace std::ignore = uinst{r, Inst}.cast(r);\ \ CHECK(m_state.is_invocable_with());\ - CHECK(m_state.invoke(Inst).get_as() == 1);\ + CHECK(m_state.invoke(Inst).as() == 1);\ } else {\ CHECK_FALSE(uinst{r, Inst}.can_cast_to(r));\ CHECK_FALSE(uinst_base{r, type_list{}}.can_cast_to(r));\ @@ -60,7 +60,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).get_as() == 1);\ + CHECK(m_state.invoke(FromValue).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 762b799..dedd570 100644 --- a/develop/untests/meta_utilities/invoke_tests.cpp +++ b/develop/untests/meta_utilities/invoke_tests.cpp @@ -33,10 +33,10 @@ TEST_CASE("meta/meta_utilities/invoke") { REQUIRE((clazz_member && clazz_method && clazz_function)); { - 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::invoke(&clazz::function, 3).as() == 3); + CHECK(meta::invoke(&clazz::function, meta::uvalue{3}).as() == 3); + CHECK(meta::invoke(clazz_function, 3).as() == 3); + CHECK(meta::invoke(clazz_function, meta::uvalue{3}).as() == 3); CHECK(meta::is_invocable_with(clazz_function, 3)); CHECK(meta::is_invocable_with(clazz_function, meta::uvalue{3})); @@ -51,10 +51,10 @@ TEST_CASE("meta/meta_utilities/invoke") { { clazz cl; - 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::invoke(&clazz::member, cl).as() == 1); + CHECK(meta::invoke(&clazz::member, meta::uvalue{cl}).as() == 1); + CHECK(meta::invoke(clazz_member, cl).as() == 1); + CHECK(meta::invoke(clazz_member, meta::uvalue{cl}).as() == 1); CHECK(meta::is_invocable_with(clazz_member, cl)); CHECK(meta::is_invocable_with(clazz_member, meta::uvalue{cl})); @@ -69,10 +69,10 @@ TEST_CASE("meta/meta_utilities/invoke") { { clazz cl; - 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::invoke(&clazz::method, cl, 2).as() == 2); + CHECK(meta::invoke(&clazz::method, meta::uvalue{cl}, meta::uvalue{2}).as() == 2); + CHECK(meta::invoke(clazz_method, cl, 2).as() == 2); + CHECK(meta::invoke(clazz_method, meta::uvalue{cl}, meta::uvalue{2}).as() == 2); CHECK(meta::is_invocable_with(clazz_method, cl, 2)); CHECK(meta::is_invocable_with(clazz_method, meta::uvalue{cl}, meta::uvalue{2})); diff --git a/develop/untests/meta_utilities/result_tests.cpp b/develop/untests/meta_utilities/result_tests.cpp index 83cd891..c7ee53d 100644 --- a/develop/untests/meta_utilities/result_tests.cpp +++ b/develop/untests/meta_utilities/result_tests.cpp @@ -150,7 +150,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -159,7 +159,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -168,7 +168,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -180,7 +180,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -189,7 +189,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -198,7 +198,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as>() == std::vector{42, 21}); + CHECK(res.get_value().as>() == std::vector{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -207,7 +207,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as>() == std::vector{42, 21}); + CHECK(res.get_value().as>() == std::vector{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -220,7 +220,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); @@ -235,7 +235,7 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res); CHECK(res.has_value()); REQUIRE(res.get_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK_FALSE(res.has_error()); CHECK(res.get_error() == meta::error_code::no_error); } @@ -246,24 +246,24 @@ TEST_CASE("meta/meta_utilities/uresult") { CHECK(res.emplace>({42, 21}) == std::vector{42, 21}); CHECK(res); CHECK(res.has_value()); - CHECK(res.get_value().get_as>() == std::vector{42, 21}); + CHECK(res.get_value().as>() == std::vector{42, 21}); CHECK(res.emplace(42, 21) == ivec2{42, 21}); CHECK(res); CHECK(res.has_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); } { meta::uresult res{meta::uerror{meta::error_code::bad_argument_cast}}; CHECK(res.emplace(42, 21) == ivec2{42, 21}); CHECK(res); CHECK(res.has_value()); - CHECK(res.get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); CHECK(res.emplace>({42, 21}) == std::vector{42, 21}); CHECK(res); CHECK(res.has_value()); - CHECK(res.get_value().get_as>() == std::vector{42, 21}); + CHECK(res.get_value().as>() == std::vector{42, 21}); } } @@ -272,15 +272,15 @@ TEST_CASE("meta/meta_utilities/uresult") { meta::uresult res1{ivec2{42}}; meta::uresult res2{ivec2{21}}; res1.swap(res2); - CHECK(res1.get_value().get_as() == ivec2{21}); - CHECK(res2.get_value().get_as() == ivec2{42}); + CHECK(res1.get_value().as() == ivec2{21}); + CHECK(res2.get_value().as() == ivec2{42}); } { meta::uresult res1{ivec2{42}}; meta::uresult res2{meta::uerror{meta::error_code::bad_argument_cast}}; swap(res1, res2); CHECK(res1.get_error() == meta::error_code::bad_argument_cast); - CHECK(res2.get_value().get_as() == ivec2{42}); + CHECK(res2.get_value().as() == ivec2{42}); } { meta::uresult res1{meta::uerror{meta::error_code::bad_argument_cast}}; @@ -298,9 +298,9 @@ TEST_CASE("meta/meta_utilities/uresult") { static_assert(std::is_same_v().get_value())>); meta::uresult res{ivec2{42, 21}}; - CHECK(res.get_value().get_as() == ivec2{42, 21}); - CHECK(std::move(res).get_value().get_as() == ivec2{42, 21}); - CHECK(std::as_const(res).get_value().get_as() == ivec2{42, 21}); - CHECK(std::move(std::as_const(res)).get_value().get_as() == ivec2{42, 21}); + CHECK(res.get_value().as() == ivec2{42, 21}); + CHECK(std::move(res).get_value().as() == ivec2{42, 21}); + CHECK(std::as_const(res).get_value().as() == ivec2{42, 21}); + CHECK(std::move(std::as_const(res)).get_value().as() == ivec2{42, 21}); } } diff --git a/develop/untests/meta_utilities/value2_tests.cpp b/develop/untests/meta_utilities/value2_tests.cpp index 4760712..25742f5 100644 --- a/develop/untests/meta_utilities/value2_tests.cpp +++ b/develop/untests/meta_utilities/value2_tests.cpp @@ -147,7 +147,7 @@ TEST_CASE("meta/meta_utilities/value2/counters/small") { meta::uvalue v2{std::move(v1)}; CHECK_FALSE(v1); - CHECK(v2.get_as().x == 1); + CHECK(v2.as().x == 1); CHECK(ivec2::destructor_counter == 2); CHECK(ivec2::move_constructor_counter == 2); @@ -163,8 +163,8 @@ TEST_CASE("meta/meta_utilities/value2/counters/small") { meta::uvalue v1{ivec2{1,2}}; meta::uvalue v2{std::as_const(v1)}; - CHECK(v1.get_as().x == 1); - CHECK(v2.get_as().y == 2); + CHECK(v1.as().x == 1); + CHECK(v2.as().y == 2); CHECK(ivec2::destructor_counter == 1); CHECK(ivec2::move_constructor_counter == 1); @@ -184,8 +184,8 @@ TEST_CASE("meta/meta_utilities/value2/counters/small") { CHECK(ivec2::copy_constructor_counter == 0); v1.swap(v2); - CHECK(v1.get_as().x == 3); - CHECK(v2.get_as().x == 1); + CHECK(v1.as().x == 3); + CHECK(v2.as().x == 1); CHECK((ivec2::destructor_counter == 5 || ivec2::destructor_counter == 6)); CHECK((ivec2::move_constructor_counter == 5 || ivec2::move_constructor_counter == 6)); @@ -234,7 +234,7 @@ TEST_CASE("meta/meta_utilities/value2/counters/big") { meta::uvalue v2{std::move(v1)}; CHECK_FALSE(v1); - CHECK(v2.get_as().x == 1); + CHECK(v2.as().x == 1); CHECK(ivec2_big::destructor_counter == 1); CHECK(ivec2_big::move_constructor_counter == 1); @@ -250,8 +250,8 @@ TEST_CASE("meta/meta_utilities/value2/counters/big") { meta::uvalue v1{ivec2_big{1,2}}; meta::uvalue v2{std::as_const(v1)}; - CHECK(v1.get_as().x == 1); - CHECK(v2.get_as().y == 2); + CHECK(v1.as().x == 1); + CHECK(v2.as().y == 2); CHECK(ivec2_big::destructor_counter == 1); CHECK(ivec2_big::move_constructor_counter == 1); @@ -271,8 +271,8 @@ TEST_CASE("meta/meta_utilities/value2/counters/big") { CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); - CHECK(v1.get_as().x == 3); - CHECK(v2.get_as().x == 1); + CHECK(v1.as().x == 3); + CHECK(v2.as().x == 1); CHECK(ivec2_big::destructor_counter == 2); CHECK(ivec2_big::move_constructor_counter == 2); @@ -305,7 +305,7 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { CHECK(ivec2::copy_constructor_counter == 0); v1.swap(v2); - CHECK(v1.get_as().x == 1); + CHECK(v1.as().x == 1); CHECK_FALSE(v2); CHECK(ivec2::destructor_counter == 2); @@ -314,7 +314,7 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { v1.swap(v2); CHECK_FALSE(v1); - CHECK(v2.get_as().y == 2); + CHECK(v2.as().y == 2); CHECK(ivec2::destructor_counter == 3); CHECK(ivec2::move_constructor_counter == 3); @@ -336,7 +336,7 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); - CHECK(v1.get_as().x == 3); + CHECK(v1.as().x == 3); CHECK_FALSE(v2); CHECK(ivec2_big::destructor_counter == 1); @@ -345,7 +345,7 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { v1.swap(v2); CHECK_FALSE(v1); - CHECK(v2.get_as().y == 4); + CHECK(v2.as().y == 4); CHECK(ivec2_big::destructor_counter == 1); CHECK(ivec2_big::move_constructor_counter == 1); @@ -371,8 +371,8 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); - CHECK(v1.get_as().x == 3); - CHECK(v2.get_as().x == 1); + CHECK(v1.as().x == 3); + CHECK(v2.as().x == 1); CHECK(ivec2::destructor_counter == 2); CHECK(ivec2::move_constructor_counter == 2); @@ -383,8 +383,8 @@ TEST_CASE("meta/meta_utilities/value2/counters/swap") { CHECK(ivec2_big::copy_constructor_counter == 0); v1.swap(v2); - CHECK(v1.get_as().y == 2); - CHECK(v2.get_as().y == 4); + CHECK(v1.as().y == 2); + CHECK(v2.as().y == 4); CHECK(ivec2::destructor_counter == 3); CHECK(ivec2::move_constructor_counter == 3); diff --git a/develop/untests/meta_utilities/value3_tests.cpp b/develop/untests/meta_utilities/value3_tests.cpp index f4f1514..4fd9bf9 100644 --- a/develop/untests/meta_utilities/value3_tests.cpp +++ b/develop/untests/meta_utilities/value3_tests.cpp @@ -88,45 +88,45 @@ TEST_CASE("meta/meta_utilities/value3/get_type") { } } -TEST_CASE("meta/meta_utilities/value3/get_as") { +TEST_CASE("meta/meta_utilities/value3/as") { namespace meta = meta_hpp; - static_assert(std::is_same_v().get_as()), derived&>); - static_assert(std::is_same_v().get_as()), derived>); - static_assert(std::is_same_v().get_as()), const derived&>); - static_assert(std::is_same_v().get_as()), const derived&&>); + static_assert(std::is_same_v().as()), derived&>); + static_assert(std::is_same_v().as()), derived>); + static_assert(std::is_same_v().as()), const derived&>); + static_assert(std::is_same_v().as()), const derived&&>); - static_assert(std::is_same_v().get_as()), derived*>); - static_assert(std::is_same_v().get_as()), derived*>); - static_assert(std::is_same_v().get_as()), derived*>); - static_assert(std::is_same_v().get_as()), derived*>); + static_assert(std::is_same_v().as()), derived*>); + static_assert(std::is_same_v().as()), derived*>); + static_assert(std::is_same_v().as()), derived*>); + static_assert(std::is_same_v().as()), derived*>); - static_assert(std::is_same_v().get_as()), const derived*>); - static_assert(std::is_same_v().get_as()), const derived*>); - static_assert(std::is_same_v().get_as()), const derived*>); - static_assert(std::is_same_v().get_as()), const derived*>); + static_assert(std::is_same_v().as()), const derived*>); + static_assert(std::is_same_v().as()), const derived*>); + static_assert(std::is_same_v().as()), const derived*>); + static_assert(std::is_same_v().as()), const derived*>); SUBCASE("derived to derived") { { meta::uvalue v{derived{}}; - CHECK(v.get_as().l == 168); - CHECK_THROWS(std::ignore = v.get_as()); + CHECK(v.as().l == 168); + CHECK_THROWS(std::ignore = v.as()); } { const meta::uvalue v{derived{}}; - CHECK(v.get_as().l == 168); - CHECK_THROWS(std::ignore = v.get_as()); + CHECK(v.as().l == 168); + CHECK_THROWS(std::ignore = v.as()); } } SUBCASE("derived to base") { { meta::uvalue v{derived{}}; - CHECK(v.get_as().k == 84); + CHECK(v.as().k == 84); } { const meta::uvalue v{derived{}}; - CHECK(v.get_as().k == 84); + CHECK(v.as().k == 84); } } @@ -134,40 +134,40 @@ TEST_CASE("meta/meta_utilities/value3/get_as") { { derived d{}; meta::uvalue v{&d}; - CHECK(v.get_as() == &d); - CHECK(v.get_as() == &d); + CHECK(v.as() == &d); + CHECK(v.as() == &d); } { const derived d{}; meta::uvalue v{&d}; - CHECK_THROWS(std::ignore = v.get_as()); - CHECK(v.get_as() == &d); + CHECK_THROWS(std::ignore = v.as()); + CHECK(v.as() == &d); } { meta::uvalue v{derived{}}; - CHECK_THROWS(std::ignore = v.get_as()); - CHECK_THROWS(std::ignore = v.get_as()); + CHECK_THROWS(std::ignore = v.as()); + CHECK_THROWS(std::ignore = v.as()); } } SUBCASE("nullptr") { { meta::uvalue v{nullptr}; - CHECK(v.get_as() == nullptr); - CHECK(v.get_as() == nullptr); - CHECK(v.get_as() == nullptr); - CHECK(v.get_as() == nullptr); + CHECK(v.as() == nullptr); + CHECK(v.as() == nullptr); + CHECK(v.as() == nullptr); + CHECK(v.as() == nullptr); - CHECK_THROWS(std::ignore = v.get_as()); + CHECK_THROWS(std::ignore = v.as()); } { const meta::uvalue v{nullptr}; - CHECK(v.get_as() == nullptr); - CHECK(v.get_as() == nullptr); - CHECK(v.get_as() == nullptr); - CHECK(v.get_as() == nullptr); + CHECK(v.as() == nullptr); + CHECK(v.as() == nullptr); + CHECK(v.as() == nullptr); + CHECK(v.as() == nullptr); - CHECK_THROWS(std::ignore = v.get_as()); + CHECK_THROWS(std::ignore = v.as()); } } @@ -175,18 +175,18 @@ TEST_CASE("meta/meta_utilities/value3/get_as") { { derived d{}; meta::uvalue v{&d}; - CHECK(v.get_as()->l == 168); - CHECK(v.get_as()->l == 168); + CHECK(v.as()->l == 168); + CHECK(v.as()->l == 168); - CHECK_THROWS(std::ignore = v.get_as()); - CHECK_THROWS(std::ignore = v.get_as()); + CHECK_THROWS(std::ignore = v.as()); + CHECK_THROWS(std::ignore = v.as()); } { const derived d{}; meta::uvalue v{&d}; - CHECK(v.get_as()->l == 168); + CHECK(v.as()->l == 168); - CHECK_THROWS(std::ignore = v.get_as()); + CHECK_THROWS(std::ignore = v.as()); } } @@ -194,58 +194,58 @@ TEST_CASE("meta/meta_utilities/value3/get_as") { { derived d{}; meta::uvalue v{&d}; - CHECK(v.get_as()->k == 84); - CHECK(v.get_as()->k == 84); + CHECK(v.as()->k == 84); + CHECK(v.as()->k == 84); } { const derived d{}; meta::uvalue v{&d}; - CHECK_THROWS(std::ignore = v.get_as()); - CHECK(v.get_as()->k == 84); + CHECK_THROWS(std::ignore = v.as()); + CHECK(v.as()->k == 84); } } } -TEST_CASE("meta/meta_utilities/value3/try_get_as") { +TEST_CASE("meta/meta_utilities/value3/try_as") { namespace meta = meta_hpp; - static_assert(std::is_same_v().try_get_as()), derived*>); - static_assert(std::is_same_v().try_get_as()), derived*>); - static_assert(std::is_same_v().try_get_as()), const derived*>); - static_assert(std::is_same_v().try_get_as()), const derived*>); + static_assert(std::is_same_v().try_as()), derived*>); + static_assert(std::is_same_v().try_as()), derived*>); + static_assert(std::is_same_v().try_as()), const derived*>); + static_assert(std::is_same_v().try_as()), const derived*>); - static_assert(std::is_same_v().try_get_as()), derived*>); - static_assert(std::is_same_v().try_get_as()), derived*>); - static_assert(std::is_same_v().try_get_as()), derived*>); - static_assert(std::is_same_v().try_get_as()), derived*>); + static_assert(std::is_same_v().try_as()), derived*>); + static_assert(std::is_same_v().try_as()), derived*>); + static_assert(std::is_same_v().try_as()), derived*>); + static_assert(std::is_same_v().try_as()), derived*>); - static_assert(std::is_same_v().try_get_as()), const derived*>); - static_assert(std::is_same_v().try_get_as()), const derived*>); - static_assert(std::is_same_v().try_get_as()), const derived*>); - static_assert(std::is_same_v().try_get_as()), const derived*>); + static_assert(std::is_same_v().try_as()), const derived*>); + static_assert(std::is_same_v().try_as()), const derived*>); + static_assert(std::is_same_v().try_as()), const derived*>); + static_assert(std::is_same_v().try_as()), const derived*>); SUBCASE("derived to derived") { { meta::uvalue v{derived{}}; - CHECK(v.try_get_as()->l == 168); - CHECK_FALSE(v.try_get_as()); + CHECK(v.try_as()->l == 168); + CHECK_FALSE(v.try_as()); } { const meta::uvalue v{derived{}}; - CHECK(v.try_get_as()->l == 168); - CHECK_FALSE(v.try_get_as()); + CHECK(v.try_as()->l == 168); + CHECK_FALSE(v.try_as()); } } SUBCASE("derived to base") { { meta::uvalue v{derived{}}; - CHECK(v.try_get_as()->k == 84); + CHECK(v.try_as()->k == 84); } { const meta::uvalue v{derived{}}; - CHECK(v.try_get_as()->k == 84); + CHECK(v.try_as()->k == 84); } } @@ -253,40 +253,40 @@ TEST_CASE("meta/meta_utilities/value3/try_get_as") { { derived d{}; meta::uvalue v{&d}; - CHECK(v.try_get_as() == &d); - CHECK(v.try_get_as() == &d); + CHECK(v.try_as() == &d); + CHECK(v.try_as() == &d); } { const derived d{}; meta::uvalue v{&d}; - CHECK_FALSE(v.try_get_as()); - CHECK(v.try_get_as() == &d); + CHECK_FALSE(v.try_as()); + CHECK(v.try_as() == &d); } { meta::uvalue v{derived{}}; - CHECK_FALSE(v.try_get_as()); - CHECK_FALSE(v.try_get_as()); + CHECK_FALSE(v.try_as()); + CHECK_FALSE(v.try_as()); } } SUBCASE("nullptr") { { meta::uvalue v{nullptr}; - CHECK(v.try_get_as() == nullptr); - CHECK(v.try_get_as() == nullptr); - CHECK(v.try_get_as() == nullptr); - CHECK(v.try_get_as() == nullptr); + CHECK(v.try_as() == nullptr); + CHECK(v.try_as() == nullptr); + CHECK(v.try_as() == nullptr); + CHECK(v.try_as() == nullptr); - CHECK_FALSE(v.try_get_as()); + CHECK_FALSE(v.try_as()); } { const meta::uvalue v{nullptr}; - CHECK(v.try_get_as() == nullptr); - CHECK(v.try_get_as() == nullptr); - CHECK(v.try_get_as() == nullptr); - CHECK(v.try_get_as() == nullptr); + CHECK(v.try_as() == nullptr); + CHECK(v.try_as() == nullptr); + CHECK(v.try_as() == nullptr); + CHECK(v.try_as() == nullptr); - CHECK_FALSE(v.try_get_as()); + CHECK_FALSE(v.try_as()); } } @@ -294,18 +294,18 @@ TEST_CASE("meta/meta_utilities/value3/try_get_as") { { derived d{}; meta::uvalue v{&d}; - CHECK(v.try_get_as()->l == 168); - CHECK(v.try_get_as()->l == 168); + CHECK(v.try_as()->l == 168); + CHECK(v.try_as()->l == 168); - CHECK_FALSE(v.try_get_as()); - CHECK_FALSE(v.try_get_as()); + CHECK_FALSE(v.try_as()); + CHECK_FALSE(v.try_as()); } { const derived d{}; meta::uvalue v{&d}; - CHECK(v.try_get_as()->l == 168); + CHECK(v.try_as()->l == 168); - CHECK_FALSE(v.try_get_as()); + CHECK_FALSE(v.try_as()); } } @@ -313,15 +313,15 @@ TEST_CASE("meta/meta_utilities/value3/try_get_as") { { derived d{}; meta::uvalue v{&d}; - CHECK(v.try_get_as()->k == 84); - CHECK(v.try_get_as()->k == 84); + CHECK(v.try_as()->k == 84); + CHECK(v.try_as()->k == 84); } { const derived d{}; meta::uvalue v{&d}; - CHECK_FALSE(v.try_get_as()); - CHECK(v.try_get_as()->k == 84); + CHECK_FALSE(v.try_as()); + CHECK(v.try_as()->k == 84); } } } diff --git a/develop/untests/meta_utilities/value4_tests.cpp b/develop/untests/meta_utilities/value4_tests.cpp index 4e0f8b3..de04a1a 100644 --- a/develop/untests/meta_utilities/value4_tests.cpp +++ b/develop/untests/meta_utilities/value4_tests.cpp @@ -60,7 +60,7 @@ TEST_CASE("meta/meta_utilities/value4/throw_dtor") { meta::uvalue v{clazz_throw_dtor{42}}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 42); + CHECK(v.as().i == 42); } SUBCASE("ptr_deref") { @@ -68,11 +68,11 @@ TEST_CASE("meta/meta_utilities/value4/throw_dtor") { meta::uvalue v_ptr{&obj}; CHECK(v_ptr.get_type() == meta::resolve_type()); - CHECK(v_ptr.get_as() == &obj); + CHECK(v_ptr.as() == &obj); meta::uvalue v = *v_ptr; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 42); + CHECK(v.as().i == 42); } SUBCASE("array_index") { @@ -80,11 +80,11 @@ TEST_CASE("meta/meta_utilities/value4/throw_dtor") { meta::uvalue v_ptr{objs}; CHECK(v_ptr.get_type() == meta::resolve_type()); - CHECK(v_ptr.get_as() == objs); + CHECK(v_ptr.as() == objs); meta::uvalue v = v_ptr[1]; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 21); + CHECK(v.as().i == 21); } SUBCASE("as_return_value") { @@ -93,7 +93,7 @@ TEST_CASE("meta/meta_utilities/value4/throw_dtor") { meta::uvalue v{clazz_throw_dtor_make_function(42)}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 42); + CHECK(v.as().i == 42); } } @@ -108,7 +108,7 @@ TEST_CASE("meta/meta_utilities/value4/inplace") { SUBCASE("def") { meta::uvalue v = meta::make_uvalue(); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 0); + CHECK(v.as().i == 0); CHECK(clazz_throw_dtor::destructor_counter == 0); CHECK(clazz_throw_dtor::constructor_counter == 1); @@ -121,10 +121,10 @@ TEST_CASE("meta/meta_utilities/value4/inplace") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v[0].get_type() == meta::resolve_type()); - CHECK(v[0].get_as().i == 42); + CHECK(v[0].as().i == 42); CHECK(v[1].get_type() == meta::resolve_type()); - CHECK(v[1].get_as().i == 42); + CHECK(v[1].as().i == 42); } SUBCASE("args/counters") { @@ -143,10 +143,10 @@ TEST_CASE("meta/meta_utilities/value4/inplace") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v[0].get_type() == meta::resolve_type()); - CHECK(v[0].get_as() == 21); + CHECK(v[0].as() == 21); CHECK(v[1].get_type() == meta::resolve_type()); - CHECK(v[1].get_as() == 42); + CHECK(v[1].as() == 42); } SUBCASE("ilist/2") { @@ -154,10 +154,10 @@ TEST_CASE("meta/meta_utilities/value4/inplace") { CHECK(v.get_type() == meta::resolve_type>>()); CHECK(v[0].get_type() == meta::resolve_type()); - CHECK(v[0].get_as() == 21); + CHECK(v[0].as() == 21); CHECK(v[1].get_type() == meta::resolve_type()); - CHECK(v[1].get_as() == 42); + CHECK(v[1].as() == 42); } SUBCASE("ilist/counters") { @@ -187,7 +187,7 @@ TEST_CASE("meta/meta_utilities/value4/emplace") { meta::uvalue v = meta::make_uvalue(21); CHECK(v.emplace().i == 0); CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as().i == 0); + CHECK(v.as().i == 0); } CHECK(clazz_throw_dtor::destructor_counter == 2); CHECK(clazz_throw_dtor::constructor_counter == 2); @@ -201,10 +201,10 @@ TEST_CASE("meta/meta_utilities/value4/emplace") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v[0].get_type() == meta::resolve_type()); - CHECK(v[0].get_as().i == 42); + CHECK(v[0].as().i == 42); CHECK(v[1].get_type() == meta::resolve_type()); - CHECK(v[1].get_as().i == 42); + CHECK(v[1].as().i == 42); } SUBCASE("args/counters") { @@ -225,10 +225,10 @@ TEST_CASE("meta/meta_utilities/value4/emplace") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v[0].get_type() == meta::resolve_type()); - CHECK(v[0].get_as() == 21); + CHECK(v[0].as() == 21); CHECK(v[1].get_type() == meta::resolve_type()); - CHECK(v[1].get_as() == 42); + CHECK(v[1].as() == 42); } SUBCASE("ilist/2") { @@ -237,10 +237,10 @@ TEST_CASE("meta/meta_utilities/value4/emplace") { CHECK(v.get_type() == meta::resolve_type>>()); CHECK(v[0].get_type() == meta::resolve_type()); - CHECK(v[0].get_as() == 21); + CHECK(v[0].as() == 21); CHECK(v[1].get_type() == meta::resolve_type()); - CHECK(v[1].get_as() == 42); + CHECK(v[1].as() == 42); } SUBCASE("ilist/counters") { diff --git a/develop/untests/meta_utilities/value_tests.cpp b/develop/untests/meta_utilities/value_tests.cpp index 7a12fe8..0f0c3eb 100644 --- a/develop/untests/meta_utilities/value_tests.cpp +++ b/develop/untests/meta_utilities/value_tests.cpp @@ -141,16 +141,16 @@ TEST_CASE("meta/meta_utilities/value") { SUBCASE("cast types") { static_assert(std::is_same_v< - decltype(std::declval().get_as()), + decltype(std::declval().as()), ivec2&>); static_assert(std::is_same_v< - decltype(std::declval().get_as()), + decltype(std::declval().as()), ivec2>); static_assert(std::is_same_v< - decltype(std::declval().get_as()), + decltype(std::declval().as()), const ivec2&>); static_assert(std::is_same_v< - decltype(std::declval().get_as()), + decltype(std::declval().as()), const ivec2&&>); } @@ -169,13 +169,13 @@ TEST_CASE("meta/meta_utilities/value") { CHECK_FALSE(*val); CHECK_FALSE(val[0]); - CHECK_FALSE(val.try_get_as()); - CHECK_FALSE(std::as_const(val).try_get_as()); + CHECK_FALSE(val.try_as()); + CHECK_FALSE(std::as_const(val).try_as()); - CHECK_THROWS(std::ignore = val.get_as()); - CHECK_THROWS(std::ignore = std::as_const(val).get_as()); - CHECK_THROWS(std::ignore = std::move(val).get_as()); - CHECK_THROWS(std::ignore = std::move(std::as_const(val)).get_as()); + CHECK_THROWS(std::ignore = val.as()); + CHECK_THROWS(std::ignore = std::as_const(val).as()); + CHECK_THROWS(std::ignore = std::move(val).as()); + CHECK_THROWS(std::ignore = std::move(std::as_const(val)).as()); } CHECK_FALSE(meta::uvalue{}.get_type()); @@ -196,29 +196,29 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(*static_cast(std::as_const(val).get_data()) == vr); CHECK(*static_cast(std::as_const(val).get_cdata()) == vr); - CHECK(val.get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); { meta::uvalue val_copy{val}; - CHECK(std::move(val_copy).get_as() == ivec2{1,2}); + CHECK(std::move(val_copy).as() == ivec2{1,2}); } { meta::uvalue val_copy{val}; - CHECK(std::move(std::as_const(val_copy)).get_as() == ivec2{1,2}); + CHECK(std::move(std::as_const(val_copy)).as() == ivec2{1,2}); } - CHECK_THROWS(std::ignore = val.get_as()); - CHECK_THROWS(std::ignore = std::as_const(val).get_as()); - CHECK_THROWS(std::ignore = std::move(val).get_as()); - CHECK_THROWS(std::ignore = std::move(std::as_const(val)).get_as()); + CHECK_THROWS(std::ignore = val.as()); + CHECK_THROWS(std::ignore = std::as_const(val).as()); + CHECK_THROWS(std::ignore = std::move(val).as()); + CHECK_THROWS(std::ignore = std::move(std::as_const(val)).as()); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); - CHECK_FALSE(val.try_get_as()); - CHECK_FALSE(std::as_const(val).try_get_as()); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); + CHECK_FALSE(val.try_as()); + CHECK_FALSE(std::as_const(val).try_as()); } SUBCASE("const ivec2&") { @@ -236,29 +236,29 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(*static_cast(std::as_const(val).get_data()) == vr); CHECK(*static_cast(std::as_const(val).get_cdata()) == vr); - CHECK(val.get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); { meta::uvalue val_copy{val}; - CHECK(std::move(val_copy).get_as() == ivec2{1,2}); + CHECK(std::move(val_copy).as() == ivec2{1,2}); } { meta::uvalue val_copy{val}; - CHECK(std::move(std::as_const(val_copy)).get_as() == ivec2{1,2}); + CHECK(std::move(std::as_const(val_copy)).as() == ivec2{1,2}); } - CHECK_THROWS(std::ignore = val.get_as()); - CHECK_THROWS(std::ignore = std::as_const(val).get_as()); - CHECK_THROWS(std::ignore = std::move(val).get_as()); - CHECK_THROWS(std::ignore = std::move(std::as_const(val)).get_as()); + CHECK_THROWS(std::ignore = val.as()); + CHECK_THROWS(std::ignore = std::as_const(val).as()); + CHECK_THROWS(std::ignore = std::move(val).as()); + CHECK_THROWS(std::ignore = std::move(std::as_const(val)).as()); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); - CHECK_FALSE(val.try_get_as()); - CHECK_FALSE(std::as_const(val).try_get_as()); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); + CHECK_FALSE(val.try_as()); + CHECK_FALSE(std::as_const(val).try_as()); } SUBCASE("ivec2&&") { @@ -270,29 +270,29 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(val.get_type() == meta::resolve_type()); - CHECK(val.get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); { meta::uvalue val_copy{val}; - CHECK(std::move(val_copy).get_as() == ivec2{1,2}); + CHECK(std::move(val_copy).as() == ivec2{1,2}); } { meta::uvalue val_copy{val}; - CHECK(std::move(std::as_const(val_copy)).get_as() == ivec2{1,2}); + CHECK(std::move(std::as_const(val_copy)).as() == ivec2{1,2}); } - CHECK_THROWS(std::ignore = val.get_as()); - CHECK_THROWS(std::ignore = std::as_const(val).get_as()); - CHECK_THROWS(std::ignore = std::move(val).get_as()); - CHECK_THROWS(std::ignore = std::move(std::as_const(val)).get_as()); + CHECK_THROWS(std::ignore = val.as()); + CHECK_THROWS(std::ignore = std::as_const(val).as()); + CHECK_THROWS(std::ignore = std::move(val).as()); + CHECK_THROWS(std::ignore = std::move(std::as_const(val)).as()); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); - CHECK_FALSE(val.try_get_as()); - CHECK_FALSE(std::as_const(val).try_get_as()); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); + CHECK_FALSE(val.try_as()); + CHECK_FALSE(std::as_const(val).try_as()); } SUBCASE("const ivec2&&") { @@ -304,29 +304,29 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(val.get_type() == meta::resolve_type()); - CHECK(val.get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); { meta::uvalue val_copy{val}; - CHECK(std::move(val_copy).get_as() == ivec2{1,2}); + CHECK(std::move(val_copy).as() == ivec2{1,2}); } { meta::uvalue val_copy{val}; - CHECK(std::move(std::as_const(val_copy)).get_as() == ivec2{1,2}); + CHECK(std::move(std::as_const(val_copy)).as() == ivec2{1,2}); } - CHECK_THROWS(std::ignore = val.get_as()); - CHECK_THROWS(std::ignore = std::as_const(val).get_as()); - CHECK_THROWS(std::ignore = std::move(val).get_as()); - CHECK_THROWS(std::ignore = std::move(std::as_const(val)).get_as()); + CHECK_THROWS(std::ignore = val.as()); + CHECK_THROWS(std::ignore = std::as_const(val).as()); + CHECK_THROWS(std::ignore = std::move(val).as()); + CHECK_THROWS(std::ignore = std::move(std::as_const(val)).as()); - CHECK(val.get_as() == ivec2{1,2}); - CHECK(std::as_const(val).get_as() == ivec2{1,2}); - CHECK_FALSE(val.try_get_as()); - CHECK_FALSE(std::as_const(val).try_get_as()); + CHECK(val.as() == ivec2{1,2}); + CHECK(std::as_const(val).as() == ivec2{1,2}); + CHECK_FALSE(val.try_as()); + CHECK_FALSE(std::as_const(val).try_as()); } SUBCASE("value(value&&)") { @@ -336,7 +336,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(ivec2::copy_constructor_counter == 0); meta::uvalue val_dst{std::move(val_src)}; - CHECK(val_dst.get_as() == ivec2{1,2}); + CHECK(val_dst.as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 2); CHECK(ivec2::copy_constructor_counter == 0); } @@ -348,11 +348,11 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(ivec2::copy_constructor_counter == 1); meta::uvalue val_dst{val_src}; - CHECK(val_dst.get_as() == ivec2{1,2}); + CHECK(val_dst.as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 0); CHECK(ivec2::copy_constructor_counter == 2); - CHECK(val_src.get_as() == ivec2{1,2}); + CHECK(val_src.as() == ivec2{1,2}); CHECK(val_src.get_data() != val_dst.get_data()); } @@ -360,10 +360,10 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val{10}; val = 20; - CHECK(val.get_as() == 20); + CHECK(val.as() == 20); val = "hello"s; - CHECK(val.get_as() == "hello"s); + CHECK(val.as() == "hello"s); } SUBCASE("value& operator=(value&&)") { @@ -375,12 +375,12 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val_dst{"hello"s}; val_dst = std::move(val_src1); - CHECK(val_dst.get_as() == "world"s); + CHECK(val_dst.as() == "world"s); CHECK(ivec2::move_constructor_counter == 1); CHECK(ivec2::copy_constructor_counter == 0); val_dst = std::move(val_src2); - CHECK(val_dst.get_as() == ivec2{1,2}); + CHECK(val_dst.as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 2); CHECK(ivec2::copy_constructor_counter == 0); } @@ -394,16 +394,16 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val_dst{"hello"s}; val_dst = val_src1; - CHECK(val_dst.get_as() == "world"s); + CHECK(val_dst.as() == "world"s); CHECK(ivec2::move_constructor_counter == 1); CHECK(ivec2::copy_constructor_counter == 0); val_dst = val_src2; - CHECK(val_dst.get_as() == ivec2{1,2}); + CHECK(val_dst.as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 1); CHECK(ivec2::copy_constructor_counter == 1); - CHECK(val_src2.get_as() == ivec2{1,2}); + CHECK(val_src2.as() == ivec2{1,2}); CHECK(val_src2.get_data() != val_dst.get_data()); } @@ -414,14 +414,14 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(ivec2::copy_constructor_counter == 0); val1.swap(val2); - CHECK(val1.get_as() == ivec2{1,2}); - CHECK(val2.get_as() == "world"s); + CHECK(val1.as() == ivec2{1,2}); + CHECK(val2.as() == "world"s); CHECK(ivec2::move_constructor_counter == 2); CHECK(ivec2::copy_constructor_counter == 0); swap(val1, val2); - CHECK(val1.get_as() == "world"s); - CHECK(val2.get_as() == ivec2{1,2}); + CHECK(val1.as() == "world"s); + CHECK(val2.as() == ivec2{1,2}); } SUBCASE("swap/1") { @@ -430,10 +430,10 @@ TEST_CASE("meta/meta_utilities/value") { swap(val1, val2); CHECK_FALSE(val1); - CHECK(val2.get_as() == 42); + CHECK(val2.as() == 42); swap(val1, val2); - CHECK(val1.get_as() == 42); + CHECK(val1.as() == 42); CHECK_FALSE(val2); } @@ -445,12 +445,12 @@ TEST_CASE("meta/meta_utilities/value") { swap(val1, val2); CHECK_FALSE(val1); - CHECK(val2.get_as() == ivec2{1,2}); + CHECK(val2.as() == ivec2{1,2}); CHECK(ivec2::move_constructor_counter == 2); CHECK(ivec2::copy_constructor_counter == 0); swap(val1, val2); - CHECK(val1.get_as() == ivec2{1,2}); + CHECK(val1.as() == ivec2{1,2}); CHECK_FALSE(val2); CHECK(ivec2::move_constructor_counter == 3); CHECK(ivec2::copy_constructor_counter == 0); @@ -464,12 +464,12 @@ TEST_CASE("meta/meta_utilities/value") { swap(val1, val2); CHECK_FALSE(val1); - CHECK(val2.get_as() == ivec2_big{1,2}); + CHECK(val2.as() == ivec2_big{1,2}); CHECK(ivec2_big::move_constructor_counter == 1); CHECK(ivec2_big::copy_constructor_counter == 0); swap(val1, val2); - CHECK(val1.get_as() == ivec2_big{1,2}); + CHECK(val1.as() == ivec2_big{1,2}); CHECK_FALSE(val2); CHECK(ivec2_big::move_constructor_counter == 1); CHECK(ivec2_big::copy_constructor_counter == 0); @@ -481,11 +481,11 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val2{std::move(val1)}; CHECK_FALSE(val1); - CHECK(val2.get_as() == 42); + CHECK(val2.as() == 42); val1 = std::move(val2); CHECK_FALSE(val2); - CHECK(val1.get_as() == 42); + CHECK(val1.as() == 42); } { meta::uvalue val1{ivec2{1,2}}; @@ -493,11 +493,11 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val2{std::move(val1)}; CHECK_FALSE(val1); CHECK(val2); - CHECK(val2.get_as() == ivec2{1,2}); + CHECK(val2.as() == ivec2{1,2}); val1 = std::move(val2); CHECK_FALSE(val2); - CHECK(val1.get_as() == ivec2{1,2}); + CHECK(val1.as() == ivec2{1,2}); } { meta::uvalue val1{ivec2_big{1,2}}; @@ -505,11 +505,11 @@ TEST_CASE("meta/meta_utilities/value") { meta::uvalue val2{std::move(val1)}; CHECK_FALSE(val1); CHECK(val2); - CHECK(val2.get_as() == ivec2_big{1,2}); + CHECK(val2.as() == ivec2_big{1,2}); val1 = std::move(val2); CHECK_FALSE(val2); - CHECK(val1.get_as() == ivec2_big{1,2}); + CHECK(val1.as() == ivec2_big{1,2}); } } @@ -526,7 +526,7 @@ TEST_CASE("meta/meta_utilities/value") { const meta::uvalue v{u.unmap()}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as() == &i); + CHECK(v.as() == &i); } { const int i{42}; @@ -535,7 +535,7 @@ TEST_CASE("meta/meta_utilities/value") { const meta::uvalue v{u.unmap()}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as() == &i); + CHECK(v.as() == &i); } { const auto i = std::make_shared(3, 4); @@ -544,7 +544,7 @@ TEST_CASE("meta/meta_utilities/value") { const meta::uvalue v{u.unmap()}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as() == i.get()); + CHECK(v.as() == i.get()); } { const auto i = std::make_shared(3, 4); @@ -553,7 +553,7 @@ TEST_CASE("meta/meta_utilities/value") { const meta::uvalue v{u.unmap()}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as() == i.get()); + CHECK(v.as() == i.get()); } } @@ -564,7 +564,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(u.has_deref_op()); const meta::uvalue v{*u}; - CHECK(v.get_as() == i); + CHECK(v.as() == i); } { const char i{42}; @@ -572,7 +572,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(u.has_deref_op()); const meta::uvalue v{*u}; - CHECK(v.get_as() == i); + CHECK(v.as() == i); } { const int i{42}; @@ -581,7 +581,7 @@ TEST_CASE("meta/meta_utilities/value") { CHECK(u.has_deref_op()); const meta::uvalue v{*u}; - CHECK(v.get_as() == pi); + CHECK(v.as() == pi); } { int i{42}; @@ -631,7 +631,7 @@ TEST_CASE("meta/meta_utilities/value") { } { meta::uvalue v{std::make_shared(42)}; - CHECK((*v).get_as() == 42); + CHECK((*v).as() == 42); } } } @@ -671,9 +671,9 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v.get_type() == meta::resolve_type()); CHECK(v.has_index_op()); - CHECK(v[0].get_as() == 1); - CHECK(v[1].get_as() == 2); - CHECK(v[2].get_as() == 3); + CHECK(v[0].as() == 1); + CHECK(v[1].as() == 2); + CHECK(v[2].as() == 3); } { int* arr = nullptr; @@ -692,9 +692,9 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v.get_type() == meta::resolve_type()); CHECK(v.has_index_op()); - CHECK(v[0].get_as() == 1); - CHECK(v[1].get_as() == 2); - CHECK(v[2].get_as() == 3); + CHECK(v[0].as() == 1); + CHECK(v[1].as() == 2); + CHECK(v[2].as() == 3); } { const int* arr = nullptr; @@ -711,9 +711,9 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v.has_index_op()); - CHECK(v[0].get_as() == 1); - CHECK(v[1].get_as() == 2); - CHECK(v[2].get_as() == 3); + CHECK(v[0].as() == 1); + CHECK(v[1].as() == 2); + CHECK(v[2].as() == 3); CHECK_FALSE(v[3]); } @@ -722,9 +722,9 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v.has_index_op()); - CHECK(v[0].get_as() == 1); - CHECK(v[1].get_as() == 2); - CHECK(v[2].get_as() == 3); + CHECK(v[0].as() == 1); + CHECK(v[1].as() == 2); + CHECK(v[2].as() == 3); CHECK_FALSE(v[3]); } @@ -733,9 +733,9 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v.get_type() == meta::resolve_type()); CHECK(v.has_index_op()); - CHECK(v[0].get_as() == 'h'); - CHECK(v[1].get_as() == 'i'); - CHECK(v[2].get_as() == '!'); + CHECK(v[0].as() == 'h'); + CHECK(v[1].as() == 'i'); + CHECK(v[2].as() == '!'); CHECK_FALSE(v[3]); } @@ -745,9 +745,9 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v.has_index_op()); - CHECK(v[0].get_as() == 1); - CHECK(v[1].get_as() == 2); - CHECK(v[2].get_as() == 3); + CHECK(v[0].as() == 1); + CHECK(v[1].as() == 2); + CHECK(v[2].as() == 3); CHECK_FALSE(v[3]); } @@ -756,9 +756,9 @@ TEST_CASE("meta/meta_utilities/value/arrays") { CHECK(v.get_type() == meta::resolve_type>()); CHECK(v.has_index_op()); - CHECK(v[0].get_as() == 1); - CHECK(v[1].get_as() == 2); - CHECK(v[2].get_as() == 3); + CHECK(v[0].as() == 1); + CHECK(v[1].as() == 2); + CHECK(v[2].as() == 3); CHECK_FALSE(v[3]); } } @@ -770,14 +770,14 @@ TEST_CASE("meta/meta_utilities/value/functions") { { meta::uvalue v{&ivec2::add}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as() == &ivec2::add); - CHECK((ivec2{1,2}.*(v.get_as()))(ivec2{3,4}) == ivec2(4,6)); + CHECK(v.as() == &ivec2::add); + CHECK((ivec2{1,2}.*(v.as()))(ivec2{3,4}) == ivec2(4,6)); } { const meta::uvalue v{&ivec2::add}; CHECK(v.get_type() == meta::resolve_type()); - CHECK(v.get_as() == &ivec2::add); - CHECK((ivec2{1,2}.*(v.get_as()))(ivec2{3,4}) == ivec2(4,6)); + CHECK(v.as() == &ivec2::add); + CHECK((ivec2{1,2}.*(v.as()))(ivec2{3,4}) == ivec2(4,6)); } } @@ -785,26 +785,26 @@ TEST_CASE("meta/meta_utilities/value/functions") { { meta::uvalue v{iadd2}; CHECK(v.get_type() == meta::resolve_type()); - CHECK((v.get_as() == &iadd2)); - CHECK((v.get_as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); + CHECK((v.as() == &iadd2)); + CHECK((v.as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); } { meta::uvalue v{&iadd2}; CHECK(v.get_type() == meta::resolve_type()); - CHECK((v.get_as() == &iadd2)); - CHECK((v.get_as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); + CHECK((v.as() == &iadd2)); + CHECK((v.as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); } { const meta::uvalue v{iadd2}; CHECK(v.get_type() == meta::resolve_type()); - CHECK((v.get_as() == &iadd2)); - CHECK((v.get_as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); + CHECK((v.as() == &iadd2)); + CHECK((v.as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); } { const meta::uvalue v{&iadd2}; CHECK(v.get_type() == meta::resolve_type()); - CHECK((v.get_as() == &iadd2)); - CHECK((v.get_as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); + CHECK((v.as() == &iadd2)); + CHECK((v.as())(ivec2{1,2}, ivec2{3,4}) == ivec2{4,6}); } } } diff --git a/headers/meta.hpp/meta_base/exceptions.hpp b/headers/meta.hpp/meta_base/exceptions.hpp index 0e3f1aa..9b134fa 100644 --- a/headers/meta.hpp/meta_base/exceptions.hpp +++ b/headers/meta.hpp/meta_base/exceptions.hpp @@ -25,9 +25,7 @@ namespace meta_hpp::detail bad_const_access, bad_uvalue_access, - bad_uresult_access, - bad_uvalue_cast, bad_argument_cast, bad_instance_cast, @@ -44,10 +42,6 @@ namespace meta_hpp::detail return "bad const access"; case error_code::bad_uvalue_access: return "bad uvalue access"; - case error_code::bad_uresult_access: - return "bad uresult access"; - case error_code::bad_uvalue_cast: - return "bad uvalue cast"; case error_code::bad_argument_cast: return "bad argument cast"; case error_code::bad_instance_cast: diff --git a/headers/meta.hpp/meta_states.hpp b/headers/meta.hpp/meta_states.hpp index eabbf77..71d9c9b 100644 --- a/headers/meta.hpp/meta_states.hpp +++ b/headers/meta.hpp/meta_states.hpp @@ -269,9 +269,6 @@ namespace meta_hpp template < typename Instance > [[nodiscard]] uresult try_get(Instance&& instance) const; - template < typename T, typename Instance > - [[nodiscard]] T get_as(Instance&& instance) const; - template < typename Instance > [[nodiscard]] uvalue operator()(Instance&& instance) const; diff --git a/headers/meta.hpp/meta_types/enum_type.hpp b/headers/meta.hpp/meta_types/enum_type.hpp index 56a3126..4fe0d2e 100644 --- a/headers/meta.hpp/meta_types/enum_type.hpp +++ b/headers/meta.hpp/meta_types/enum_type.hpp @@ -57,7 +57,7 @@ namespace meta_hpp } for ( const evalue& evalue : data_->evalues ) { - if ( evalue.get_value().get_as() == value ) { + if ( evalue.get_value().as() == value ) { return evalue.get_name(); } } diff --git a/headers/meta.hpp/meta_uvalue.hpp b/headers/meta.hpp/meta_uvalue.hpp index 28765ba..b585b86 100644 --- a/headers/meta.hpp/meta_uvalue.hpp +++ b/headers/meta.hpp/meta_uvalue.hpp @@ -81,26 +81,26 @@ namespace meta_hpp [[nodiscard]] bool has_unmap_op() const noexcept; template < typename T > - [[nodiscard]] T get_as() &&; + [[nodiscard]] T as() &&; template < typename T > - [[nodiscard]] auto get_as() & // + [[nodiscard]] auto as() & // -> std::conditional_t, T, T&>; template < typename T > - [[nodiscard]] auto get_as() const& // + [[nodiscard]] auto as() const& // -> std::conditional_t, T, const T&>; template < typename T > - [[nodiscard]] auto get_as() const&& // + [[nodiscard]] auto as() const&& // -> std::conditional_t, T, const T&&>; template < typename T > - [[nodiscard]] auto try_get_as() noexcept // + [[nodiscard]] auto try_as() noexcept // -> std::conditional_t, T, T*>; template < typename T > - [[nodiscard]] auto try_get_as() const noexcept // + [[nodiscard]] auto try_as() const noexcept // -> std::conditional_t, T, const T*>; private: diff --git a/headers/meta.hpp/meta_uvalue/uvalue.hpp b/headers/meta.hpp/meta_uvalue/uvalue.hpp index 5d2441a..95bcbff 100644 --- a/headers/meta.hpp/meta_uvalue/uvalue.hpp +++ b/headers/meta.hpp/meta_uvalue/uvalue.hpp @@ -433,76 +433,76 @@ namespace meta_hpp } template < typename T > - T uvalue::get_as() && { + T uvalue::as() && { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( T* ptr = try_get_as() ) { + if ( T* ptr = try_as() ) { return std::move(*ptr); } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > - auto uvalue::get_as() & -> std::conditional_t, T, T&> { + auto uvalue::as() & -> std::conditional_t, T, T&> { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( T* ptr = try_get_as() ) { + if ( T* ptr = try_as() ) { return *ptr; } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > - auto uvalue::get_as() const& -> std::conditional_t, T, const T&> { + auto uvalue::as() const& -> std::conditional_t, T, const T&> { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( const T* ptr = try_get_as() ) { + if ( const T* ptr = try_as() ) { return *ptr; } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > - auto uvalue::get_as() const&& -> std::conditional_t, T, const T&&> { + auto uvalue::as() const&& -> std::conditional_t, T, const T&&> { static_assert(std::is_same_v>); if constexpr ( detail::pointer_kind ) { - if ( T ptr = try_get_as(); ptr || get_type().is_nullptr() ) { + if ( T ptr = try_as(); ptr || get_type().is_nullptr() ) { return ptr; } } else { - if ( const T* ptr = try_get_as() ) { + if ( const T* ptr = try_as() ) { return std::move(*ptr); } } - throw_exception(error_code::bad_uvalue_cast); + throw_exception(error_code::bad_uvalue_access); } template < typename T > // NOLINTNEXTLINE(*-cognitive-complexity) - auto uvalue::try_get_as() noexcept -> std::conditional_t, T, T*> { + auto uvalue::try_as() noexcept -> std::conditional_t, T, T*> { static_assert(std::is_same_v>); using detail::type_registry; @@ -570,7 +570,7 @@ namespace meta_hpp template < typename T > // NOLINTNEXTLINE(*-cognitive-complexity) - auto uvalue::try_get_as() const noexcept -> std::conditional_t, T, const T*> { + auto uvalue::try_as() const noexcept -> std::conditional_t, T, const T*> { static_assert(std::is_same_v>); using detail::type_registry;