mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 11:40:35 +07:00
fix examples
This commit is contained in:
@@ -49,7 +49,7 @@ namespace meta_hpp::detail
|
||||
std::ignore = std::invoke(
|
||||
std::move(function),
|
||||
(args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return {};
|
||||
return value{};
|
||||
} else {
|
||||
return_type&& return_value = std::invoke(
|
||||
std::move(function),
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace meta_hpp::detail
|
||||
std::move(method),
|
||||
inst.cast<qualified_type>(),
|
||||
(args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return {};
|
||||
return value{};
|
||||
} else {
|
||||
return_type&& return_value = std::invoke(
|
||||
std::move(method),
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace meta_hpp
|
||||
return ctor.second.invoke(std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
return value{};
|
||||
}
|
||||
|
||||
template < typename... Args >
|
||||
|
||||
@@ -71,7 +71,7 @@ TEST_CASE("meta/meta_examples/classes/usage") {
|
||||
const meta::method rectangle_area = rectangle_type.get_method("get_area");
|
||||
|
||||
// creates a rectangle instance by the registered constructor(int, int)
|
||||
const meta::value rectangle_v = rectangle_type.create(10, 20).value();
|
||||
const meta::value rectangle_v = rectangle_type.create(10, 20);
|
||||
|
||||
// calls the method with the dynamic rectangle instance 'rectangle_v'
|
||||
CHECK(rectangle_area.invoke(rectangle_v) == 200);
|
||||
|
||||
@@ -49,11 +49,11 @@ TEST_CASE("meta/meta_examples/enums/usage") {
|
||||
const meta::enum_type align_type = meta::resolve_type(e);
|
||||
|
||||
// converts the enumerator to its name
|
||||
CHECK(align_type.value_to_name(e).value() == "center");
|
||||
CHECK(align_type.value_to_name(e) == "center");
|
||||
|
||||
// also, it works with dynamic value types
|
||||
CHECK(align_type.value_to_name(meta::value{e}).value() == "center");
|
||||
CHECK(align_type.value_to_name(meta::value{e}) == "center");
|
||||
|
||||
// ... and back again
|
||||
CHECK(align_type.name_to_value("center").value() == e);
|
||||
CHECK(align_type.name_to_value("center") == e);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ TEST_CASE("meta/meta_examples/functions/usage") {
|
||||
CHECK(sub_function.is_invocable_with<int, int>());
|
||||
|
||||
// calls the function and retrieves a returned value
|
||||
const meta::value sub_result_value = sub_function.invoke(60, 18).value();
|
||||
const meta::value sub_result_value = sub_function.invoke(60, 18);
|
||||
|
||||
// checks the type of the returned value
|
||||
CHECK(sub_result_value.get_type() == meta::resolve_type<int>());
|
||||
|
||||
@@ -69,7 +69,7 @@ TEST_CASE("meta/meta_examples/methods/usage") {
|
||||
CHECK(ivec2_add.is_invocable_with<ivec2&, ivec2>());
|
||||
|
||||
// calls the method and retrieves a returned value
|
||||
const meta::value ivec2_add_result_value = ivec2_add.invoke(v, ivec2{22, 11}).value();
|
||||
const meta::value ivec2_add_result_value = ivec2_add.invoke(v, ivec2{22, 11});
|
||||
|
||||
// checks the type and value of the result
|
||||
CHECK(ivec2_add_result_value.get_type() == meta::resolve_type<ivec2>());
|
||||
|
||||
Reference in New Issue
Block a user