mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 11:40:35 +07:00
fix github issue #15
This commit is contained in:
@@ -44,7 +44,11 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to call a function with incorrect argument types");
|
||||
}
|
||||
|
||||
if constexpr ( as_void ) {
|
||||
if constexpr ( std::is_void_v<return_type> ) {
|
||||
function(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else if constexpr ( stdex::same_as<Policy, function_policy::discard_return> ) {
|
||||
std::ignore = function(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
|
||||
@@ -50,9 +50,12 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to call a method with incorrect argument types");
|
||||
}
|
||||
|
||||
if constexpr ( as_void ) {
|
||||
if constexpr ( std::is_void_v<return_type> ) {
|
||||
(inst.cast<qualified_type>().*method)(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else if constexpr ( stdex::same_as<Policy, method_policy::discard_return> ) {
|
||||
std::ignore = (inst.cast<qualified_type>().*method)(
|
||||
inst.cast<qualified_type>(),
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else {
|
||||
|
||||
@@ -5624,7 +5624,11 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to call a function with incorrect argument types");
|
||||
}
|
||||
|
||||
if constexpr ( as_void ) {
|
||||
if constexpr ( std::is_void_v<return_type> ) {
|
||||
function(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else if constexpr ( stdex::same_as<Policy, function_policy::discard_return> ) {
|
||||
std::ignore = function(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
@@ -6364,9 +6368,12 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to call a method with incorrect argument types");
|
||||
}
|
||||
|
||||
if constexpr ( as_void ) {
|
||||
if constexpr ( std::is_void_v<return_type> ) {
|
||||
(inst.cast<qualified_type>().*method)(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else if constexpr ( stdex::same_as<Policy, method_policy::discard_return> ) {
|
||||
std::ignore = (inst.cast<qualified_type>().*method)(
|
||||
inst.cast<qualified_type>(),
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else {
|
||||
|
||||
38
untests/meta_issues/github_issue_15.cpp
Normal file
38
untests/meta_issues/github_issue_15.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include "../meta_untests.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
class rect {
|
||||
public:
|
||||
void get_width(int* v) {
|
||||
*v = 42;
|
||||
}
|
||||
|
||||
static void get_width_static(int* v) {
|
||||
*v = 84;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_issues/15") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
meta::class_<rect>()
|
||||
.method_("get_width", &rect::get_width)
|
||||
.function_("get_width_static", &rect::get_width_static);
|
||||
|
||||
int v{};
|
||||
rect r{};
|
||||
|
||||
meta::resolve_type(r).get_method("get_width").invoke(r, &v);
|
||||
CHECK(v == 42);
|
||||
|
||||
meta::resolve_type(r).get_function("get_width_static").invoke(&v);
|
||||
CHECK(v == 84);
|
||||
}
|
||||
Reference in New Issue
Block a user