When can copy elision occur in c++ (apart from RVO and NRVO) -


i understand copy elision can occur in cases other when returning function. i'm not able find evidence of it. can give example of when copy elision occur?

i've tried following, none of 3 copies optimised out

class mystring { public:     mystring(const char* str) : mystr(str)      {      }      mystring(const mystring& str) : mystr(str.mystr)      {      }      std::string mystr; };  class myclass { public:     myclass(mystring str) : mystring(str) {}       mystring mystring; };    int main() {     mystring test("hello");     std::cout << myclass(test).mystring.mystr << std::endl;      return 0; } 


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -