I wrote the following code for parsing command line arguments, using Visual C++ 2012. These command-line parameters have traditional GNU style (--option).
void parseCmdLines(int argc, wchar_t* argv[]) {
for (auto i = 1; i < argc; ++i) {
std::wstring arg(argv[i]);
// I hope it can match the L"--config=../etc/my.conf"
std::wregex regex(L"--config=(+*)");
std::wsmatch match;
std::regex_match(arg, match, regex);
// TODO: ...
}
Unfortunately, when I run this program, I met an exception. The description of the exception is as follows:
Microsoft C++ exception: std::regex_error at memory location 0x23F090.
How can I solve this problem?