本文介绍了正则表达式:升压:: X pressive VS的boost ::正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做一些常规的前pressions在C ++中,所以我枕着趣闻(是的,我是一个初学者/用C ++中级),发现this SO回答。

I wanted to do some regular expressions in C++ so I looked on the interwebz (yes, I am an beginner/intermediate with C++) and found this SO answer.

我真的不知道该怎么和boost ::正则表达式之间进行选择提振:: X pressive。有什么利弊/缺点是什么?

I really don't know what to choose between boost::regex and boost::xpressive. What are the pros/cons?

我也看了反对提高该升压:: X pressive ::正则表达式是一个只有标题库。它是很难静态编译的boost ::正则表达式在Linux和Windows(我几乎总是编写跨平台的应用程序)?

I also read that boost::xpressive opposed to boost::regex is a header-only library. Is it hard to statically compile boost::regex on Linux and Windows (I almost always write cross-platform applications)?

我也有兴趣在编译时比较。我有一个目前的实现使用boost :: X pressive,我不是太满足于编译时间(但我没有比较,以提振::正则表达式)。

I'm also interested in comparisons of compile time. I have a current implementation using boost::xpressive and I'm not too content with the compile times (but I have no comparisons to boost::regex).

我当然开放为regex实现过其他建议。要求是免费的(如啤酒)和 http://nclabs.org/license.php 。

Of course I'm open for other suggestions for regex implementations too. The requirements are free (as in beer) and compatible with http://nclabs.org/license.php.

推荐答案

那么,如果你需要在运行时创建一个常规的前pression(即放生在正规前pression用户类型搜索)你不能使用 X pressive ,因为它是只编译时间。

Well if you need to create a regular expression at runtime (i.e. Letting the user type in a regular expression to search for) you can't use xpressive as it is compile time only.

在另一方面,因为它是一个编译时的结构,它应该更多地受益于您的优化比正则表达式一样。

On the other hand, since it is a compile-time construct, it should benefit more from your optimizer than regex does.

我做Boost.MPL,状态图足够的东西,那灵编译器警告的220KB和错误真的不打扰我了。如果这听起来像地狱给你,坚持Boost.Regex。

I do enough stuff with Boost.MPL, StateChart, and Spirit that 220KB of compiler warning and errors don't really bother me much. If that sounds like hell to you, stick with Boost.Regex.

如果你用x pressive,我强烈建议开启 -Wfatal-错误,因为这将第一个错误后停止编译(和其它错误) :'行

If you do use xpressive, I highly recommend turning on -Wfatal-errors as this will stop compilation (and further errors) after the first 'error:' line.

有关编译时间,这是没有比赛。 Boost.Regex会更快*。使得x pressive使用MPL会导致编译时间,这一事实得到大幅提升。

For compilation time, it's no contest. Boost.Regex will be faster*. The fact that xpressive uses MPL will cause compile times to be dramatically increased.

*假设你只生成DLL /所以一旦

*This assumes you only build the dll/so once

这篇关于正则表达式:升压:: X pressive VS的boost ::正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 05:32