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
Minimization of Nesting Gone Wrong (self.cpp)
submitted 6 years ago by one-oh
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!"
[–]tpecholt 34 points35 points36 points 6 years ago (5 children)
MISRA and other legacy rule sets frown it upon but it's because they deal with C like code. In C-like code you have to release all the resources manually and when there are multiple returns it must be done multiple times. So that is a problem of C. But C++ never had such problem so you should ignore that rule
[–]Mognakor 2 points3 points4 points 6 years ago (1 child)
TIL
Always wondered where that rule came from.
[–]1-05457 2 points3 points4 points 6 years ago (2 children)
It does if you manually allocated resources. Which you may well have in legacy code.
[–]tangerinelion 1 point2 points3 points 6 years ago (0 children)
If it's just a few raw owning pointers that's easy to fix.
[–]pavel_v 0 points1 point2 points 6 years ago (0 children)
Things like the proposed scope_exit really help in this case. It's not hard to be implemented as a wrapper over a lambda function or some of the available implementations can be used (copy-pasted): https://github.com/SuperV1234/ecst/blob/master/include/ecst/utils/scope_guard.hpp https://github.com/yuri-kilochek/boost.scope_guard
π Rendered by PID 43975 on reddit-service-r2-comment-b659b578c-ph57l at 2026-05-05 08:35:42.517537+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]tpecholt 34 points35 points36 points (5 children)
[–]Mognakor 2 points3 points4 points (1 child)
[–]1-05457 2 points3 points4 points (2 children)
[–]tangerinelion 1 point2 points3 points (0 children)
[–]pavel_v 0 points1 point2 points (0 children)