gpt4 book ai didi

c++ - `boost::phoenix::static_cast_` 与标准库混合使用

转载 作者:太空宇宙 更新时间:2023-11-04 14:20:52 25 4
gpt4 key购买 nike

这是一个 Phoenix v3 错误。它与 Phoenix v2 编译得很好。我做了错误报告。 我会在 2 天内将此问题标记为已解决。谢谢大家。

我正在尝试用 phoenix 制作一个短的兰巴舞曲,但我遇到了一堆编译错误。这是代码。

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&>)>’

最佳答案

两者都在 GCC 和 MSVC 上编译,如果我尝试一下,我猜违规者是:

using boost::phoenix::arg_names::_1;

还有其他名称完全相同的占位符,其中一些已导入到全局范围(例如,我相信 boost::bind 使用的是在全局范围内)。最后一个错误特别暗示了这一点,因为它似乎没有在某处使用需要成为元函数的类型。

关于c++ - `boost::phoenix::static_cast_` 与标准库混合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7833434/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com