std::string s1 = "hello";
std::string s2 = std::move(s1);
std::string s3 = std::string("hello");
std::string &&r3 = std::move(s3);
std::string s4{r3};
The compiler I use is g++ 7.5.0. The compile command is g++ -Wall -g source.cpp
. I use gdb
to see which constructor is called. I think only s2
calls the move constructor and the others use copy constructor. Am I right? Would you like to tell me why?
Aucun commentaire:
Enregistrer un commentaire