2011-02-02 74 views
9

我有以下代碼:解析一對整數與提升精神

std::string test("1.1"); 
std::pair<int, int> d; 

bool r = qi::phrase_parse(
     test.begin(), 
     test.end(), 
     qi::int_ >> '.' >> qi::int_, 
     space, 
     d 
     ); 

所以我試圖解析字符串測試,並將結果存放在標準::對d。但它不起作用,我懷疑它與Compound Attribute Rules有關。

任何提示如何讓這個工作?

編譯器錯誤是:

error: no matching function for call to 'std::pair::pair(const int&)'

回答

18

它應該工作。人們常常忘記的是將

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

添加到它們的包含列表。這是使std::pair成爲一個完整的Fusion公民的必要條件。

+1

完美的工作..它寫在文檔的某個地方?我找不到它,但也許我只是忽略了它。 – mortenvp 2011-02-02 15:28:42