正则表达式 - 为何如下正则代码在VC++ 调试模式下crash
大家讲道理
大家讲道理 2017-04-17 13:44:33
0
1
448

为何如下正则代码在VC++ 2013 调试模式下crash,而Release模式可以正常运行

#include <regex>
#include <iostream>
int main(){
    auto P = std::regex(R"(^([^\x00]*?)$)");
    std::smatch M;
    if (std::regex_search(std::string("A"), M, P)){
        std::cout << M[0].str();
    }
    return 0;
}
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
巴扎黑

Tested it. . No problem

However, there is a small problem under VS2015. Directly passing std::string("A") into the regex_search function will prompt an error. The reason should be that what needs to be received here is a reference, and the constructor is deleted after passing the value.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template