Type qualifiers extend our control over variable behaviour. There are four type qualifiers in C: const
, volatile
, restrict
, and _Atomic
(C89, 89, 99, 11, respectively). Only the first two are available in C++.
A non-exhaustive list of qualifiers:
restrict
The restrict
specifier is used on pointers, and is used to tell the compiler that the pointer is the only access to the object it points to, i.e., we cannot get to the pointer value any other way.
This is especially relevant with pointer based functions (like those in stdlib.h or string.h). For string processing functions, this is an important optimisation tool.