How to loop through a boost::mpl::list?

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2010-05-15T15:28:43Z Indexed on 2010/05/15 15:34 UTC
Read the original article Hit count: 419

This is as far as I've gotten,

#include <boost/mpl/list.hpp>
#include <algorithm>
namespace mpl = boost::mpl;

class RunAround {};
class HopUpAndDown {};
class Sleep {};

template<typename Instructions> int doThis();
template<> int doThis<RunAround>()    { /* run run run.. */ return 3; }
template<> int doThis<HopUpAndDown>() { /* hop hop hop.. */ return 2; }
template<> int doThis<Sleep>()        { /* zzz.. */ return -2; }


int main()
{
    typedef mpl::list<RunAround, HopUpAndDown, Sleep> acts;

//  std::for_each(mpl::begin<acts>::type, mpl::end<acts>::type, doThis<????>);

    return 0;
};

How do I complete this? (I don't know if I should be using std::for_each, just a guess based on another answer here)

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost-mpl