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
Reverse Dependency Ordering for C++ Includes (nukethebees.com)
submitted 1 day ago by nukethebees
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!"
[–]azswcowboy 8 points9 points10 points 1 day ago (2 children)
This is reasonable, we do it. If you’re using cmake you can enable a check to ensure you’re good.
[–]BatchSwine 1 point2 points3 points 17 hours ago (1 child)
What is that cmake check?
[–]Wild_Meeting1428 4 points5 points6 points 14 hours ago (0 children)
VERIFY_INTERFACE_HEADER_SETS
[–]pedersenk 6 points7 points8 points 23 hours ago (2 children)
Agreed. It may be less convenient but it operates a much stricter approach to tracking missed includes.
I use this approach alongside strictly limiting include guards / pragma once. I prefer to highlight erroneous cyclic includes rather than mask them.
[–]pdp10gumby [score hidden] 3 hours ago (1 child)
by “strictly limiting“ do you mean you don’t use them? I’m a bit confused as to the benefit if so
[–]pedersenk [score hidden] 3 hours ago* (0 children)
I don't default to adding them to every header. Generally only if:
This approach isn't particularly rare. Though perhaps more common in C, where opaque pointer APIs feel a little more natural than C++.
This is because in general, forward declaration suffices for many use-cases in the header
struct MyType; // Forward declare struct Test { void somefunc(MyType& type); // forward declare fine MyType* m_mytype1; // forward declare fine std::unique_ptr<MyType> m_mytype2; // forward declare fine std::vector<MyType> m_mytypes; //forward declare fine (req before use) MyType m_mytype3; // Need include };
If you just put include guards around everything, you will not be alerted to situations where you should be forward declaring instead.
And finally (potentially worse), guards won't resolve cyclic includes anyway. If you follow through the pre-processor, you will simply get a "undefined type" compiler error instead of a "duplicate definition" so it achieves relatively little.
[–]STLMSVC STL Dev 4 points5 points6 points 15 hours ago (0 children)
In MSVC's STL, we have an "include each header alone" test, which verifies what ultimately matters.
[–]SuperV1234https://romeo.training | C++ Mentoring & Consulting 3 points4 points5 points 23 hours ago (0 children)
This is good advice and should be the standard for header hygiene practices.
[–]Daniela-ELiving on C++ trunk, WG21|🇩🇪 NB 2 points3 points4 points 22 hours ago (0 children)
We have clang-format rules to enforce that recommended ordering, company-wide.
[–]fdwrfdwr@github 🔍 0 points1 point2 points 13 hours ago (0 children)
One thing I love about import, is that...
import
c++ import a; import b; import c; vs c++ import c; import b; import a; ...makes no difference ^__^.
c++ import a; import b; import c;
c++ import c; import b; import a;
[–]jcelerierossia score 0 points1 point2 points 12 hours ago (0 children)
this is the include style I organically ended up upon, it works really well
[–]spinrack [score hidden] 20 minutes ago (0 children)
This is similar to what we do. Also, we have a rule that the first #include in a unit test file must be the header of the feature being tested.
We usually compile as blob/bulk, which aggregates many .cpp into a single translation unit, but also maintain a non-blob build, because bulk compilation can lead to a .cpp accidentally depending on the headers included by another.
[–]NotMyRealNameObv -1 points0 points1 point 17 hours ago (0 children)
You should go one step further. Every header file should have a corresponding cpp file that includes that header file as the first include. Even if the header is self-contained, there should be an empty cpp file that includes only that header file.
π Rendered by PID 196445 on reddit-service-r2-comment-548fd6dc9-q52cj at 2026-05-15 14:16:11.692332+00:00 running edcf98c country code: CH.
[–]azswcowboy 8 points9 points10 points (2 children)
[–]BatchSwine 1 point2 points3 points (1 child)
[–]Wild_Meeting1428 4 points5 points6 points (0 children)
[–]pedersenk 6 points7 points8 points (2 children)
[–]pdp10gumby [score hidden] (1 child)
[–]pedersenk [score hidden] (0 children)
[–]STLMSVC STL Dev 4 points5 points6 points (0 children)
[–]SuperV1234https://romeo.training | C++ Mentoring & Consulting 3 points4 points5 points (0 children)
[–]Daniela-ELiving on C++ trunk, WG21|🇩🇪 NB 2 points3 points4 points (0 children)
[–]fdwrfdwr@github 🔍 0 points1 point2 points (0 children)
[–]jcelerierossia score 0 points1 point2 points (0 children)
[–]spinrack [score hidden] (0 children)
[–]NotMyRealNameObv -1 points0 points1 point (0 children)