Introduction
In Chapter 2A, No Ducks Allowed – Types, and Deduction, we briefly touched on some concepts, such as smart pointers and move semantics. In this chapter, we'll be exploring them further. It turns out that these topics are very closely related to resource management and writing robust code (code that will run often and for long periods without problems).
To understand what happens, we are going to explore where variables get placed in memory, as well as when and what happens when they go out of scope.
We will look at what the compiler generates as assembler code for what we enter, and we will explore how all of this is affected when an exception occurs.
Variable Scope and Lifetime
In Chapter 2B, No Ducks Allowed – Templates, and Deduction, we discussed variable scope and lifetimes. Let's quickly go through their different types:
Scope:
- Local scope (also known as block scope): This applies to anything that's declared within a block that is enclosed...