jeudi 25 janvier 2018

Return by value+move vs return by rvalue refernce

What is the difference between

struct Beta {
  //...
  Beta_ab && getAB() && { return move(ab); }
};
Beta_ab ab = Beta().getAB();

This example is from here.

And

struct Beta {
  //...
  Beta_ab getAB() && { return move(ab); }
};
Beta_ab ab = Beta().getAB();

Which is a conceptually identical example from Scot Meyers book. Both examples claim to achieve the same.

What is the difference between them?

Aucun commentaire:

Enregistrer un commentaire