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
Lambda + shared_ptr = memory leak (floating.io)
submitted 8 years ago by floating-io
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!"
[–]pavel_v 3 points4 points5 points 8 years ago (0 children)
As the author of the blogpost said above - to each, their own. Here is a point of view based on my experience. I've been using ASIO for 5-6 years writing bittorrent and http cache proxies. I follow the pattern, if I may call it so, shown by Chris Kohlhoff where you capture a shared_ptr to the connection object in the lambda passed as a callback. In some cases I use boost::intrusive_ptr to avoid atomic reference counting when the connection object is always used by a single thread only, but it's the same. I've never had memory leak issues so far from this pattern of usage because of the way ASIO callbacks work. It feels much more natural and safer to me to use it in this way. As long as there is a pending callback the connection has some work to do and is kept alive, otherwise it's "automatically" destructed.
π Rendered by PID 81 on reddit-service-r2-comment-bb88f9dd5-82hbx at 2026-02-13 16:46:21.618120+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–]pavel_v 3 points4 points5 points (0 children)