Чисто из любви к искусству вопрос: можно ли напрямую забайндить boost::fusion::for_each без вспомогательного функтора?
#include <string>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/fusion/include/for_each.hpp>
struct func
{
template< typename T, typename S >
void operator()( T const& t, S const& s ) const
{
std::cout << "[ (" << typeid(t).name() << ") " << t
<< ", (" << typeid(s).name() << ") " << s << " ]\n";
}
};
struct tuple_for_each
{
template< typename T, typename S, typename F >
void operator()( T const& t, S const& s, F f ) const
{
boost::fusion::for_each( t, boost::bind<void>(f, s, _1) );
}
};
template< typename T1, typename T2, typename F >
void cartesian_product( T1 const& t1, T2 const& t2, F f )
{
boost::fusion::for_each( t1, boost::bind<void>( tuple_for_each(), t2, _1, f ) );
}
int main()
{
cartesian_product( boost::make_tuple(1, 2.0, 3L, "s"), boost::make_tuple(11, 12.0, 13), func() );
}