
Zitat von Alexander Lamaison
template
void dispatch(int id,mpl::true_ endofvec){} template
void dispatch(int id,mpl::false_){ if(id == mpl::deref<It>::type::value){ ... }else{ typedef typename mpl::next<It>::type Next; dispatch (id,typename is_same ::type()); } } call with mpl::begin<YourVec> and mpl::end<YourVec> as template arguments
Thanks! This does exactly what I want. Just out of interest, how would Boost.Fusion help here. I had a look at its algorithms but they seem to require an instantiated sequence. For instance the signature of find() is:
template< typename T, typename Sequence > unspecified find(Sequence& seq);
I need the result of my search to be a type rather than a value. The Fusion examples seem to return values.
there is no difference between type and value with MPL sequences. e.g. the element type of a vector_c is mpl::int_<5>, which evaluates to 5. MPL sequences are empty objects, so they can be instantiated. but you're right that fusion::find(_if) doesn't seem to be suitable for your case, as it doesn't take a (runtime) functor, only a (compiletime) predicate. but I've used fusion::fold before with MPL sequences.