jeudi 4 mars 2021

Using possibility to move constant reference

void foo (const std::string& str)
{
   std::string local = std::move(str);
}

I'm really confused that this is allowed. Am I missing something and in some cases it can be used? Like if I know that it's safe to move this string, should I still use this construction, or is it something that is allowed by the compiler but in real life it should be never used?

Aucun commentaire:

Enregistrer un commentaire