samedi 27 août 2016

Why it's a bad idea to take std::unique_ptr by &&?

I saw Nicol Bolas said

never take unique_ptr by &&, unless you are actually writing its move constructor

in his anwser post.

I thought force the explicit calling of std::move on unique_ptr by && should be a good practice, which notice the coder: from here on, the unique_ptr got moved into another place, don't touch it anymore.

So why did Nicol Bolas say that?

Aucun commentaire:

Enregistrer un commentaire