小编use*_*477的帖子

regex_token_iterator*it ++ bug?

用于以下代码:

#include<iostream>
#include<regex>

using namespace std;

int main(int argc, char *argv[]) 
{
    regex reg("/");
    string s = "Split/Values/Separated/By/Slashes";
    sregex_token_iterator it{std::begin(s), std::end(s), reg, -1};
    sregex_token_iterator end;

    while(it != end)
    {
        cout << *it++ << endl;
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

应该输出:

Split
Values
Separated
By
Slashes
Run Code Online (Sandbox Code Playgroud)

但它输出这个:

Values
Separated
By

Slashes
Run Code Online (Sandbox Code Playgroud)

主要代码可能是问题*it++,如果我写cout << *it << endl;++it;,它的工作正常.

当我将stand c ++ 11 regex更改为boost-regex时,*it++也正常工作.

我检查了正则表达式的头部,我认为该operator++(int)函数没有问题.

我的铿锵版是

Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) 
Target: x86_64-apple-darwin13.0.0 …
Run Code Online (Sandbox Code Playgroud)

c++ regex c++11

7
推荐指数
1
解决办法
345
查看次数

标签 统计

c++ ×1

c++11 ×1

regex ×1