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,675 of 33,346    |
|    =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All    |
|    Re: Constructing pair |
|    22 Nov 12 15:24:26    |
      From: daniel.kruegler@googlemail.com              Am 22.11.2012 20:28, schrieb Zhihao Yuan:       > On Thursday, 22/11/2012 1:46:09 AM UTC-6, Frank Birbacher wrote:       >> Does to following code reliably construct a pair that holds a given       >> value twice? Is it true that pair::first will be constructed before       >> pair::second? Does make_pair only forward arguments?       >       > No. Actually, It copies its argument first, then copies t and move t       > into make_pair's argument list, in an indeterminate sequence. The       > moving /b/ can happen before the copying /a/.              No, it is not moving nor copying the arguments at that point - std::move       really is a red herring. The call to std::move just produces an xvalue       of T (assuming that T is not an lvalue-reference). Certainly the       arguments are evaluated in an indeterminate sequence, but I don't see       how that matters in this case. The actual copy/move operation happens in       the /mem-initializer-list/ which again is evaluated in order, thus the       actual move-construction of second will happen after the       copy-construction of first.              (I'm ignoring std::reference_wrapper-unpacking, but in this case there       is no "move" of a value taking place)              HTH & Greetings from Bremen,              Daniel Krügler                     --        [ 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