1
4

1 回答 1

3

没有 ostream 插入器phoenix::arg_names::_1。不过,我们可以轻松地添加一个。这用 clang++ (trunk) 为我编译:

#include <iostream>
#include <boost/phoenix.hpp>

namespace proto   = boost::proto;
namespace fusion  = boost::fusion;
namespace phoenix = boost::phoenix;

struct display
{
  template<typename T>
  void operator()(T const &t) const
  {
    std::cout << t << std::endl;
  }
};

namespace boost { namespace phoenix
{
  template<int N>
  std::ostream& operator<<(std::ostream& sout, argument<N> const& arg)
  {
    return sout << "_" << N;
  }
}}

int main()
{
  fusion::for_each(
    fusion::transform(
      proto::flatten(phoenix::arg_names::_1 + 2 + 3 + 4)
    , proto::functional::value()
    )
  , display()
  );
}
于 2013-03-05T04:52:37.170 回答