9
To jest tak daleko, jak stałam,Jak uruchomić pętlę boost :: mpl :: list?
#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;
};
Jak mogę zakończyć tego? (Nie wiem, czy powinienem używać std :: for_each, tylko odgadnąć na podstawie innej odpowiedzi tutaj)
Dzięki - czy można to zrobić za pomocą metody boost :: bind zamiast obiektu opakowania? – Kyle
@Kyle: Nie sądzę - nie jestem świadomy żadnej użyteczności w Boost.Bind, która generuje wymagane funktory z szablonem 'operator()'. –
@GeorgFritzsche: Czy istnieje sposób na zrobienie 'do_this_wrapper' a lambda (jak w C++ 11/14/17)? –