jeudi 28 novembre 2019

C++ std::move and global variables

Is it useful and logical to use std::move for a global variable?

Example code:

const std::string gvar = "Global variables.......";
Print(const std::string&& str)
{
  std::cout << "Rvalue: " << str << std::endl;
}

int main( void )
{
  Print( std::move(gvar) );
  std::cout << gvar << std::endl;
  return 0;
}

Aucun commentaire:

Enregistrer un commentaire