Open utterances-bot opened 3 years ago
These are the most beautiful notes I've ever seen
much better than cppreference
@maidamai0: thanks! cppreference is great if you want to know specific details, my focus is more on giving a quick overview don't forget to check out the visual standard algorithms overview: https://hackingcpp.com/cpp/std/algorithms.html
So cool! Which tools do you use to make the infographics?
Great infographics & cheat sheet for quick reviewing and renewing what you know before. Thanks!
awesome.
It would be cool a PDF version of that! Very good job guys
I shall print them on the wall of my bedroom
Wow, awesome cheat sheet, thank you so much for that
Best cheat sheet ever made.
The claim about the size of std::variant
is not quite correct, it ignores that they need some space to store the index of the currently stored type (example). Very nice cheat sheet otherwise!
@malte0811 you are absolutely right - I actually implemented tagged unions like std::variant in the past so it's not that I didn't know. I probably shouldn't have dumbed it down so much on this cheat sheet - it's always a tough decision how much detail one wants to present. I've now added the type index on the sheet and also tried to make it clear that pair and tuple might have padding in between the members.
COOOOOOOOL
optional<T>
looks incorrect to me.. the picture should look very similar to the one for pair
since it will often look like pair<bool, T>
in memory, including the padding that entails for most T
.
Though I am not a fan of how vector<bool>
is specialized, the above makes me think a specialized vector<optional<T>>
that stores bit-sized bools separate from the T
s would be neat. But should maybe have its own name, like optional_vector<T>
. And you could go even further, if has_value
is expected to often be false, you could use pop_count
to only store consecutive T
s actually present for an even more compressed representation..
There's a tiny mistake in the forward_list example code (it uses list instead).
@TJSarkka thanks! I fixed it.
@aardappel You are right that optional needs an additional member to store whether it is engaged or not. These box graphics where originally supposed to be very "dumbed down" but I guess it is better to show more details. I changed it. But the bool is usually stored "behind" the optional's payload (so like pair<T,bool>). Storing it before the payload would require padding on almost all modern platforms but storing it behind the payload doesn't always require padding (e.g. when the payload size is a multiple of 64 bits on x86-64).
@hackingcpp afaik storing it behind the payload also almost always requires padding, e.g. optional<int64_t>
results in an underlying struct/class type that is 16-byte in size, and will still be 16 bytes when stored as a local, as part of another struct or vector.
The alignment of a struct is that of its highest alignment member, and sizeof is padded accordingly.
@aardappel Oh - of course, you are absolutely right - that was totally wrong thinking on my part. Avoiding the trailing padding would still require packing the type (e.g. with #pragma pack
). I saw the bool following the std::optional payload (at least in libstdc++ and libc++) and totally forgot that this only avoids padding between the members in some cases but not padding after the bool.
I have been working in CS for more than 26 years now. I have never seem something like this. Really hard work .. amazing.
Awesome!
Absolutely fantastic. C++ has an enormous quantity of valuable nuances, and that quantity is also a detriment. Thank you for putting this together!
Gorgeous and beneficial work, I really appreciate it 👏👏
Lots of respect to hackingcpp.. It's my best platform, i always visit this site regular basis.
Do you have any [Data structure and Algorithm] course like this?
Great resource, many many thanks! Can you please have a look on website search? Looks like it doesn't work...
Can you make a visualization of std::filesystem::path
, such as results of its methods?
I've always used a tablet for hand-drawn notes because drawing on a computer seemed too complicated. However, I've seen better electronic notebooks here. How are these drawings created?
Thanks for the detailed information! So far I’ve figured out how to make an online calculator full screen. I will continue to learn new technologies. Thank you!
I love it!
Great infographics & cheat sheet for quick reviewing and renewing what you know before. Thanks!
Wow! AFAIK this is a very neat and the most easy-to-read cheat sheets for CPP. Much respect for your effort.
thanks! maybe multimap multiset unordered_multimap unordered_multiset needed!
C++ Infographics & Cheat Sheets | hacking C++
A collection of overview graphics or cheat sheets each capturing one aspect of C++.
https://hackingcpp.com/cpp/cheat_sheets.html