Skip to Content
Advanced C++ Programming Cookbook
book

Advanced C++ Programming Cookbook

by Dr. Rian Quinn
January 2020
Intermediate to advanced
454 pages
11h 25m
English
Packt Publishing
Content preview from Advanced C++ Programming Cookbook

How it works...

Sometimes, we wish to change the behavior of our programs but the code that we are creating is always constant, meaning the compiler is capable of determining the value of the branch itself, as shown in this example:

if (!NDEBUG) {}

This is a common if statement used in a lot of code, including the standard library. If debugging is enabled, this code evaluates to true. We use this by adding debug statements to our code, which can be turned off. The compiler is smart enough to see that NDEBUG is true or false and will either add the code or remove the code completely. In other words, the compiler can make a simple optimization and reduce the size of the code as well as remove an unneeded branch as it knows the value of this ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern C++ Programming Cookbook

Modern C++ Programming Cookbook

Marius Bancila

Publisher Resources

ISBN: 9781838559915Supplemental Content