957fc174   
   From: 0xCDCDCDCD@gmx.at   
      
   On 27.09.2011 19:24, Thiago Adams wrote:   
   >> On 26 set, 19:28, Seungbeom Kim wrote:   
   > ....   
   >> If you provide a move constructor, consider this example:   
   >>   
   >> string a = ...;   
   >> use(a); // before move   
   >> string b = std::move(a);   
   >> use(a); // after move   
   >>   
   >> When 'a' is moved from, the change of its contents will be visible to   
   >> the client. Therefore, 'string' is not an immutable string anymore, and   
   >> a const data member doesn't fit in the class.   
   >>   
   >> I'd almost like to conclude that "movability" and "immutablility" are   
   >> mutually exclusive.   
   >   
   >   
   > Yes I Agree. The move operation is a non-const operation.   
   > But.. some "moves" happens just before the destructor and I guess   
   > the only point will see the transformations is the destructor.   
   >   
   > For instance:   
   >   
   > string f()   
   > {   
   > string s("new string");   
   > return s;   
   > }   
   >   
      
      
   Hmm ... in a move-enabled compiler & library, `s` will certainly be   
   moved on return (if RVO doesn't kick in).   
      
   But what about:   
      
   string f() {   
    string const s("new string");   
    return s;   
   }   
      
   will `s` be moved here?   
      
   cheers,   
   Martin   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|