get_as<T> for variable and member

This commit is contained in:
BlackMATov
2023-01-12 10:16:26 +07:00
parent 1ebd2e75ed
commit 5a54ea9bac
8 changed files with 58 additions and 19 deletions

View File

@@ -80,8 +80,8 @@ TEST_CASE("meta/meta_examples/scopes/local") {
const meta::variable unit3_variable = math_scope.get_variable("unit3");
// checks and uses found variables with functions
CHECK(unit2_variable.get().get_as<ivec2>() == ivec2{1,1});
CHECK(unit3_variable.get().get_as<ivec3>() == ivec3{1,1,1});
CHECK(unit2_variable.get_as<ivec2>() == ivec2{1,1});
CHECK(unit3_variable.get_as<ivec3>() == ivec3{1,1,1});
CHECK(dot2_function(unit2_variable.get(), unit2_variable.get()).get_as<int>() == 2);
CHECK(dot3_function(unit3_variable.get(), unit3_variable.get()).get_as<int>() == 3);
}

View File

@@ -44,6 +44,6 @@ TEST_CASE("meta/meta_examples/variable/usage") {
// prints all variables in the scope
std::cout << "* " << constants_scope.get_name() << std::endl;
for ( auto&& [index, variable] : constants_scope.get_variables() ) {
std::cout << " - " << index.get_name() << ":" << variable.get().get_as<double>() << std::endl;
std::cout << " - " << index.get_name() << ":" << variable.get_as<double>() << std::endl;
}
}