C++ is a high-level programming language and offers many abstract programming constructs that make programmers amazingly productive. But, the higher the abstraction level is, the greater is the threat of obscuring the low-level performance details. Optimally, we want to write clear, understandable and maintainable code but without compromising performance in the process. For this reason, compilers will try to optimize the code automatically and improve the performance so that we can have the better of two worlds—readable code and good machine-level performance.
One must say that compilers have become quite sophisticated in doing so over the years. They have many amazing tricks up their sleeves as we will see, so we should be better focusing on clear, understandable code rather than trying to optimize code manually that then ends up being...