r/cpp • u/srcmake • Dec 13 '18
I Made A C++ STL Algorithm Cheat Sheet
https://youtu.be/9XGqSDjaW245
u/germandiago Dec 16 '18
Hello. I just dropped by because I wanted to say: thanks for trying and even if the material is not there yet I am sure you can do a good job with the feedback given. Do not get discouraged, keep learning the material and teach it through good practices. I would recommend you books such as Effective Modern C++ and others.
Stay positive under the criticism and good luck :)
1
u/srcmake Dec 13 '18
Link to the cheat sheet itself: https://github.com/srcmake/cpp-stl-algorithms
Link to the tutorial on Pairs, Lambda Expressions, Iterators: https://www.srcmake.com/home/cpp-stl-algorithms
I was inspired by a certain CppCon talk showing the STL algorithms, especially since I participate in programming contests and the algorithms seem useful. I couldn't find any resources that actually explained the algorithms in simple words or that gave short enough examples for me to find useful, so I decided to make my own. The STL Algorithm cheat sheet that I wrote on github is meant to have a very short description of each algorithm and provide 2-5 lines of example code showing how the algorithm is used, and what gets modified/produced as a result.
If there were better resources and it was a waste of time, please let me know lol because I'd love to know where everyone else gets their C++ resources from. But if you find this useful, please star/share the project on github so more developers can [easily] see how these algorithms are used so that they can learn/use them themselves. (And if I made an error somewhere or you see room for improvement, please let me know.)
2
Dec 16 '18
It's not a "waste of time" but you should pay attention to the feedback suggesting you make your language more precise. For example, stuff like: "Iterators are just special variables that point to a certain element in a container." Iterators aren't "variables." They are types with many variations (forward, random, bidirectional, etc). Earlier, you refer to pairs as "mini-containers" which suggests that there should be iterators for them. Sharp beginners will pick up on these incongruencies, so it is important to say what you mean, and mean what you say. Saying stuff like "you're now a C++ pro" is overly gratuitous and doesn't help anyone. As for the cheatsheet portion, my feedback is that it actually contains too much content to qualify as a "cheatsheet," which in my opinion, should be immediately readable and contained within a glance. For full examples and a description of the semantics, I would just use cppreference itself. Your cheatsheet should honestly at a minimum contain actual arguments and return types (note, it would currently be missing overloads) and a very terse description to be useful.
1
May 14 '19 edited May 14 '19
What is the iterator type of a unordered_map? It's a freaking pair. A pair can be an iterator so it wouldn't even make sense to have an iterator to an iterator, something you allege sharp coders would get confused about. Sharp coders aren't going to be learning from a cheat sheet. This should be a refresher.
0
u/srcmake Dec 13 '18
Btw since this relates to the Standard/C++ resources, how do I ask for this to be put on isocpp.org ? I'd like to share it there since the homepage has other resources, but I don't know how people are supposed to do that. I'm not part of the Standard Committee so...
8
7
u/VicontT Dec 13 '18
I was going to list issues I have with that, and I have started doing it and named following:
How is it better than https://en.cppreference.com/w/cpp/header/algorithm (the page)
STL does not mean standard TEMPLATE library for about 10 years for now
std::pair is NOT a container, it's a struct template.
Lambda is CERTAINLY not a different way to write a function, it's very different from that.
And than, when you started talking about auto as a lamba type, I just realized you are not really familiar with the subject. May be you should learn more and teach less?