问题
Replacing boost::regex
with std::regex
since we are using gcc 4.6 in the company I ran into an issue with empty () method of that class - it basically didn't make it from boost::regex
into std::regex
class. I am not sure whether this is a gcc's issue or this method didn't make it into C++11 standard at all, but that piece of code was heavily depending on this feature. So the question is - is there a way in C++11 std::regex
to check if expression was ever set or I should stick to boost::regex
for the rest of my life?
回答1:
empty()
got removed from std::regex
a long time ago. N1507 (2003-09-16) was the original paper to suggest its removal (search for "What is an invalid/empty regular expression?"). This issue was directed at what then was std::tr1:regex
. It was recorded in the LWG tr1 issues lists as issue 7.28 and contained the following resolution:
Discussed at Kona. The LWG agrees that the default constructor should be equivalent to construction from an empty string. Leaving this open for now partly because we need wording expressing that, and partly because it’s not clear that there’s any point to having theempty() member function in the first place.
N1711 (2004-11-04) was the first TR1 draft to lack basic_regex::empty()
. From there it got imported from TR1 into C++11 with no further discussion.
来源:https://stackoverflow.com/questions/7799705/boostregex-vs-stdregex-cant-find-empty-method