You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 (constauto structure : storage)
Most likely the intended type is const Structure*, which can be deduced using auto* instead of auto.
Example with deduced type const Structure*:
for (constauto* structure : storage)
The text was updated successfully, but these errors were encountered:
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*
:The text was updated successfully, but these errors were encountered: