This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compare two regular expressions -> check if empty()


On 6 October 2014 21:52, Stefan Schweter wrote:
> 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("");

You can just call the default constructor to create an empty regex
here, that's going to be more efficient than invoking the compiler to
create a finite state automaton for the string "".

>
>   if (test == test2) {
>     std::cout << "empty" << std::endl;
>   }
>
>   return 0;
> }
>
> Won't compile with the latest GCC 5.

We just implement the standard, which gives no meaning to equality of
regex objects.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]