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,570 of 33,346    |
|    Francis Glassborow to Simon Parmenter    |
|    Re: lvalues, rvalues, temporary values -    |
|    03 Oct 12 09:19:10    |
      From: francis.glassborow@btinternet.com              On 03/10/2012 00:23, Simon Parmenter wrote:       > Hi All       >       > I was just playing around with some test code I had done sometime ago and       > found some behaviour I could not explain; looking up the C++11 standard       > did me no good either.       >       > It may be the std::string implementation - just guessing here.       > So what do you think?       >              I think your problem concerns not recognising a library defined operator.              when you wrote:              s1 + s2 = "Eh?";              the compiler sees:              operator=(s1+s2, "Eh?");              It evaluates s1+s2 as a temporary of type std::string and passes that       along with the second argument to the relevant operator=(). Where the       new features of C++11 cut in is in allowing (in this context) a       temporary to be bound to a non-const reference parameter                     --        [ 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