Make your Source Code more Readable When Passing a Boolean.

Suppose you have a C++ function declared as follows:

void UpdateDisplay(bool WithDelay);

and somewhere later you want to use this, calling it without the delay.

You could write:

UpdateDisplay(false);

But a simple way to make your source code more readable (and hence more maintainable by yourself and your team in the future) is to write:

const bool WithDelay{false};
UpdateDisplay(WithDelay);

When you compile this code for release the local variable “WithDelay” will be optimised away so this improvement to source code readability incurs no performance cost penalty.