这是Phoenix v3的错误。它与凤凰v2编译就好了。 我做了错误报告。 我会在2天内将此问题标记为已解决。谢谢大家。
我正在尝试用凤凰做一个简短的lamba,但是我得到了很多编译错误。这是代码。
std::vector<unsigned char> data;
using boost::phoenix::arg_names::_1;
using boost::phoenix::static_cast_;
std::ostringstream oss;
oss << std::hex;
//Doesn't compile
std::for_each(data.begin(),data.end(), oss << static_cast_<unsigned int>(_1) );
//Compiles
std::for_each(data.begin(),data.end(), oss << _1 );
现在我从GCC 4.6.1得到以下编译错误:
/usr/include/boost/utility/result_of.hpp:-1: In instantiation of ‘boost::detail::result_of_nested_result<boost::phoenix::static_cast_eval, boost::phoenix::static_cast_eval(boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::target<unsigned char> >, 0l>&, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> >&, boost::phoenix::vector2<boost::phoenix::vector2<const boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<std::basic_ostringstream<char>&>, 0l> >, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::tag::static_cast_, boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::target<unsigned char> >, 0l>, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> > >, 2l> >*, unsigned char&>&, const boost::phoenix::default_actions&>)>’:
/usr/include/boost/phoenix/object/static_cast.hpp:29: error: declaration of ‘struct boost::phoenix::static_cast_eval::result<boost::phoenix::static_cast_eval(boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::target<unsigned char> >, 0l>&, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> >&, boost::phoenix::vector2<boost::phoenix::vector2<const boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<std::basic_ostringstream<char>&>, 0l> >, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::tag::static_cast_, boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::target<unsigned char> >, 0l>, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> > >, 2l> >*, unsigned char&>&, const boost::phoenix::default_actions&>)>’
/usr/include/boost/phoenix/core/detail/preprocessed/call_10.hpp:65: error: no type named ‘type’ in ‘struct boost::result_of<boost::phoenix::static_cast_eval(boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::target<unsigned char> >, 0l>&, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> >&, boost::phoenix::vector2<boost::phoenix::vector2<const boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::shift_left, boost::proto::argsns_::list2<boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<std::basic_ostringstream<char>&>, 0l> >, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::phoenix::tag::static_cast_, boost::proto::argsns_::list2<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::target<unsigned char> >, 0l>, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::phoenix::argument<1> >, 0l> > >, 2l> > >, 2l> >*, unsigned char&>&, const boost::phoenix::default_actions&>)>’
答案 0 :(得分:0)
这两个都在GCC和&amp; MSVC,如果我有一个刺,我猜这个罪犯是:
using boost::phoenix::arg_names::_1;
还有其他占位符具有相同的名称,一些占位符导入全局范围(我相信一个boost :: bind使用的是全局范围)。最后一个错误特别暗示了这一点,因为它似乎是一个需要成为元函数的类型而不是在某处使用。