mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-16 14:09:02 +07:00
style fixes
This commit is contained in:
@@ -7,6 +7,7 @@ Checks: '-*,
|
|||||||
|
|
||||||
cppcoreguidelines-*,
|
cppcoreguidelines-*,
|
||||||
-cppcoreguidelines-macro-usage,
|
-cppcoreguidelines-macro-usage,
|
||||||
|
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
|
||||||
|
|
||||||
modernize-*,
|
modernize-*,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
|
|||||||
2
TODO.md
2
TODO.md
@@ -1,6 +1,8 @@
|
|||||||
# meta.hpp
|
# meta.hpp
|
||||||
|
|
||||||
- metadata
|
- metadata
|
||||||
|
- add policy tests
|
||||||
|
- rebind types support
|
||||||
|
|
||||||
* argument defaults
|
* argument defaults
|
||||||
* argument names
|
* argument names
|
||||||
|
|||||||
@@ -25,14 +25,14 @@ namespace meta_hpp::detail
|
|||||||
template < stdex::copy_constructible T >
|
template < stdex::copy_constructible T >
|
||||||
struct index_traits<T*> {
|
struct index_traits<T*> {
|
||||||
value operator()(T* v, std::size_t i) const {
|
value operator()(T* v, std::size_t i) const {
|
||||||
return value{*(v + i)};
|
return value{v[i]};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template < stdex::copy_constructible T >
|
template < stdex::copy_constructible T >
|
||||||
struct index_traits<const T*> {
|
struct index_traits<const T*> {
|
||||||
value operator()(const T* v, std::size_t i) const {
|
value operator()(const T* v, std::size_t i) const {
|
||||||
return value{*(v + i)};
|
return value{v[i]};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,22 +40,22 @@ namespace meta_hpp::detail
|
|||||||
args
|
args
|
||||||
// NOLINTNEXTLINE(readability-named-parameter)
|
// NOLINTNEXTLINE(readability-named-parameter)
|
||||||
]<std::size_t... Is>(std::index_sequence<Is...>) -> value {
|
]<std::size_t... Is>(std::index_sequence<Is...>) -> value {
|
||||||
if ( !(... && (args.data() + Is)->can_cast_to<type_list_at_t<Is, argument_types>>()) ) {
|
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");
|
throw_exception_with("an attempt to call a constructor with incorrect argument types");
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr ( as_object ) {
|
if constexpr ( as_object ) {
|
||||||
class_type return_value{(args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...};
|
class_type return_value{args[Is].cast<type_list_at_t<Is, argument_types>>()...};
|
||||||
return value{std::move(return_value)};
|
return value{std::move(return_value)};
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr ( as_raw_ptr ) {
|
if constexpr ( as_raw_ptr ) {
|
||||||
auto return_value{std::make_unique<class_type>((args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...)};
|
auto return_value{std::make_unique<class_type>(args[Is].cast<type_list_at_t<Is, argument_types>>()...)};
|
||||||
return value{return_value.release()};
|
return value{return_value.release()};
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr ( as_shared_ptr ) {
|
if constexpr ( as_shared_ptr ) {
|
||||||
auto return_value{std::make_shared<class_type>((args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...)};
|
auto return_value{std::make_shared<class_type>(args[Is].cast<type_list_at_t<Is, argument_types>>()...)};
|
||||||
return value{std::move(return_value)};
|
return value{std::move(return_value)};
|
||||||
}
|
}
|
||||||
}, std::make_index_sequence<ct::arity>());
|
}, std::make_index_sequence<ct::arity>());
|
||||||
@@ -72,7 +72,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
// NOLINTNEXTLINE(readability-named-parameter)
|
// NOLINTNEXTLINE(readability-named-parameter)
|
||||||
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||||
return (... && (args.data() + Is)->can_cast_to<type_list_at_t<Is, argument_types>>());
|
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>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,19 +42,19 @@ namespace meta_hpp::detail
|
|||||||
&function, args
|
&function, args
|
||||||
// NOLINTNEXTLINE(readability-named-parameter)
|
// NOLINTNEXTLINE(readability-named-parameter)
|
||||||
]<std::size_t... Is>(std::index_sequence<Is...>) -> value {
|
]<std::size_t... Is>(std::index_sequence<Is...>) -> value {
|
||||||
if ( !(... && (args.data() + Is)->can_cast_to<type_list_at_t<Is, argument_types>>()) ) {
|
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");
|
throw_exception_with("an attempt to call a function with incorrect argument types");
|
||||||
}
|
}
|
||||||
|
|
||||||
if constexpr ( as_void ) {
|
if constexpr ( as_void ) {
|
||||||
std::ignore = std::invoke(
|
std::ignore = std::invoke(
|
||||||
function,
|
function,
|
||||||
(args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...);
|
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||||
return value{};
|
return value{};
|
||||||
} else {
|
} else {
|
||||||
return_type&& return_value = std::invoke(
|
return_type&& return_value = std::invoke(
|
||||||
function,
|
function,
|
||||||
(args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...);
|
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||||
|
|
||||||
if constexpr ( ref_as_ptr ) {
|
if constexpr ( ref_as_ptr ) {
|
||||||
return value{std::addressof(return_value)};
|
return value{std::addressof(return_value)};
|
||||||
@@ -76,7 +76,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
// NOLINTNEXTLINE(readability-named-parameter)
|
// NOLINTNEXTLINE(readability-named-parameter)
|
||||||
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||||
return (... && (args.data() + Is)->can_cast_to<type_list_at_t<Is, argument_types>>());
|
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>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace meta_hpp::detail
|
|||||||
&method, &inst, args
|
&method, &inst, args
|
||||||
// NOLINTNEXTLINE(readability-named-parameter)
|
// NOLINTNEXTLINE(readability-named-parameter)
|
||||||
]<std::size_t... Is>(std::index_sequence<Is...>) -> value {
|
]<std::size_t... Is>(std::index_sequence<Is...>) -> value {
|
||||||
if ( !(... && (args.data() + Is)->can_cast_to<type_list_at_t<Is, argument_types>>()) ) {
|
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");
|
throw_exception_with("an attempt to call a method with incorrect argument types");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,13 +56,13 @@ namespace meta_hpp::detail
|
|||||||
std::ignore = std::invoke(
|
std::ignore = std::invoke(
|
||||||
method,
|
method,
|
||||||
inst.cast<qualified_type>(),
|
inst.cast<qualified_type>(),
|
||||||
(args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...);
|
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||||
return value{};
|
return value{};
|
||||||
} else {
|
} else {
|
||||||
return_type&& return_value = std::invoke(
|
return_type&& return_value = std::invoke(
|
||||||
method,
|
method,
|
||||||
inst.cast<qualified_type>(),
|
inst.cast<qualified_type>(),
|
||||||
(args.data() + Is)->cast<type_list_at_t<Is, argument_types>>()...);
|
args[Is].cast<type_list_at_t<Is, argument_types>>()...);
|
||||||
|
|
||||||
if constexpr ( ref_as_ptr ) {
|
if constexpr ( ref_as_ptr ) {
|
||||||
return value{std::addressof(return_value)};
|
return value{std::addressof(return_value)};
|
||||||
@@ -89,7 +89,7 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
// NOLINTNEXTLINE(readability-named-parameter)
|
// NOLINTNEXTLINE(readability-named-parameter)
|
||||||
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
return std::invoke([args]<std::size_t... Is>(std::index_sequence<Is...>){
|
||||||
return (... && (args.data() + Is)->can_cast_to<type_list_at_t<Is, argument_types>>());
|
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