5 ms·
There are parts of C++ standard library that no one should ever use. The examples are: regex, iostreams, locale... My main concern - this can also become such
by zX41ZdbW 3y ago
There are parts of C++ standard library that no one should ever use.
The examples are: regex, iostreams, locale...
My main concern - this can also become such a dead weight.
- the_svd_doctor 3y agoCan you expand on the problems with regex?
- mike_hock 3y agoThe implementations are bad and implementers are refusing to fix their own bad implementations so as to not break their own ABI, but that has nothing to do with C++ the standard.
- dkersten 3y agoFrom what I’ve heard, std::regex is notoriously inefficient (lots of memory allocations, no allocator support). But I’ve never used it myself.
- TylerGlaiel 3y agooh yeah C++ regex is stupidly inefficient, like "python is faster" inefficient. I tried to use it for text replacements and pretty much immediately abandoned it
- gpderetta 3y agoApparently typical implementations of std::regex are inefficient like "'popen("perl..")' is faster" is inefficient! I thing boost::regex is significantly faster although not particularly fast
- verall 3y agoWhat's wrong with std::regex? Seems to work fine for me. And iostreams - they're not great. Bad programming UI, poor performance, etc. Issues abound. But should you never use them? What do you use instead? *printf methods have lots of issues too. And so does depending on Boost::format. And so does writing your own Logger/wrapping code (which is what everyone does AFAICT). locale is bad though
- gpderetta 3y agoiostreams are not great but are nothing compared to the awkwardness and lack of extensibility of printf style format strings.
- einpoklum 3y ago1. Historically, std::regex was offered in GCC before it was actually fully implemented. Much hilarity ensued... 2. Some existing implementations have efficiency issues, e.g. performing many allocations. 3. It is claimed (e.g. by Titus Winters) that the ABI of std::regex is problematic, and without breaking it, the implementations cannot be good enough See these points and others at: https://www.reddit.com/r/cpp/comments/e16s1m/what_is_wrong_with_stdregex/ https://www.reddit.com/r/cpp/comments/e16s1m/what_is_wrong_w...
- npsimons 3y ago> What do you use instead [of std::iostream]? This is what I want to know. Having come from C to C++, iostreams were a big improvement over the "strings" and print functions of C. I even extended a base iostream class to have a "teebuf" logger, that could output to multiple streams and had the standard logging levels. It's been a while since I last had mastery of C++, but I'd like to hear what is as portable and better than iostreams.
- usefulcat 3y ago> I'd like to hear what is as portable and better than iostreams Have a look at fmtlib. The interface is more like printf, but type safe and format strings are parsed at compile time. I believe it’s what std::format is based on, which could also be an option for you depending on how recent your compiler/language version is.
- npsimons 3y ago> The interface is more like printf See, I don't believe that's an improvement. Having used printf in C, I was relieved to be able to "redirect" whatever to a stream, and not care about whether it should be "%d" or "%02f" or even if it was a struct/class. On top of this, treating files as streams, strings as streams, or even extending streams to make a tee-stream[0] all seem clunkier to me with a printf like system. Maybe fmt fixes these problems, I don't know. But I feel a lot of people don't like iostreams because they have some form of Stockholm syndrome with printf. [0] - https://wordaligned.org/articles/cpp-streambufs#tee-streams https://wordaligned.org/articles/cpp-streambufs#tee-streams