
On Sun, 16 May 2010 09:07:53 +0200, strasser@uni-bremen.de wrote:
Zitat von Alexander Lamaison
: I'm trying to recursively traverse an MPL vector_c but I'm not sure what the base-case type should be.
if you encounter this type of thing regularily, you might want to have a look at Boost.Fusion, which has runtime algorithms that can also be used on Boost.MPL sequences. however, using function templates is much simpler than the dispatch class specialization you attempted above:
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. Many thanks. Alex