Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: moving primitives

27 views
Skip to first unread message
Message has been deleted

Juha Nieminen

unread,
Apr 28, 2015, 9:23:14 AM4/28/15
to
Stefan Ram <r...@zedat.fu-berlin.de> wrote:
> int main() { int && i = ::std::move( 3 ); ::std::cout << i << '\n'; }

There is no difference between "something = std::move(something_else)"
and "something = something_else" when that type has no move constructor.

As for having a reference to a temporary, the temporary will exist for
as long as the reference (ie. the current scope).

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Öö Tiib

unread,
Apr 28, 2015, 3:38:10 PM4/28/15
to
On Tuesday, 28 April 2015 16:23:14 UTC+3, Juha Nieminen wrote:
> Stefan Ram <r...@zedat.fu-berlin.de> wrote:
> > int main() { int && i = ::std::move( 3 ); ::std::cout << i << '\n'; }
>
> There is no difference between "something = std::move(something_else)"
> and "something = something_else" when that type has no move constructor.

'std::move' just returns a rvalue reference to its argument
and the "something" is rvalue reference so no constructors were
called in the process?

> As for having a reference to a temporary, the temporary will exist for
> as long as the reference (ie. the current scope).

Yes, that is true, so sane compiler just optimized the bloat away and
made "std::cout << 3 << '\n';" out of it.

0 new messages