return types for meta_func are no longer ambiguous (close #274)

This commit is contained in:
Michele Caini
2019-07-06 00:10:37 +02:00
parent 260b9a8d0d
commit e3ac292af1
2 changed files with 6 additions and 2 deletions

View File

@@ -2269,6 +2269,7 @@ invoke(const meta_handle &, meta_any *args, std::index_sequence<Indexes...>) {
{
if constexpr(std::is_void_v<typename helper_type::return_type>) {
std::invoke(Func, (args+Indexes)->cast<typename helper_type::template arg_type<Indexes>>()...);
any.emplace<void>();
} else {
any = meta_any{std::invoke(Func, (args+Indexes)->cast<typename helper_type::template arg_type<Indexes>>()...)};
}
@@ -2291,6 +2292,7 @@ invoke(meta_handle &handle, meta_any *args, std::index_sequence<Indexes...>) {
{
if constexpr(std::is_void_v<typename helper_type::return_type>) {
std::invoke(Member, clazz, (args+Indexes)->cast<typename helper_type::template arg_type<Indexes>>()...);
any.emplace<void>();
} else {
any = meta_any{std::invoke(Member, clazz, (args+Indexes)->cast<typename helper_type::template arg_type<Indexes>>()...)};
}

View File

@@ -1373,7 +1373,8 @@ TEST_F(Meta, MetaFuncRetVoid) {
auto any = func.invoke(instance, 5);
ASSERT_FALSE(any);
ASSERT_TRUE(any);
ASSERT_TRUE(any.can_cast<void>());
ASSERT_EQ(func_type::value, 25);
func.prop([](auto prop) {
@@ -1442,7 +1443,8 @@ TEST_F(Meta, MetaFuncStaticRetVoid) {
auto any = func.invoke({}, 42);
ASSERT_FALSE(any);
ASSERT_TRUE(any);
ASSERT_TRUE(any.can_cast<void>());
ASSERT_EQ(func_type::value, 42);
func.prop([](auto *prop) {