diff --git a/alib2abstraction/src/common/AbstractionHelpers.hpp b/alib2abstraction/src/common/AbstractionHelpers.hpp index 4a86d5dec003c2c4f393a3fe1eea3d84b26f4611..f4e84c11bb18b9a5e2b2a64d6a995f9f9fa84ccf 100644 --- a/alib2abstraction/src/common/AbstractionHelpers.hpp +++ b/alib2abstraction/src/common/AbstractionHelpers.hpp @@ -50,33 +50,29 @@ struct CheckInput { }; template < class ... Params > -struct ParamType; +struct ParamType { + static ext::type_index paramType ( unsigned index ) { + ext::type_index res ( typeid ( void ) ); -template < > -struct ParamType < > { - static ext::type_index paramType ( unsigned ) { - throw std::logic_error ( "Out of types to check" ); - } + auto lambda = [ & ] ( auto I ) { + res = ext::type_index ( typeid ( std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > ) ); + }; - static ext::set < abstraction::ParamQualifiers::ParamQualifier > paramTypeQualifiers ( unsigned ) { - throw std::logic_error ( "Out of types to check" ); - } -}; + ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); -template < class Param, class ... Params > -struct ParamType < Param, Params ... > { - static ext::type_index paramType ( unsigned index ) { - if ( index == 0 ) - return ext::type_index ( typeid ( Param ) ); - else - return ParamType < Params ... >::paramType ( index - 1 ); + return res; } static ext::set < abstraction::ParamQualifiers::ParamQualifier > paramTypeQualifiers ( unsigned index ) { - if ( index == 0 ) - return abstraction::ParamQualifiers::paramQualifiers < Param > ( ); - else - return ParamType < Params ... >::paramTypeQualifiers ( index - 1 ); + ext::set < abstraction::ParamQualifiers::ParamQualifier > res; + + auto lambda = [ & ] ( auto I ) { + res = abstraction::ParamQualifiers::paramQualifiers < std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > > ( ); + }; + + ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda ); + + return res; } };