2014-02-22 78 views
4
#include <iostream> 
#include <boost/spirit/include/qi.hpp> 

namespace qi = boost::spirit::qi; 
int main() 
{ 
    // the following parses "1.0 2.0" into a pair of double 
    std::string input("1.0 2.0"); 
    std::string::iterator strbegin = input.begin(); 
    std::pair<double, double> p; 
    qi::phrase_parse(strbegin, input.end(), 
      qi::double_ >> qi::double_,  // parser grammar 
      qi::space,      // delimiter grammar 
      p);        // attribute to fill while parsing 
} 

這是升壓轉換器的文檔例如http://www.boost.org/doc/libs/1_55_0/libs/spirit/doc/html/spirit/abstracts/attributes/compound_attributes.htmlBoost.Spirit編譯器無法識別的std ::對

我正在編譯器錯誤

main.cpp:14:14: instantiated from here 
/usr/local/include/boost/spirit/home/qi/detail/assign_to.hpp:152:13: error: no matching function for call to ‘std::pair<double, double>::pair(const double&)’ 
/usr/local/include/boost/spirit/home/qi/detail/assign_to.hpp:152:13: note: candidates are: 
/usr/include/c++/4.6/bits/stl_pair.h:108:21: note: template<class _U1, class _U2> std::pair::pair(const std::pair<_U1, _U2>&) 
/usr/include/c++/4.6/bits/stl_pair.h:103:26: note: std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = double, _T2 = double] 
/usr/include/c++/4.6/bits/stl_pair.h:103:26: note: candidate expects 2 arguments, 1 provided 
/usr/include/c++/4.6/bits/stl_pair.h:99:26: note: std::pair<_T1, _T2>::pair() [with _T1 = double, _T2 = double] 
/usr/include/c++/4.6/bits/stl_pair.h:99:26: note: candidate expects 0 arguments, 1 provided 
/usr/include/c++/4.6/bits/stl_pair.h:87:12: note: std::pair<double, double>::pair(const std::pair<double, double>&) 
/usr/include/c++/4.6/bits/stl_pair.h:87:12: note: no known conversion for argument 1 from ‘const double’ to ‘const std::pair<double, double>&’ 
make: *** [all] Error 1 

回答

7

你需要對適應融合序列,這是通過包括

#include <boost/fusion/adapted/std_pair.hpp> 
相關問題