There are a number of places in the code that can and should be using const, but currently aren't. I thought I'd create an issue to track such updates in one place.
One notable example is the use of getStructures, and iterating over the corresponding Structure* elements.
Related to the above, it should be noted that when auto deduces a pointer type, applying const to it will apply to the pointer, not the underlying type. This is similar to type aliases with using and typedef. When a type alias refers to a pointer, applying const to the alias applies it to the pointer, not the underlying pointed to type.
Example of auto deducing Structure*:
for (auto structure : storage)
Applying const to the above will deduce Structure* const, which may not be what was intended:
for (const auto structure : storage)
Most likely the intended type is const Structure*, which can be deduced using auto* instead of auto.
There are a number of places in the code that can and should be using
const
, but currently aren't. I thought I'd create an issue to track such updates in one place.One notable example is the use of
getStructures
, and iterating over the correspondingStructure*
elements.Related to the above, it should be noted that when
auto
deduces a pointer type, applyingconst
to it will apply to the pointer, not the underlying type. This is similar to type aliases withusing
andtypedef
. When a type alias refers to a pointer, applyingconst
to the alias applies it to the pointer, not the underlying pointed to type.Example of
auto
deducingStructure*
:Applying
const
to the above will deduceStructure* const
, which may not be what was intended:Most likely the intended type is
const Structure*
, which can be deduced usingauto*
instead ofauto
.Example with deduced type
const Structure*
: