lundi 10 janvier 2022

decltype determines a type of const double& [duplicate]

I have seen the following code (in cppreference.com)

struct A { double x; };
const A* a;
 
decltype(a->x) y;       // type of y is double (declared type)
decltype((a->x)) z = y; // type of z is const double& (lvalue expression)

Can someone explain how it turns out that z is const double&?

Thanks

Aucun commentaire:

Enregistrer un commentaire