mercredi 27 juillet 2016

Does C++11 "auto" keyword retrieve "cv-qualifier" at all? I've got conflict samples

It's said the "auto" doesn't retrieve cv-qualifier, so I did an experiment:

const int i = 0;
auto r1 = i;
auto& r2 = i;
r1 = 3;//ok
r2= 3;//compilation error

Seems when constructing a value, cv-qualifier is not with the new variable, but used with reference "&", the cv-qualifier is with it. Why is that, does auto retrieves "cv-qualifier" at all?

Aucun commentaire:

Enregistrer un commentaire