4 ms·
Fmt – A Modern Formatting Library
- billforsternz 6y agoI know I am a barbarian, but I'll probably just continue to use my own std::string sprintf( const char *fmt, ... ); function as implemented here; https://github.com/billforsternz/retro-sargon/blob/master/src/util.cpp https://github.com/billforsternz/retro-sargon/blob/master/sr...
- qppo 6y ago(C++)
- throw0101a 6y agoI was wondering that was "modern" about it, given that fmt(1) has been around since 3BSD (1979?).
- agallego 6y agovery different, in just about every way. Type safety, deduced by the compiler instead of the stringly-typed %d and friends for starters.
- grandmczeb 6y agoFor those who don’t know, much of the fmt library interface has been standardized in C++20 as std::format. It’s a great library, and a very efficient alternative to ostream and friends.
- vitaut 6y agoIn case anyone is interested here's brief history of standardizing std::format: http://www.zverovich.net/2019/07/23/std-format-cpp20.html http://www.zverovich.net/2019/07/23/std-format-cpp20.html
- mhh__ 6y agoIt's great that it's there now but it absolutely amazes me how long some of these features have taken. Concepts took, what, the best part of 20 years and the end result is just OK. Unless there's something I'm missing the system as standardized in C++20 just seems overcooked - not very elegant while also introducing a lot of new legalese in the standard. The system D uses seems to be much simpler (and more powerful in the sense that it effectively moves template constraints into the library - doesn't require updating as traits change) i.e. template<typename T> if(constexprConditionOnT<T>) void toy(T x) {}
- thechao 6y agoThe real power of concepts was the “concept_map” construct. Gaby & Bjarne wanted predicated checking instead of structural checking. Without structural checking there’s no “natural” way in C++ syntax to specify a concept_map. The problem is that predicate checking isn’t that great. I can send you the turd of a PhD thesis that was left after my doctorate was bombed by the removal of concepts from C++0x.
- nsajko 6y agoI kind of think that IEEE 754 (or other binary floating point) to ASCII conversion should be its own project, or else in a language's standard library, since it is quite involved, especially if accuracy is important.
- zidel 6y agoThe low level part of that was standardized in C++17 as std::to_chars https://en.cppreference.com/w/cpp/utility/to_chars https://en.cppreference.com/w/cpp/utility/to_chars
- ncmncm 6y agoI see that the ostream comparison is cooked. On each iteration they trigger a memory allocation.
- dietrichepp 6y agoIt’s really astonishing how bad <ostream> is. It’s not just one or two problems—the <ostream> interface is just a total disaster. In my mind, fmt is not just a replacement for <ostream>, it’s a replacement for <cstdio>, which is a much higher bar to clear. https://www.moria.us/articles/iostream-is-hopelessly-broken/ https://www.moria.us/articles/iostream-is-hopelessly-broken/