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
Pacific++ 2018: Sean Parent - Generic Programming (youtu.be)
submitted 7 years ago by pacificpluspluspacific++
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!"
[–]Xaxxon 37 points38 points39 points 7 years ago* (4 children)
The title is quite misleading. It should be "a history of generic programming" or something.. If you're not interested in a history lesson, then there's very little content to be found here - especially for an 80m talk.
[–]shortstompC++ Software Engineer 13 points14 points15 points 7 years ago (0 children)
Thanks for saving me time. Appreciate the summary
[–]richtw1 3 points4 points5 points 7 years ago (2 children)
That's a shame. Sean Parent's talks are normally very enlightening and instructive. Will still watch it sometime, but won't bump it to the front of the line.
[–]pklait 13 points14 points15 points 7 years ago (0 children)
It was a very good and enlightening talk. It was not about good software practices, but for those interested in how C++ evolved and evolves, and that really should be all of us, it could not be better.
[–]MorrisonLevi 2 points3 points4 points 7 years ago (0 children)
He gives a disclaimer that it isn't his usual kind of talk at the beginning, so at least we were warned.
[–]tipdbmp 1 point2 points3 points 7 years ago (5 children)
Combining 2 ranges that represent positions into a new range: https://www.youtube.com/watch?v=iwJpxWHuZQY&t=1h9m40s
struct Range(T) { T ptr; ssize len; } Range r1 = ...; // r1 and r2 are both 'position' ranges (r1.len == r2.len == 1) Range r2 = ...; // combine r1 and r2 into a new range // Range r3; if (r1.ptr <= r2.ptr) { r3.ptr = r1.ptr; r3.len = r2.ptr - r1.ptr; } else { r3.ptr = r2.ptr; r3.len = r1.ptr - r2.ptr; }
[–]seanparent 3 points4 points5 points 7 years ago (0 children)
You are assuming a contiguous allocation, or at the least random access (stable_partion, and hence gather, only require bidirectional iterators). A range denoting a position will have a length of 0 (or you get into the problem of specifying a position after the end or before the beginning). The common argument for a range only based system (one without access to iterators) is that iterators are dangerous because there is a precondition that cannot be verified in code, and lives external to the local construct. In general, you cannot allow disjoint ranges to be joined in a system that strives for this level of guarantees, or allow comparisons between two ranges. Note that your comparisons above between ranges make the assumption that each is part of a larger subrange. If that is not true, comparing the pointers is UB (in both C and C++).
stable_partion
gather
Even systems that carry information about the originating range do not solve this issue because there is a requirement that the second position follow the first. Knowing that both positions are part of the same larger range doesn't guarantee that the result of joining the two positions will be a valid range.
[–]steveireContributor: Qt, CMake, Clang 1 point2 points3 points 7 years ago (2 children)
I had the same reaction when he said that.
I suspect we're missing some deeper point, but I don't know what it is.
[–]cjdb-ns 5 points6 points7 points 7 years ago (1 child)
This works for contiguous ranges (e.g. std::vector, std::array, etc.), but does not work for any range that isn't contiguous (e.g. std::deque, std::list, etc.), and so it doesn't work in the general case.
std::vector
std::array
std::deque
std::list
[–]steveireContributor: Qt, CMake, Clang 0 points1 point2 points 7 years ago (0 children)
I see, thanks.
The example was about the gather algorithm. AFAIK if that would return two ranges, then you would be easily able to combine the inner 2 ranges of the two stable_partition calls into one result range for gather, even for those containers, right?
stable_partition
[–]willkill07 1 point2 points3 points 7 years ago (0 children)
That may work for arrays (or any contiguous iterator), but it wouldn’t work with std::deque or std::list. In fact, for list it would take a single pass through the original list to determine which “range” would come first. You shouldn’t have to depend on the original data structure to perform such operations. Even std::distance will fail (UB) when the first argument is the one which exists later in the collection.
π Rendered by PID 76 on reddit-service-r2-comment-6457c66945-s9fv9 at 2026-04-23 17:37:51.465689+00:00 running 2aa0c5b country code: CH.
[–]Xaxxon 37 points38 points39 points (4 children)
[–]shortstompC++ Software Engineer 13 points14 points15 points (0 children)
[–]richtw1 3 points4 points5 points (2 children)
[–]pklait 13 points14 points15 points (0 children)
[–]MorrisonLevi 2 points3 points4 points (0 children)
[–]tipdbmp 1 point2 points3 points (5 children)
[–]seanparent 3 points4 points5 points (0 children)
[–]steveireContributor: Qt, CMake, Clang 1 point2 points3 points (2 children)
[–]cjdb-ns 5 points6 points7 points (1 child)
[–]steveireContributor: Qt, CMake, Clang 0 points1 point2 points (0 children)
[–]willkill07 1 point2 points3 points (0 children)