Std::printf("failed to clone %s from %s", target, src) Old printf code, works ok for most people The part that fmtlib / std::format has, which is printf-like, is the idea of having a format string and arguments, rather than having a bunch of separate, piecemeal strings. Not really trying to be hostile here, but you did acknowledge that you were unfamiliar with std::format. Yeah, it looks like you did a lot of guesswork in that comment, and a lot of those guesses were inaccurate. > Maybe fmt fixes these problems, I don't know. Libfmt is also better and more portable, and it is now part of the standard library as std::format. Using std::printf is better and more portable. I don't think that's much of an advantage, especially weighed against the numerous disadvantages. The only remaining advantage of is that you can overload operator<<. You get type safety with std::printf, with most compilers, assuming you enable -Wformat on GCC or similar options in other compilers. The main advantage of was that it provided type safety, but IMO that advantage has long since been irrelevant. Performance of, out of the box, is mediocre (to get decent performance, you need to change some defaults) Streams in are stateful, and it's easy to accidentally leave them in the wrong state (radix, padding, field width, etc) The operator overloading syntax is bad (my sense is that the operator overloading abuse in was a contributing factor for why Java doesn't allow operator overloading) makes thread safety more difficult, compared to printf (it is safe to printf/fprintf from multiple threads, simultaneously, without any extra work) makes localization more difficult, compared to printf (localizing code is beyond awful) Strings in C++ are nice, especially now that we have std::string_view, but is one of the worst pieces of the C++ standard library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |