• <bdo id='vK86P'></bdo><ul id='vK86P'></ul>

    <tfoot id='vK86P'></tfoot>
    <i id='vK86P'><tr id='vK86P'><dt id='vK86P'><q id='vK86P'><span id='vK86P'><b id='vK86P'><form id='vK86P'><ins id='vK86P'></ins><ul id='vK86P'></ul><sub id='vK86P'></sub></form><legend id='vK86P'></legend><bdo id='vK86P'><pre id='vK86P'><center id='vK86P'></center></pre></bdo></b><th id='vK86P'></th></span></q></dt></tr></i><div id='vK86P'><tfoot id='vK86P'></tfoot><dl id='vK86P'><fieldset id='vK86P'></fieldset></dl></div>
  • <small id='vK86P'></small><noframes id='vK86P'>

      <legend id='vK86P'><style id='vK86P'><dir id='vK86P'><q id='vK86P'></q></dir></style></legend>
      1. 示例解析错误

        Example parsing error(示例解析错误)

            <small id='FNayh'></small><noframes id='FNayh'>

            <i id='FNayh'><tr id='FNayh'><dt id='FNayh'><q id='FNayh'><span id='FNayh'><b id='FNayh'><form id='FNayh'><ins id='FNayh'></ins><ul id='FNayh'></ul><sub id='FNayh'></sub></form><legend id='FNayh'></legend><bdo id='FNayh'><pre id='FNayh'><center id='FNayh'></center></pre></bdo></b><th id='FNayh'></th></span></q></dt></tr></i><div id='FNayh'><tfoot id='FNayh'></tfoot><dl id='FNayh'><fieldset id='FNayh'></fieldset></dl></div>
              <bdo id='FNayh'></bdo><ul id='FNayh'></ul>
              <legend id='FNayh'><style id='FNayh'><dir id='FNayh'><q id='FNayh'></q></dir></style></legend>

                <tfoot id='FNayh'></tfoot>

                    <tbody id='FNayh'></tbody>
                  本文介绍了示例解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试按照示例解析提升精神 (2.5.2) 的示例.我的代码如下

                  I'm trying to parse an example of boost spirit (2.5.2) following the example. My code is the following

                  #include <boostspirithomeqi.hpp>
                  #include <iostream>
                  #include <string>
                  #include <utility>
                  
                  int main()
                  {
                  
                    // Parsing two numbers
                    std::string input("1.0 2.0");
                    std::pair<double, double> p;
                  
                    boost::spirit::qi::phrase_parse(
                      input.begin(),
                      input.end(),
                      boost::spirit::qi::double_ >> boost::spirit::qi::double_ , // Parse grammar
                      boost::spirit::qi::space,
                      p
                    );
                  
                    return 0;
                  }
                  

                  它几乎等于找到的例子 此处,但是当我使用 Visual Studio 2010(32 位,调试)编译它时,出现以下错误:

                  It's almost equal to the example found here, but when I compile it with Visual studio 2010 (32 bit, debug) I obtain the following error:

                  error C2440: 'static_cast': unable to convert from 'const double' to 'std::pair<_Ty1,_Ty2>'
                  

                  (错误可能略有不同,我是从意大利语翻译过来的)

                  (the error can be slighty different, I've translated it from italian)

                  我做错了什么,我怎样才能成功编译这个例子?

                  What I'm doing wrong and how can I compile successfully the example?

                  预先感谢您的回复.

                  推荐答案

                  您缺少一个包含:

                  #include <boost/fusion/adapted/std_pair.hpp>
                  

                  它定义了属性分配规则,使 Fusion 序列 (vector2<>) 可分配给 std::pair.

                  It defines the attribute assignment rules to make Fusion sequences (vector2<>) assignable to std::pair.

                  查看实时代码:liveworkspace.org

                  See the code live: liveworkspace.org

                  #include <boost/spirit/include/qi.hpp>
                  #include <boost/fusion/adapted/std_pair.hpp>
                  #include <iostream>
                  #include <string>
                  #include <utility>
                  
                  int main()
                  {
                      // Parsing two numbers
                      std::string input("1.2 3.4");
                      std::pair<double, double> p;
                  
                      namespace qi = boost::spirit::qi;
                  
                      qi::phrase_parse(
                              input.begin(), 
                              input.end(),
                              qi::double_ >> qi::double_ , // Parse grammar
                              qi::space, p);
                  
                      std::cout << "Lo:     " << p.first << "
                  "
                                << "Behold: " << p.second << "
                  ";
                  }
                  

                  这篇关于示例解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to limit the number of running instances in C++(C++中如何限制运行实例的数量)
                  Using boost::asio::async_read with stdin?(将 boost::asio::async_read 与 stdin 一起使用?)
                  How to find out what dependencies (i.e other Boost libraries) a particular Boost library requires?(如何找出特定 Boost 库需要哪些依赖项(即其他 Boost 库)?)
                  What#39;s the purpose of a leading quot;::quot; in a C++ method call(引导“::的目的是什么?在 C++ 方法调用中)
                  Boost Spirit x3: parse into structs(Boost Spirit x3:解析为结构体)
                  How boost auto-linking makes choice?(boost自动链接如何做出选择?)
                    <tbody id='mMaTu'></tbody>
                  • <i id='mMaTu'><tr id='mMaTu'><dt id='mMaTu'><q id='mMaTu'><span id='mMaTu'><b id='mMaTu'><form id='mMaTu'><ins id='mMaTu'></ins><ul id='mMaTu'></ul><sub id='mMaTu'></sub></form><legend id='mMaTu'></legend><bdo id='mMaTu'><pre id='mMaTu'><center id='mMaTu'></center></pre></bdo></b><th id='mMaTu'></th></span></q></dt></tr></i><div id='mMaTu'><tfoot id='mMaTu'></tfoot><dl id='mMaTu'><fieldset id='mMaTu'></fieldset></dl></div>

                      <small id='mMaTu'></small><noframes id='mMaTu'>

                      • <bdo id='mMaTu'></bdo><ul id='mMaTu'></ul>
                      • <legend id='mMaTu'><style id='mMaTu'><dir id='mMaTu'><q id='mMaTu'></q></dir></style></legend>

                          <tfoot id='mMaTu'></tfoot>