hackingcpp / comments

Comments regarding hackingcpp.com
0 stars 0 forks source link

cpp/libs/fmt #23

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

{fmt} Formatting & Printing C++ Library | hacking C++

Example-based introduction to the {fmt} library that offers a fast(er) and safe(r) alternative to iostreams/stdio using a Python-inspired formatting syntax.

https://hackingcpp.com/cpp/libs/fmt.html

hackingcpp commented 1 year ago

@FelixDombek Thanks, I fixed it. And yes, for the time being the comment section is the preferred place to contribute / report issues.

hackingcpp commented 1 year ago

@FelixDombek Thanks for spotting and pointing out these issues.

The less than sign in nth_element was of course a typo and I really don't remember why on earth I put the "C++17" on the overload of adjacent_difference that takes a function object.

Regarding vector shrinkage: The goal of shinking is to make sure that the capacity is not larger than the size for a particular vector object v while retaining all the elements. But if you swap v with an empty vector this will empty out v and you will lose all elements. Swapping with a copy replaces v's buffer with a copy that has the same size as capacity while retaining all elements. That's a classic idiom and sometimes still necessary to this day as "shrink_to_fit" doesn't always shrink on all implementations.

BTW I meant that I'd prefer issues pertaining to an article to be reported in the comment section of that article. For bug reports with a broader scope I'd prefer email.

FelixDombek-TomTom commented 1 year ago

(I removed my previous comments to not clutter the page with outdated remarks)

I just got bitten by the fact that fmt 9.0.0 (ostream.h) removes automatic operator<< discovery; so it would be nice if the section "{fmt} can print types that support iostream" included an example with fmt::streamed.