If you're familiar with object-oriented programming languages, you must have heard of the Gang of Four's design patterns. While they can be implemented in C++ (and often are), this multi-paradigm language often takes a different approach for achieving the same goals. If you want to beat the performance of the so-called coffee-based languages such as Java or C#, sometimes paying the cost of virtual dispatch is too much. In many cases, you'll know upfront what types you'll deal with. If that happens, you can often write more performant code using the tools available both in the language and in the standard library. Out of many, there's a group that we will start this chapter with – the language idioms. Let's start our journey by looking at a few of them.
By definition, an idiom is a construct that recurs in a given language, an expression that's specific to the language. "Native speakers" of C++ should know its idioms...