hackingcpp / comments

Comments regarding hackingcpp.com
1 stars 0 forks source link

cpp/cheat_sheets #1

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

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

pyeprog commented 3 years ago

These are the most beautiful notes I've ever seen

maidamai0 commented 3 years ago

much better than cppreference

hackingcpp commented 3 years ago

@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

kbumsik commented 3 years ago

So cool! Which tools do you use to make the infographics?

mrcakb commented 3 years ago

Great infographics & cheat sheet for quick reviewing and renewing what you know before. Thanks!

AhmadBan commented 2 years ago

awesome.

RubenRubioM commented 2 years ago

It would be cool a PDF version of that! Very good job guys

mimicryryu commented 2 years ago

I shall print them on the wall of my bedroom

AlphaHot commented 2 years ago

Wow, awesome cheat sheet, thank you so much for that

heatblazer commented 2 years ago

Best cheat sheet ever made.

malte0811 commented 2 years ago

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!

hackingcpp commented 2 years ago

@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.

royaalto commented 2 years ago

COOOOOOOOL

aardappel commented 2 years ago

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 Ts 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 Ts actually present for an even more compressed representation..

TJSarkka commented 2 years ago

There's a tiny mistake in the forward_list example code (it uses list instead).

hackingcpp commented 2 years ago

@TJSarkka thanks! I fixed it.

hackingcpp commented 2 years ago

@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).

aardappel commented 2 years ago

@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.

hackingcpp commented 2 years ago

@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.

ghost commented 2 years ago

I have been working in CS for more than 26 years now. I have never seem something like this. Really hard work .. amazing.

Heuristack commented 2 years ago

Awesome!

biessenerdavid commented 2 years ago

Absolutely fantastic. C++ has an enormous quantity of valuable nuances, and that quantity is also a detriment. Thank you for putting this together!

makifay commented 2 years ago

Gorgeous and beneficial work, I really appreciate it 👏👏

Shakilkhan24 commented 2 years ago

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?

ft0g0 commented 1 year ago

Great resource, many many thanks! Can you please have a look on website search? Looks like it doesn't work...

HenryAWE commented 1 year ago

Can you make a visualization of std::filesystem::path, such as results of its methods?

785360050 commented 1 year ago

Awesome

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?

1ucasdev commented 1 year ago

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!

chen-qingyu commented 1 year ago

Exciting!

I love it!

RivTian commented 12 months ago

Great infographics & cheat sheet for quick reviewing and renewing what you know before. Thanks!

PMSivaDev commented 8 months ago

Wow! AFAIK this is a very neat and the most easy-to-read cheat sheets for CPP. Much respect for your effort.

WangFengtu1996 commented 6 months ago

thanks! maybe multimap multiset unordered_multimap unordered_multiset needed!