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

Re: Is this an xvalue, too?

20 views
Skip to first unread message
Message has been deleted

Victor Bazarov

unread,
Jun 6, 2015, 4:44:55 PM6/6/15
to
On 6/6/2015 1:32 PM, Stefan Ram wrote:
> #include <iostream>
> #include <ostream>
> #include <string>
>
> using namespace ::std::literals;
>
> int main()
> { ::std::string t;
> { ::std::string s{ "alpha"s }; t = s; }
> ::std::cout << t << '\n'; }
>
> »s« is used near the end of its lifetime.
> That should be visible for a compiler, too.
> So, is »s« deemed to be an xvalue above and
> is being moved from? (It's kind of like a
> »block return value«.)

These are rhetorical, mostly:

(a) What difference does it make?

(b) Consider that in a regular program xvalue-ness is not observable.
Those things are like const-ness, all in the head of the programmer.

(c) Why don't you get the assembly output and see whether your compiler
does what you think might be needed for "moving" from 's'?

V
--
I do not respond to top-posted replies, please don't ask
0 new messages