Boost.Phoenix V3 - 2つ以上の式を書く

カンマ演算子で、複数の式が書けます。

#include <vector>
#include <boost/range/algorithm/for_each.hpp>
#include <boost/phoenix.hpp>

int main()
{
    using boost::phoenix::arg_names::_1;
    namespace phx = boost::phoenix;

    const std::vector<int> v = {1, 2, 3};

    int sum = 0;
    boost::for_each(v, (
        phx::ref(sum) += _1,
        std::cout << _1 << std::endl
    ));

    std::cout << sum << std::endl;
}
1
2
3
6