I'm getting this when using square brackets in a regex string:
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
The following program runs fine:
#include <regex>
int main()
{
std::regex rx1("a");
return 0;
}
But this does not:
#include <regex>
int main()
{
std::regex rx1("[a]");
return 0;
}
It compiles fine, and I couldn't find any examples of this happening to anybody else, so I'm really stumped here. I'm quite new to c++, so I could be missing something blindingly obvious, but could anybody explain what's up?
edit--
So I recompiled with ms visual c++ 2010 (I was using GCC) and it didn't throw any errors. I'm not familiar with the differences between compilers, though, and I don't know which I should/shouldn't be using. Is there a generally accepted "best" compiler?