提振精神KWD分析器在Visual Studio 2013 [英] Boost Spirit kwd parser in Visual Studio 2013

查看:186
本文介绍了提振精神KWD分析器在Visual Studio 2013的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Boost 1.57与Visual Studio 2010。

I'm using Boost 1.57 with Visual Studio 2010.

我想我的项目升级到Visual Studio 2013,但我有一些问题,升压精神分析器。
在我看来,该的 KWD 的解析器以某种方式打破。下面code编译正确Visual Studio 2010中:

I would like to upgrade my project to Visual Studio 2013 but i'm having some problem with the boost Spirit parser. Seem to me that the kwd parser is broken somehow. The following code compiles correctly in Visual Studio 2010:

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/repository/include/qi_kwd.hpp>
#include <boost/spirit/repository/include/qi_keywords.hpp>
#include <iostream>
#include <string>
using boost::spirit::qi::double_;
using boost::spirit::qi::_1;
using boost::phoenix::ref;
using boost::spirit::repository::qi::kwd;

template <typename Iterator>
bool difference(Iterator first, Iterator last, double& n) {
    bool r = boost::spirit::qi::phrase_parse(first, last,
             //the grammar
             (kwd("A")[double_[ref(n) += _1]] /
              kwd("B")[double_ [ref(n) -= _1]]),
                              boost::spirit::ascii::space);
    if (first != last) return false;
    return r;
}

int main() {
    std::string str("A 1 B 2");
    double n=0;
    std::cout << "Full parse: " << difference(str.begin(), str.end(), n) << std::endl;  
    std::cout << "A - B = " << n <<std::endl;
    return 0;
}

我得到wnen我尝试使用Visual Studio 2013来编译它的错误是(很多中):

The errors I get wnen i try to compile it with Visual Studio 2013 are (among the many):

 Error  3   error C3203: 'type' : unspecialized class template can't be used as a template argument for template parameter 'T2', expected a real type   ... fold_impl.hpp   
 Error  4   error C2039: 'type' : is not a member of 'boost::mpl::apply<boost::fusion::detail::apply_transform_result<boost::spirit::repository::qi::detail::string_keywords<Elements,boost::mpl::filter_view<Elements,boost::spirit::repository::qi::is_kwd_parser<boost::mpl::_>>,boost::mpl::filter_view<boost::mpl::vector2<boost::mpl::integral_c<T,0>,boost::mpl::integral_c<T,1>>,boost::spirit::repository::qi::keywords<Elements,Modifiers>::is_kwd_parser_filter<boost::mpl::_>>,boost::array<bool,2>,Modifiers>::build_char_type_sequence<StringKeywords>::element_char_type>,boost::spirit::repository::qi::kwd_parser<Subject,const char (&),boost::spirit::qi::make_directive_internal<T1,Subject,Modifiers,boost::mpl::false_>::iterator_type,boost::spirit::has_modifier<Modifiers,boost::spirit::tag::char_code_base<CharClass>>,Distinct>,boost::mpl::na,boost::mpl::na,boost::mpl::na,boost::mpl::na>'   ... value_of_impl.hpp   

这是加速的错误?
有没有办法让这个code在Visual Studio 2013来编译?
(当然我真实的项目比这大得多,这将是重写所有的语法有问题)

Is this a bug of Boost? Is there any way to get this code to compile in Visual Studio 2013? (of course my real project is much bigger than this, it would be a problem to rewrite all the grammar)

任何帮助是AP preciated。

Any help is appreciated.

推荐答案

这个问题似乎是在MPL /融合库已转向不再期待TR1协议结果-的。

The problem appears to be that the mpl/fusion libraries have shifted to no longer expecting to TR1 result-of protocol.

这有什么都做与编译器在大已经实现decltype支持的事实,而实际上

This has everything to do with the fact that compilers at large have implemented decltype support, and in fact


  • BOOST_RESULT_OF_USE_DECLTYPE已经成为大多数编译器的默认配置提振

  • 凤凰V3已经成为精神默认在最新版本

我验证了您的特定示例并汇编铛当你在上面插入此行:

I verified that your particular sample does compile on clang when you insert this line at the top:

#define BOOST_RESULT_OF_USE_TR1

看它的 住在Coliru

See it Live On Coliru

其实这仍然重新presents应当报灵邮件列表的问题,海事组织TR1协议肯定会在将来会过时。

Actually this still represents a problem that should be reported to the Spirit mailing list, IMO as TR1 protocol will certainly be obsoleted in the future.

在此期间,我建议使用TR1,因为只有后备:

In the meantime, I suggest to use TR1 as a fallback only:

#define BOOST_RESULT_OF_USE_DECLTYPE_WITH_TR1_FALLBACK

看它的 住在Coliru 了。

See it Live On Coliru too.

为了用VS2013编译,我不得不的添加如下定义

In order to compile with VS2013, I had to also add the following define

#define _SCL_SECURE_NO_WARNINGS

这篇关于提振精神KWD分析器在Visual Studio 2013的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆