Is there a semantic difference between auto const
and const auto
, or do they mean the same thing?
C++ auto auto, const, and referencesThe auto keyword by itself represents a value type, similar to int or char . It can be modified with the const keyword and the & symbol to represent a const type or a reference type, respectively. These modifiers can be combined.
One of the first things that C++ programmers learn about auto is that bare auto never deduces a reference.
Deduces the type of a declared variable from its initialization expression. The C++ standard defines an original and a revised meaning for this keyword. Before Visual Studio 2010, the auto keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime.
The const
qualifier applies to the type to the immediate left unless there is nothing to the left then it applies to the type to the immediate right. So yup it's the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With