diff --git a/headers/meta.hpp/meta_registry.hpp b/headers/meta.hpp/meta_registry.hpp index 3ba376e..c0c7bdc 100644 --- a/headers/meta.hpp/meta_registry.hpp +++ b/headers/meta.hpp/meta_registry.hpp @@ -55,20 +55,6 @@ namespace meta_hpp return registry.resolve_type(); } } - - template < typename... Ts > - [[nodiscard]] any_type_list resolve_types() { - using namespace detail; - type_registry& registry = type_registry::instance(); - return {registry.resolve_type>()...}; - } - - template < typename... Ts > - [[nodiscard]] any_type_list resolve_types(type_list) { - using namespace detail; - type_registry& registry = type_registry::instance(); - return {registry.resolve_type>()...}; - } } namespace meta_hpp diff --git a/headers/meta.hpp/meta_types/constructor_type.hpp b/headers/meta.hpp/meta_types/constructor_type.hpp index b92ccf5..ff1f371 100644 --- a/headers/meta.hpp/meta_types/constructor_type.hpp +++ b/headers/meta.hpp/meta_types/constructor_type.hpp @@ -12,6 +12,27 @@ #include "../meta_detail/type_traits/constructor_traits.hpp" +namespace meta_hpp::detail::constructor_type_data_impl +{ + template < class_kind Class, typename... Args > + any_type_list make_argument_types() { + using ct = constructor_traits; + using ct_argument_types = typename ct::argument_types; + + return [](std::index_sequence) { + any_type_list argument_types; + argument_types.reserve(type_list_arity_v); + + [[maybe_unused]] const auto make_argument_type = [](index_constant) { + return resolve_type>(); + }; + + (argument_types.emplace_back(make_argument_type(index_constant{})), ...); + return argument_types; + }(std::make_index_sequence>()); + } +} + namespace meta_hpp::detail { template < class_kind Class, typename... Args > @@ -19,7 +40,7 @@ namespace meta_hpp::detail : type_data_base{type_kind::constructor_} , flags{constructor_traits::make_flags()} , owner_type{resolve_type::class_type>()} - , argument_types{resolve_types(typename constructor_traits::argument_types{})} {} + , argument_types{constructor_type_data_impl::make_argument_types()} {} } namespace meta_hpp diff --git a/headers/meta.hpp/meta_types/function_type.hpp b/headers/meta.hpp/meta_types/function_type.hpp index 57113bd..bc15e0e 100644 --- a/headers/meta.hpp/meta_types/function_type.hpp +++ b/headers/meta.hpp/meta_types/function_type.hpp @@ -12,6 +12,27 @@ #include "../meta_detail/type_traits/function_traits.hpp" +namespace meta_hpp::detail::function_type_data_impl +{ + template < function_kind Function > + any_type_list make_argument_types() { + using ft = function_traits; + using ft_argument_types = typename ft::argument_types; + + return [](std::index_sequence) { + any_type_list argument_types; + argument_types.reserve(type_list_arity_v); + + [[maybe_unused]] const auto make_argument_type = [](index_constant) { + return resolve_type>(); + }; + + (argument_types.emplace_back(make_argument_type(index_constant{})), ...); + return argument_types; + }(std::make_index_sequence>()); + } +} + namespace meta_hpp::detail { template < function_kind Function > @@ -19,7 +40,7 @@ namespace meta_hpp::detail : type_data_base{type_kind::function_} , flags{function_traits::make_flags()} , return_type{resolve_type::return_type>()} - , argument_types{resolve_types(typename function_traits::argument_types{})} {} + , argument_types{function_type_data_impl::make_argument_types()} {} } namespace meta_hpp diff --git a/headers/meta.hpp/meta_types/method_type.hpp b/headers/meta.hpp/meta_types/method_type.hpp index fcc0eb4..c7153fd 100644 --- a/headers/meta.hpp/meta_types/method_type.hpp +++ b/headers/meta.hpp/meta_types/method_type.hpp @@ -12,6 +12,27 @@ #include "../meta_detail/type_traits/method_traits.hpp" +namespace meta_hpp::detail::method_type_data_impl +{ + template < method_pointer_kind Method > + any_type_list make_argument_types() { + using mt = method_traits; + using mt_argument_types = typename mt::argument_types; + + return [](std::index_sequence) { + any_type_list argument_types; + argument_types.reserve(type_list_arity_v); + + [[maybe_unused]] const auto make_argument_type = [](index_constant) { + return resolve_type>(); + }; + + (argument_types.emplace_back(make_argument_type(index_constant{})), ...); + return argument_types; + }(std::make_index_sequence>()); + } +} + namespace meta_hpp::detail { template < method_pointer_kind Method > @@ -20,7 +41,7 @@ namespace meta_hpp::detail , flags{method_traits::make_flags()} , owner_type{resolve_type::class_type>()} , return_type{resolve_type::return_type>()} - , argument_types{resolve_types(typename method_traits::argument_types{})} {} + , argument_types{method_type_data_impl::make_argument_types()} {} } namespace meta_hpp