mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 19:41:29 +07:00
remove all unnecessary std::invoke calls
This commit is contained in:
@@ -36,10 +36,8 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to call a constructor with an incorrect arity");
|
||||
}
|
||||
|
||||
return std::invoke([
|
||||
args
|
||||
// NOLINTNEXTLINE(readability-named-parameter)
|
||||
]<std::size_t... Is>(std::index_sequence<Is...>) -> uvalue {
|
||||
return [args]<std::size_t... Is>(std::index_sequence<Is...>) -> uvalue {
|
||||
if ( !(... && args[Is].can_cast_to<type_list_at_t<Is, argument_types>>()) ) {
|
||||
throw_exception_with("an attempt to call a constructor with incorrect argument types");
|
||||
}
|
||||
@@ -58,7 +56,7 @@ namespace meta_hpp::detail
|
||||
auto return_value{std::make_shared<class_type>(args[Is].cast<type_list_at_t<Is, argument_types>>()...)};
|
||||
return uvalue{std::move(return_value)};
|
||||
}
|
||||
}, std::make_index_sequence<ct::arity>());
|
||||
}(std::make_index_sequence<ct::arity>());
|
||||
}
|
||||
|
||||
template < class_kind Class, typename... Args >
|
||||
@@ -71,9 +69,9 @@ namespace meta_hpp::detail
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-named-parameter)
|
||||
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||
return [args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||
return (... && args[Is].can_cast_to<type_list_at_t<Is, argument_types>>());
|
||||
}, std::make_index_sequence<ct::arity>());
|
||||
}(std::make_index_sequence<ct::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,22 +38,18 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to call a function with an incorrect arity");
|
||||
}
|
||||
|
||||
return std::invoke([
|
||||
&function, args
|
||||
// NOLINTNEXTLINE(readability-named-parameter)
|
||||
]<std::size_t... Is>(std::index_sequence<Is...>) -> uvalue {
|
||||
return [&function, args]<std::size_t... Is>(std::index_sequence<Is...>) -> uvalue {
|
||||
if ( !(... && args[Is].can_cast_to<type_list_at_t<Is, argument_types>>()) ) {
|
||||
throw_exception_with("an attempt to call a function with incorrect argument types");
|
||||
}
|
||||
|
||||
if constexpr ( as_void ) {
|
||||
std::ignore = std::invoke(
|
||||
function,
|
||||
std::ignore = function(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else {
|
||||
return_type&& return_value = std::invoke(
|
||||
function,
|
||||
return_type&& return_value = function(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
|
||||
if constexpr ( ref_as_ptr ) {
|
||||
@@ -62,7 +58,7 @@ namespace meta_hpp::detail
|
||||
return uvalue{std::forward<decltype(return_value)>(return_value)};
|
||||
}
|
||||
}
|
||||
}, std::make_index_sequence<ft::arity>());
|
||||
}(std::make_index_sequence<ft::arity>());
|
||||
}
|
||||
|
||||
template < function_kind Function >
|
||||
@@ -75,9 +71,9 @@ namespace meta_hpp::detail
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-named-parameter)
|
||||
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||
return [args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||
return (... && args[Is].can_cast_to<type_list_at_t<Is, argument_types>>());
|
||||
}, std::make_index_sequence<ft::arity>());
|
||||
}(std::make_index_sequence<ft::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace meta_hpp::detail
|
||||
}
|
||||
|
||||
if ( inst.is_const() ) {
|
||||
auto&& return_value = std::invoke(member, inst.cast<const class_type>());
|
||||
auto&& return_value = inst.cast<const class_type>().*member;
|
||||
|
||||
if constexpr ( as_copy ) {
|
||||
return uvalue{std::forward<decltype(return_value)>(return_value)};
|
||||
@@ -52,7 +52,7 @@ namespace meta_hpp::detail
|
||||
return uvalue{std::ref(return_value)};
|
||||
}
|
||||
} else {
|
||||
auto&& return_value = std::invoke(member, inst.cast<class_type>());
|
||||
auto&& return_value = inst.cast<class_type>().*member;
|
||||
|
||||
if constexpr ( as_copy ) {
|
||||
return uvalue{std::forward<decltype(return_value)>(return_value)};
|
||||
@@ -100,7 +100,7 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to set a member with an incorrect argument type");
|
||||
}
|
||||
|
||||
std::invoke(member, inst.cast<class_type>()) = arg.cast<value_type>();
|
||||
inst.cast<class_type>().*member = arg.cast<value_type>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,24 +44,19 @@ namespace meta_hpp::detail
|
||||
throw_exception_with("an attempt to call a method with an incorrect instance type");
|
||||
}
|
||||
|
||||
return std::invoke([
|
||||
&method, &inst, args
|
||||
// NOLINTNEXTLINE(readability-named-parameter)
|
||||
]<std::size_t... Is>(std::index_sequence<Is...>) -> uvalue {
|
||||
return [&method, &inst, args]<std::size_t... Is>(std::index_sequence<Is...>) -> uvalue {
|
||||
if ( !(... && args[Is].can_cast_to<type_list_at_t<Is, argument_types>>()) ) {
|
||||
throw_exception_with("an attempt to call a method with incorrect argument types");
|
||||
}
|
||||
|
||||
if constexpr ( as_void ) {
|
||||
std::ignore = std::invoke(
|
||||
method,
|
||||
std::ignore = (inst.cast<qualified_type>().*method)(
|
||||
inst.cast<qualified_type>(),
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
return uvalue{};
|
||||
} else {
|
||||
return_type&& return_value = std::invoke(
|
||||
method,
|
||||
inst.cast<qualified_type>(),
|
||||
return_type&& return_value = (inst.cast<qualified_type>().*method)(
|
||||
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||
|
||||
if constexpr ( ref_as_ptr ) {
|
||||
@@ -70,7 +65,7 @@ namespace meta_hpp::detail
|
||||
return uvalue{std::forward<decltype(return_value)>(return_value)};
|
||||
}
|
||||
}
|
||||
}, std::make_index_sequence<mt::arity>());
|
||||
}(std::make_index_sequence<mt::arity>());
|
||||
}
|
||||
|
||||
template < method_kind Method >
|
||||
@@ -88,9 +83,9 @@ namespace meta_hpp::detail
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(readability-named-parameter)
|
||||
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||
return [args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||
return (... && args[Is].can_cast_to<type_list_at_t<Is, argument_types>>());
|
||||
}, std::make_index_sequence<mt::arity>());
|
||||
}(std::make_index_sequence<mt::arity>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user