Skip to content
Snippets Groups Projects
Commit cf8f91eb authored by Jan Travnicek's avatar Jan Travnicek Committed by Jan Trávníček
Browse files

use constexpr_switch elsewhere

parent e1800140
No related branches found
No related tags found
No related merge requests found
...@@ -50,33 +50,29 @@ struct CheckInput { ...@@ -50,33 +50,29 @@ struct CheckInput {
}; };
   
template < class ... Params > template < class ... Params >
struct ParamType; struct ParamType {
static ext::type_index paramType ( unsigned index ) {
ext::type_index res ( typeid ( void ) );
   
template < > auto lambda = [ & ] ( auto I ) {
struct ParamType < > { res = ext::type_index ( typeid ( std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > ) );
static ext::type_index paramType ( unsigned ) { };
throw std::logic_error ( "Out of types to check" );
}
   
static ext::set < abstraction::ParamQualifiers::ParamQualifier > paramTypeQualifiers ( unsigned ) { ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda );
throw std::logic_error ( "Out of types to check" );
}
};
   
template < class Param, class ... Params > return res;
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 );
} }
   
static ext::set < abstraction::ParamQualifiers::ParamQualifier > paramTypeQualifiers ( unsigned index ) { static ext::set < abstraction::ParamQualifiers::ParamQualifier > paramTypeQualifiers ( unsigned index ) {
if ( index == 0 ) ext::set < abstraction::ParamQualifiers::ParamQualifier > res;
return abstraction::ParamQualifiers::paramQualifiers < Param > ( );
else auto lambda = [ & ] ( auto I ) {
return ParamType < Params ... >::paramTypeQualifiers ( index - 1 ); res = abstraction::ParamQualifiers::paramQualifiers < std::tuple_element_t < decltype ( I )::value, std::tuple < Params ... > > > ( );
};
ext::constexpr_switch < sizeof ... ( Params ) > ( index, lambda );
return res;
} }
}; };
   
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment