regex: boost::xpressive vs boost::regex

前端 未结 5 1525
醉梦人生
醉梦人生 2021-02-19 12:25

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.

I really don\'t know

5条回答
  •  感情败类
    2021-02-19 12:42

    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.

    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.

    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.

    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.

    *This assumes you only build the dll/so once

提交回复
热议问题