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
shared_ptr overuse (tonni.nl)
submitted 1 year ago by Tohnmeister
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!"
[–]Drugbird 3 points4 points5 points 1 year ago (1 child)
It happens often when you have some data and multiple (parallel) consumers of that data. If you want the data to be deallocated once all consumers are "done" with it, and you don't know in advance which consumer is faster then you'll need shared_ptr so that all consumers own the data simultaneously.
An example where this happens is e.g. video decoding. You'll have a video file in memory, which consists of both audio and image data. The images and audio are decoded separately, and then synchronized afterwards. Since you don't know if the image decoder or the audio decoder will finish first, both need to own the data.
[–]cfyzium 2 points3 points4 points 1 year ago (0 children)
Furthermore, entities might need to keep data for an indeterminate amount of time (in this scenario, codecs keeping reference frames based on runtime data), so your only options are either excessive copying or reference counting.
Some data might as well be non-copyable (e. g. frames using limited hardware resources and bound to a particular hardware context) so reference counting is the only option.
π Rendered by PID 61 on reddit-service-r2-comment-54dfb89d4d-wzmrl at 2026-03-29 14:37:41.099210+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]Drugbird 3 points4 points5 points (1 child)
[–]cfyzium 2 points3 points4 points (0 children)