Today, I was trying to validate some user input with C++11's new regular expressions. In essence, I tried the following.
auto r = std::regex("[0\\- ]"); std::cout << std::regex_match(some_string, r) << std::endl;
The code should compile, and does compile. However, the first line throws an error.
Invalid range in bracket expression. terminate called after throwing an instance of 'std::logic_error'
This is somewhat surprising. The intent is to generate a (somewhat useless) regular expression checking if a string contains one of the three characters
auto r = std::regex("[0 \\-]");
Small difference, big effect.