Compare two regular expressions -> check if empty()
Stefan Schweter
stefan@schweter.it
Mon Oct 6 20:53:00 GMT 2014
Hi,
when I read the regular expression section in C++11 correctly, there's
no method called "size", "length" in order to get the length of a
regular expression or a method "empty(). Using Boost's regex
implementation e.g. provides empty(). So I need to do a comparison of
two regexes - consider the following code:
#include <regex>
#include <iostream>
int main()
{
std::regex test("");
std::regex test2("");
if (test == test2) {
std::cout << "empty" << std::endl;
}
return 0;
}
Won't compile with the latest GCC 5.
As I read the current regex implementation, there's an internal variable
called "_M_original_str". So maybe it would be a good idea to compare
lhs and rhs of two regexes for the == operator in order to get the
comparison mentioned above work?
Thanks in advance + regards,
Stefan
More information about the Libstdc++
mailing list