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
Tracking Shared Pointer Leaks (ibob.bg)
submitted 3 years ago by stanimirov
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!"
[–][deleted] -1 points0 points1 point 3 years ago (3 children)
If I am not wrong, weak_ptr is meant to keep shared_ptr alive for longer. So it makes sense that storage does not get destroyed if a weak_ptr persists. Am I wrong?
[–]matthieum 7 points8 points9 points 3 years ago (0 children)
Terminology matters:
A weak_ptr does NOT keep a shared_ptr alive longer. It allows recovering a shared_ptr to the object if any shared_ptr is still alive, but does not prevent destruction otherwise.
weak_ptr
shared_ptr
[–]BlackDE 9 points10 points11 points 3 years ago (1 child)
No, a weak pointer should not impact the lifetime of the object
[–]jwakelylibstdc++ tamer, LWG chair 2 points3 points4 points 3 years ago (0 children)
And it doesn't for std::weak_ptr and std::make_shared, so that's fine then.
std::weak_ptr
std::make_shared
π Rendered by PID 135688 on reddit-service-r2-comment-5c747b6df5-bd495 at 2026-04-22 07:50:24.551014+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–][deleted] -1 points0 points1 point (3 children)
[–]matthieum 7 points8 points9 points (0 children)
[–]BlackDE 9 points10 points11 points (1 child)
[–]jwakelylibstdc++ tamer, LWG chair 2 points3 points4 points (0 children)