Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is 'auto const' and 'const auto' the same?

Is there a semantic difference between auto const and const auto, or do they mean the same thing?

like image 244
steffen Avatar asked May 22 '12 20:05

steffen


People also ask

What is const auto?

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.

Is Auto A reference in C++?

One of the first things that C++ programmers learn about auto is that bare auto never deduces a reference.

What is Auto& in C++?

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.


1 Answers

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.

like image 127
AJG85 Avatar answered Oct 31 '22 05:10

AJG85