2011-02-10 60 views
2

我與升壓xpressive中玩弄周圍和我遇到了下列故障片斷xpressive中>> =操作

#include <iostream> 
#include <string> 
#include <boost/xpressive/xpressive.hpp> 

using namespace std; 
using namespace boost::xpressive; 

int main() 
{ 
    string s("123"); 
    sregex rex = _d; 
    rex >>= _d; 

    smatch what; 

    regex_search(s, what, rex); 

    cout << "Match: " << what[0] << endl; 

    return 0; 
} 

運行這個程序的結果是1匹配,而不是預期的12sregex::operator>>=有不同的含義/使用我直覺上認爲的嗎?我期待這會產生類似於_d >> _dsregex

回答

1

Xpressive不支持>>運算符。這個代碼編譯的事實可以被認爲是一個錯誤。嘗試:

rex = rex >> _d; 

但是,像這樣建立一個正則表達式將使正則表達式表現不佳。