C++ Const Correctness Refresher

By Vladimir Vishnevskii

Const correctness of C++ programs is one of the crucial building blocks for reliable and consistent code. This criticality is reflected in the strict recommendations listed in the C++ Core Guidelines. Unfortunately, in practice, some of the rules are neglected and situations where const correctness should be enforced are often unnoticed. In this short presentation the overview of const correctness concept will be presented along with the real life examples of issues that could be avoided with the help of proper usage of the concept. It will be demonstrated how following the guidelines will encourage better design practices. Special attention will be given to specifics associated with auto type deduction, standard smart pointers and iterators.