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

前端 未结 1 1523
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 09:41

This is as far as I\'ve gotten,

#include 
#include 
namespace mpl = boost::mpl;

class RunAround {};
class HopUpAn         


        
相关标签:
1条回答
  • 2021-01-02 10:39

    Use mpl::for_each for runtime iteration over type lists. E.g.:

    struct do_this_wrapper {
        template<typename U> void operator()(U) {
            doThis<U>();
        }
    };
    
    int main() {
        typedef boost::mpl::list<RunAround, HopUpAndDown, Sleep> acts;
        boost::mpl::for_each<acts>(do_this_wrapper());    
    };
    
    0 讨论(0)
提交回复
热议问题