2011-02-10 62 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; 

但是,像这样建立一个正则表达式将使正则表达式表现不佳。