dimanche 26 mai 2019

static_cast int to reference to int?

Is it allowed:

int x = 1;
int r1 = static_cast<int&>(x);
int r2 = static_cast<int&&>(x)

If it is, then what is the meaning of these casts?

The question has arisen from this code:

int x = 1;
int y = 2;
std::swap(x, y); // uses int temp = std::move(x);

Aucun commentaire:

Enregistrer un commentaire