mardi 3 octobre 2017

What do we call a constructor like this C::C(const C&&)? And is there any use of it other than prohibit move from const?

I can have declaration of three constructors like

  • copy constructor C::C(const C&)
  • move constructor C::C(C&&)
  • C::C(const C&&)

in a class without ambiguity.

What do we call a constructor like C::C(const C&&)? Does it have some kind of nickname?

I can come up with =delete to explicitly prohibit users from unknowingly trying to move from const and restricting the automatic copy fallback effect. This reminds users what they are doing.

And is there any other use of it?

Aucun commentaire:

Enregistrer un commentaire