为何如下正则代码在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;
}
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.