home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,576 of 33,346   
   Gene Bushuyev to James K. Lowden   
   Re: lvalues, rvalues, temporary values -   
   05 Oct 12 23:30:50   
   
   From: publicfilter@gbresearch.com   
      
   On Thursday, October 4, 2012 11:40:30 AM UTC-7, James K. Lowden wrote:   
   > On Wed,  3 Oct 2012 09:19:10 -0700 (PDT)   
   ...   
   > When I've defined operator+ on my own objects, it returned a const   
   > object, just to prevent this very thing.  I wonder why std::string   
   > doesn't do that.   
      
   That's not a good solution, as it was mentioned, it would hurt   
   performance by prohibiting moving temporaries.  I think the right   
   solution is to supply correct ref-qualifier to the declaration of   
   operator=   
      
   basic_string& operator= (basic_string other) &   
   {   
       /*move guts from other*/;   
       return *this;   
   }   
      
   I wonder why the standard instead specifies these two overloads:   
   basic_string& operator=(const basic_string& str); basic_string&   
   operator=(basic_string&& str) noexcept;   
      
      
   --   
         [ 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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca