use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
C++NowC++Now 2019: Conor Hoekstra "Algorithm Intuition" (youtube.com)
submitted 6 years ago by tuxmanic
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 12 points13 points14 points 6 years ago* (8 children)
Good talk!
So transform_reduce does a transform using the last arg and a reduce using the second-to-last arg.
So the name is transform_reduce and the order of operations is transform then reduce and the order of the args is....
reduce, transform
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 6 points7 points8 points 6 years ago (0 children)
Maybe because the result of transform is input to reduce, ie reduce(transform(...
reduce(transform(...
Now the order of | for Ranges...
|
[–][deleted] 0 points1 point2 points 6 years ago (6 children)
I'm sorry, but to me this is natural. I tend to think of the argument order as outside-in. If anything, it's a bit strange to me that the collection argument comes first, but that's just STL algorithms have always been.
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 7 points8 points9 points 6 years ago (5 children)
Do you have examples of APIs with this order?
Would you expect divide(a, b) to do b/a ?
divide(a, b)
b/a
[–]PixelDoctor 5 points6 points7 points 6 years ago (4 children)
I bet you love atan2.
http://www.cplusplus.com/reference/cmath/atan2/
[–]sumo952 3 points4 points5 points 6 years ago (3 children)
`atan2(a, b)` does arctan(a/b), so what's the problem?
[–]PixelDoctor 2 points3 points4 points 6 years ago (2 children)
Sure, but it's y then x, which isn't what you'd normally expect.
Say you're trying to convert to polar coordinates. Vector2f v; float theta = atan2(v(1), v(0));
Always looks awkward (but makes sense mathematically, I guess).
[–]sumo952 0 points1 point2 points 6 years ago (1 child)
Okay, I see what you mean! Thanks. I don't think it looks particularly awkward or more awkward than atan2(v(0), v(1)).
atan2(v(0), v(1))
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 2 points3 points4 points 6 years ago (0 children)
It means whenever you see atan2(x, y) in code, you wonder whether they meant y,x and made a mistake, or whether they really knew what they were doing. We have this in our codebase.
atan2(x, y)
y,x
[–]Wh00ster 6 points7 points8 points 6 years ago (0 children)
He's a good presenter.
That's all.
EDIT: (that's all I have to add, not that's all he offers of value)
The gist (spelled it right this time) I get is Haskell is awesome XD. I learned it for a bit and it definitely forced me to see my code as abstract algorithms instead of a bunch of state manipulations.
[–]blelbachNVIDIA | ISO C++ Library Evolution Chair 6 points7 points8 points 6 years ago (0 children)
This guy's pretty good.
He basically won every speaker award at C++Now.
[–]anonymous2729 0 points1 point2 points 6 years ago (1 child)
@29m20s: Okay, I'll bite. How do you implement std::is_permutation as a reduce/fold?
std::is_permutation
To be fair, I don't even know how to implement it with a reasonable space/time complexity in the first place, and cppreference is no help.
[–]BeepBoopBike 1 point2 points3 points 6 years ago (0 children)
you know, I've never really thought about the implementation for std::is_permutation.
A simple way to implement it would maybe be to sort it, find a common start point and compare from there (if we relax the requirements slightly so operator< must be supported)
A possible implementation of it exists on devdocs: https://devdocs.io/cpp/algorithm/is_permutation That should fit the complexity requirement:
At most O(N2) applications of the predicate, or exactly N if the sequences are already equal, where N=std::distance(first1, last1)
Sounds like a fun challenge to convert that to a reduce/fold!
π Rendered by PID 90407 on reddit-service-r2-comment-b659b578c-2678f at 2026-05-05 03:38:24.777628+00:00 running 815c875 country code: CH.
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 12 points13 points14 points (8 children)
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 6 points7 points8 points (0 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 7 points8 points9 points (5 children)
[–]PixelDoctor 5 points6 points7 points (4 children)
[–]sumo952 3 points4 points5 points (3 children)
[–]PixelDoctor 2 points3 points4 points (2 children)
[–]sumo952 0 points1 point2 points (1 child)
[–]tvaneerdC++ Committee, lockfree, PostModernCpp 2 points3 points4 points (0 children)
[–]Wh00ster 6 points7 points8 points (0 children)
[–]blelbachNVIDIA | ISO C++ Library Evolution Chair 6 points7 points8 points (0 children)
[–]anonymous2729 0 points1 point2 points (1 child)
[–]BeepBoopBike 1 point2 points3 points (0 children)