Where to Learn C++

This post is an attempt to list down resources I find interesting or useful for learning, polishing, debugging, or exploring C++ programming language. It is unlikely to provide an exhaustive list and I don't necessarily intend to create one. If you have any suggestions, I'm happy to read them.

An alternative title would be: where to read about C++ or my links about C++.

I organized this list into completely arbitrary items with no particular order. It is completely opinionated and each item has a very short explanatory description, link, instruction, and/or any other reference. I swear there is a reason for each entry...

  1. Literature
  2. Standard References
  3. Proposals
  4. The Standard
  5. Implementations
  6. Headers
  7. Source Code
  8. Boost
  9. Conferences
  10. Core Guidelines
  11. Code Style Guidelines
  12. Interactive Exploration
  13. Other

Literature

There are three books on C++ that are good enough to be excluded from my usual "ban on books about programming languages, frameworks and libraries."

book covers

From left to right

  1. Effective Modern C++, Scott Meyers
  2. The C++ Programming Language, Bjarne Stroustrup
  3. C++ Primer, Stanley B. Lippman, Josée Lajole, Barbara E. Moo

If you are beginning your programming journey, you have better chance of learning something if you use the books as complementary resource to your class/course. If you are intermediate or higher, these books are good as "back-to-basics" and to solidify your foundations.

Standard References

The intent is to translate the legal language from the standard to a more programmer friendly language complemented with examples, compatibility matrices, and a good number of other useful resources. Currently there is only one worthwhile community-driven page:

You are likely to use it the most compared to any other entry in this list. This is the case for me.

Proposals

Proposals are my favourites for filling the "would you like to know more" gap. They are C++ standard committee papers that propose changes to the language or standard library. Their goals are to present an idea in understandable way, reason it, and make it look good. This part of their nature makes them often better to read than the actual C++ standard. This is especially evident when they are coming from the outside of the working group and/or compiler circles.

You can find them at C++ Standards Committee Papers index.

Alternatively, if you are looking for proposal regarding a particular feature, you can:

  1. Go to cppreference.com.
  2. Find applicable C++ standard revision, e.g., C++17.
  3. Find feature in one of the matrices, e.g., Structured Bindings and associated P0217R3.
  4. P0217R3 describes wording changes but refers to P0144R2 as original proposal.

The Standard

Also known as ISO/IEC 14882.

c++ logo

This is the primary source. Or rather the working draft of the primary source. Standard is intended to define requirements for compiler and library implementations. It is not necessarily intended as your day-to-day reference document. Nonetheless, it is useful because it can provide you with an authoritative answer.

You can buy the actual standard revisions at the ISO Store.

Draft is available at eel.is/c++draft.

Standard C++ has a homepage at isocpp.org with a good amount of useful resources, i.a., Get Started!, Tour, and Super-FAQ.

Implementations

On the other side of the standard specifications are implementations of said requirements: compilers and standard libraries. It is as awkward to split them into separate list items as it is to have them both here. I rely mostly on standard specification and/or reference and use these from time to time, when I need to consult implementation-defined behaviour or details, options, recommendations.

Headers

The gist of it is, know your include paths. For example to start with:

  1. /usr/include/c++/14.1.1
  2. /usr/include/c++/14.1.1/x86_64-pc-linux-gnu
  3. /usr/include/c++/14.1.1/backward
  4. /usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include
  5. /usr/local/include
  6. /usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/include-fixed
  7. /usr/include

Of course, depending on your compiler, library provider and targets these will vary. Consult your compiler documentation. With GCC you can provide a -v flag to command and find the applicable paths, for example:

$ c++ -v example.cpp -o example
Using built-in specs.
...
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include
 /usr/local/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include-fixed
 /usr/include
End of search list.

They may feel hit-or-miss. It gets especially bad when dealing with multi-target back-compatible headers as they quickly devolve into macro madness. Yet, they are your exact specification of what you are dealing with.

Source Code

I like reading what others wrote. I don't really care if it is bad or not, because I can learn from it nonetheless simply by asking a questions "why?" and "what does this excerpt exactly do?"

Selected pieces of software (alphabetical order):

In general, just take a look at whatever software you use. You might even end up contributing to it and that's always good.

Boost

I have a love-hate relationship with Boost. Nonetheless, its documentation has a number of good examples and recommendations. Even if you don't plan using Boost, it may provide you with solution patterns.

Docs version index is located at boost.org/doc.

Conferences

I'm socially awkward but I do like to listen to knowledgeable people. Even better if I'm interested in the topic they talk about. Isocpp.org maintains a list of worldwide conferences.

Here are channels with recordings from C++ or around C++ conferences:

Core Guidelines

A document maintained by Bjarne Stroustrup and Herb Sutter with a whole lot of recommendations. It is available online at C++ Core Guidelines.

It's not necessary to read it like a book, but doing a full skim at least once would be beneficial to get an idea when to refer to the guideline. Choosing a random topic and reading it on a coffee break is also an option. Whatever the method - read it - it's good.

Code Style Guidelines

Even if you work alone these can be useful as rules may prevent trivial errors and make the code more maintainable in the long run.

Examples of coding styles (alphabetical order):

Interactive Exploration

A good way to build intuition around C++ is to watch the tools do what they are intended to do and inspect the results. An example of such tool is Compiler Explorer.

We can get similar results in local environment. For example, we can make GCC emit assembly output with -S flag. Another command, c++filt(1) can be used to demangle symbols in the output:

$ g++ -O3 -S something.cpp -o - | c++filt

Other than assembly output, we can also view preprocessor output with -E flag or cpp(1) command. In general, building minimal examples to see certain behaviours is a decent debugging method. Of course, full blown debuggers are also an option for exploration.

Other

I don't have much to say about these. They listed here only to avoid questions about them.

Older revision of this article had some additional notes, but even at the time of writing I was struggling to see any good points in my comments.