开发者

Boost.Regex vs C++11 Regex

Could someone explain the开发者_StackOverflow中文版 differences between the two? Which would be better to learn right now? How would knowledge transfer from one to the other and vice-versa?


The boost regex library made it into C++0x so I'm guessing it will slowly be removed from boost. However, using boost is nice because you can still use it with compilers without C++0x support. So it's really up to you.


One major difference is, that C++11 does not provide the Perl syntax for regular expressions. So, if you tend to use Perl syntax you have to use the Boost::Regex library.


At least in Visual Studio 2013 this and related names (cmatch, regex_match) are the same in both namespaces. They also have the same (or similar?) interface.

So you can just change namespace and the same code will be compiled with another regex without warning and errors. And it should work the same of course.

P.S. I would prefer std::regex since it is part of C++11 and boost::regex is a third-party library. I'm sure few years later, boost will remove support for boost::regex.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜