How it works...

One of the best ways to learn how to optimize your C++ code is to learn how to analyze the resulting assembly code that the compiler generates after compilation. In this recipe, we will learn how this analysis is done by looking at two different examples: loop unrolling and pass-by-reference parameters.

Before we look at these examples, let's look at a simple example:

int main(void){ }

In the preceding example, we have nothing more than a main() function. We haven't included any C or C++ libraries and the main() function itself is empty. If we compile this example, we will see that the resulting binary is still pretty large:

In this case, the example is 22kb in size. To show the resulting assembly that the compiler generated ...

Get Advanced C++ Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.