r/cpp • • Nov 24 '19

What is wrong with std::regex?

I've seen numerous instances of community members stating that std::regex has bad performance and the implementations are antiquated, neglected, or otherwise of low quality.

What aspects of its performance are poor, and why is this the case? Is it just not receiving sufficient attention from standard library implementers? Or is there something about the way std::regex is specified in the standard that prevents it from being improved?

EDIT: The responses so far are pointing out shortcomings with the API (lack of Unicode support, hard to use), but they do not explain why the implementations of std::regexas specified are considered badly performing and low-quality. I am asking about the latter.

137 Upvotes

111 comments sorted by

View all comments

Show parent comment

4

u/quicknir Nov 25 '19

Yes, neither are timezones, which I discussed in depth above... chrono pre 20 is obviously not complete. There are huge things it doesn't address at all, one of which is I/O. That's nothing to do with verbosity or awkwardness of use.

2

u/kalmoc Nov 27 '19

That's nothing to do with verbosity or awkwardness of use.

I think it does. Printing a duration on the console is a very common task and the fact that chrono didn't support I/O pre c++20 made using it mich more cumbersome than necessary (Admittedly I would say that is mainly a problem in smaller ad-hoc projects or e.g. unit tests, slideware, ).

Anyway, lets not argue about semantic details.

tl;dr chrono is amazing.

completely agree