mercredi 20 juin 2018

C++ constructor and rvalue

I was reading this post. The code under attention is the following

struct S {
  void func() &;
  void func() &&;
};

S s1;
s1.func(); // OK, calls S::func() &
S().func(); // OK, calls S::func() &&

I think I understood what are the reference qualifiers. My question is more basic: what is S()? Is it a (copy) creator? Why is it an rvalue? It seems that in that blog and also in other places it is taken for granted. What am I missing?

Aucun commentaire:

Enregistrer un commentaire