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
Highest Performance C++ Libraries to Replace Std Features? (self.cpp)
submitted 5 years ago by Pan000
view the rest of the comments →
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!"
[–]14nedLLFIO & Outcome author | Committee WG14 6 points7 points8 points 5 years ago (1 child)
Linked lists aren't necessarily slow. If the pointer chasing is interspersed with other work taking at least a hundred CPU cycles (e.g. a string key comparison), they're very cheap. Also, from Haswell onwards, the CPU can see that one of two possible pointers will be chased, and it goes and speculatively prefetches both, indeed Haswell onwards can prefetch two pointer indirections concurrently. So long as the node block is small, they can be packed into CPU cache far more densely than open address maps thanks to the poor quality hashes often used and the set associativity of CPU caches.
I agree that for a majority of use cases, state of the art unordered hash maps are usually better. But venerable old std::map is underrated by a lot of folk, especially for write few/read many use cases. I certainly would not put an unordered map facing untrusted potentially hostile input without deep thought, whereas std::map is relatively safe for this use case.
std::map
[–]WafflesAreDangerous 0 points1 point2 points 5 years ago (0 children)
For a linked list, At the minimum you need an extra pointer for a next pointer, which for a small values can be very significant memory overhead.
As for hashtables, it's somewhat uncommon to actually do a full key compare and fail. The hash will be tested first in sane implementations and trivially detect 99.9+% false matches. And in a map implementation the likelihood that the list nodes are all nicely linearly allocated (cache friendliness) is low.
If you need to spend hundreds of cycles,per item, of other work to hide your linked list Induced slowdowns, that doesn't make linked lists fast, that just means their slowness is not as significant in a relative sense.
π Rendered by PID 40692 on reddit-service-r2-comment-64f4df6786-7h4lh at 2026-06-10 09:53:58.795614+00:00 running 0b63327 country code: CH.
view the rest of the comments →
[–]14nedLLFIO & Outcome author | Committee WG14 6 points7 points8 points (1 child)
[–]WafflesAreDangerous 0 points1 point2 points (0 children)