mardi 27 juillet 2021

What is the difference between int{10} and 10?

As the title, I have two expressions:

int&& a = const_cast<int&&>(int{10});
int&& a = const_cast<int&&>(10);

The first compiling passed, but second not. Why is this happening?

In my view, it's because 10 is a literal and int{10} is a unamed variable. Is it?

Aucun commentaire:

Enregistrer un commentaire