Articles & Books

Template Arguments--Rainer Grimm

The series continue.

Template Arguments

by Rainer Grimm

From the article:

It is quite interesting how the compiler deduces the types for the template arguments. To make it short, you get most of the time the type you expect. The rules do not only apply to function templates (C++98) but also to auto (C++11), to class templates (C++17), and concepts (C++20)...

7 Top Tips for Debugging C++--Greg Law

How do you do it?

7 Top Tips for Debugging C++

by Greg Law

From the article:

Brian Kernighan famously said, “Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it?”. For me, this doesn’t just mean “keep it simple.” It also means debugging is central to programming – you cannot be a great programmer without being great at debugging. Hopefully, my favorite C++ debugging tips will help you be as clever and productive debugging your code as you are writing it in the first place...

Decent concepts--Andrzej Krzemieński

Are you using concepts?

Decent concepts

by Andrzej Krzemieński

From the article:

Last year I published two posts on writing concepts:

  1. Concept Archetypes,
  2. Semantic requirements in concepts.

Having had some time to reflect upon these posts, I now realize that the model presented in them is not complete. In this post I want to give a more coherent view of concepts...

A list of bad practices commonly seen in industrial projects-- Thomas Lourseyre

Are you in such an environement?

A list of bad practices commonly seen in industrial projects

by Thomas Lourseyre

From the article:

If you ever worked in a company-size software project (with numerous developers), there is a good chance that the codebase was, at least, pretty messy.

In these days, most industrial C++ developers are not experts. You will often work with developers with a Java or Python background, people who just learnt C++ at school and don’t really care that much about the language and old developers who code in “C with classes” instead of C++.

Having worked on a few industrial projects myself, I realized there are some recurring patterns and bad practices. If you happen to teach your coworkers to avoid these bad practices, you will all take a huge step toward a beautiful codebase and it will be beneficial to you, your coworkers and your project.

Here is a non-exhaustive list of these common bad practices...

Quick Q: Overload resolution between object, rvalue reference, const reference

Quick A: the better match is picked, and an error generated if there none.

Recently on SO:

Overload resolution between object, rvalue reference, const reference

As there is only one parameter, the rule is that one of the three viable parameter initializations of that parameter must be a better match than both the other two. When two initializations are compared, either one is better than the other, or neither is better (they are indistinguishable).

Without special rules about direct reference binding, all three initializations mentioned would be indistinguishable (in all three comparisons)...

GotW #102 Solution: Assertions and "UB" -- Herb Sutter

Solution just posted:

GotW #102 Solution: Assertions and "UB"

by Herb Sutter

From the article:

Now that we have considered assertions, postconditions, and preconditions in GotWs #97-101, let’s pause and reflect: To what extent does a failed contract imply "UB"... either the Hidden Dragon of Undefined Behavior, or the Crouching Tiger of Unspecified Behavior?