mpl::foldでproductメタ関数

#include <boost/static_assert.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/multiplies.hpp>

using namespace boost::mpl;

template <class Seq>
struct product {
    static const int value = fold<Seq, int_<1>, multiplies<_1, _2> >::type::value;
};

int main()
{
    typedef list_c<int, 1, 2, 3> ls;

    BOOST_STATIC_ASSERT(product<ls>::value == 6);
        // 1 * 1 * 2 * 3
}