r/cpp • u/HappyCerberus • Feb 01 '23
[book] A Complete Guide to Standard C++ Algorithms (v1.0.0)
https://github.com/HappyCerberus/book-cpp-algorithms/releases/download/v1.0.0/book_with_cover_v1.0.0.pdf17
u/ironykarl Feb 01 '23
Any chance this will ever get published (printed)?
24
u/HappyCerberus Feb 01 '23
I haven't found a publisher that would do a charity release.
I have it on leanpub with the profits going to EFF, but that's still digital only.
5
u/70rd Feb 01 '23
Have you looked into Amazon or the TheBookPatch?
I know Fabien Sanglard self-publishes some of his books there, and the quality is quite high. Lulu would be anthor option.
edit: read too fast, didn't see the charity release requirement. You can crank your own revenue down quite low I believe, however, or donate the proceeds to charity (modulo tax implications).
7
u/HappyCerberus Feb 01 '23
Yeah, no, that doesn't work for me.
I basically need the LeanPub model, where it is them moving the money to the charity and me getting zero profit.
4
5
u/baz_a Feb 02 '23
Thank you! Very nicely written and formatted, a pleasure to read.
Small question. Why do you use ssize_t in several cases? It's not a problem, everything is understandable. But is there any specific purpose to it? From what I could find ssize_t is POSIX primitive, the equivalent in the standard is ptrdiff_t, which ssize() members return typically. That's unlike size_t type, by the way.
3
u/markopolo82 embedded/iot/audio Feb 02 '23
@op: I admit I’ve only just skimmed the introduction so far, but this is definitely something that would be valuable to discuss I’m your book if it isn’t already
2
u/HappyCerberus Feb 02 '23
It is touched upon in 5.2.1 (briefly).
4
u/baz_a Feb 02 '23
I got that you needed a signed size type when taking a difference between iterators, but
ssize()returnsptrdiff_ttype, there is nossize_tin the standard, it's a POSIX extension, as far as I understand. It's ok for gcc and clang, but in msvc can cause issues, maybe. I am not sure, but it caught my eye.4
u/HappyCerberus Feb 02 '23
Ah, yeah, I might need to do a cleanup pass. ptrdiff_t is the correct type.
19
u/almost_useless Feb 02 '23
Looks good, but book_with_cover.pdf is a terrible filename for something people should download and save.
Any chance of an epub version?
7
10
5
1
3
u/utf8decodeerror Feb 02 '23
I'm very excited to dive into this. Thank you for sharing your expertise!
3
3
u/masher_oz Feb 02 '23
I really like the look of this. I need to print it to read it properly.
Ta a lot for your effort.
4
3
3
u/serviscope_minor Feb 02 '23
It can be tricky to internalize all the rules associated with iterators when working with standard algorithms. One shorthand that can help is to think in terms of ranges instead of iterators
C++23 enters the chat :)
This looks very good, I'll definitely bookmark it.
Some LaTeX pedantry: you often have $O(nlogn)$ you probably want $O(n\log n)$ so that the log appears as an operator
2
2
2
u/iMadz13 Feb 02 '23
Great job on the formatting, especially the code blocks! any chance for the LaTeX to be open source? I want to get some of this style into my note-taking snippets for my classes
3
u/jmattspartacus Feb 02 '23
The entire book's LaTeX can be found at https://github.com/HappyCerberus/book-cpp-algorithms/tree/main/chapters
2
u/arulselvan1234 Feb 02 '23
I started reading the book and it's really useful! Appreciate the explanation of license in the beginning. I was looking for something like that.
2
u/RogerV Feb 07 '23
And this is what is daunting about C++ - entire books can be written on very narrow subjects - like a book that covers C++ move semantics, or this subject - the breadth of C++ off-the-shelf algorithms. But the community is fortunate to have such resources.
1
u/benbradley Dec 12 '23
I'd welcome a book on move semantics, as I don't much understand it. I understand (many) STL algorithms, though I've only used a few.
1
u/RogerV Dec 12 '23
Nicolai Josuttis has written a book entirely on the subject of C++ move semantics - probably going to be as deep a dive as there is.
Josuttis has authored several C++ books - one I have is on C++ 20 and I definitely recommend that one too
1
Aug 05 '24
u/HappyCerberus Hi, I m new to C++, I would like to ask why is std::iota considered an algorithm if it is part of the numeric header?
1
1
0
Feb 01 '23
[deleted]
15
u/HappyCerberus Feb 01 '23
I strongly suspect that the problem is with the code examples. And sorry, but I can't help you with such a niche use case (e-reader that doesn't support PDF).
If you figure out a solution that I can implement to generate something that works for you, feel free to create a pull request. I don't mind generating multiple outputs.
0
Feb 01 '23
[deleted]
20
u/HappyCerberus Feb 01 '23
You know. I was about to take the time to respond, but, this is the only valuable thing I have that I'm giving out. My time.
You don't like it? Feel free to block/mute/whatever me forever. You won't be missed.
24
u/CocktailPerson Feb 01 '23
Yikes, dude. He doesn't support EPUB, full stop. If you want support for EPUB, then pay him. Condescension is the proper response to entitlement.
29
u/0xcedbeef Feb 01 '23
looks very nice, how did you format this book?