Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #123750
| From | Andrey Tarasevich <noone@noone.net> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Move semantics with literals |
| Date | 2026-04-18 09:46 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <10s0cha$3b4c6$2@dont-email.me> (permalink) |
| References | <10rlkk9$6hau$1@dont-email.me> <10s0bd5$3b4c6$1@dont-email.me> |
On Sat 4/18/2026 9:27 AM, Andrey Tarasevich wrote:
> Moreover, there's no
> "move semantics" in C++ language. "Move semantics" is a user-level
> concept - something you implement yourself in your user-level code. The
> only thing C++ the language does is provide some low-level primitives to
> help you do that (e.g. rvalue references). But the above example has no
> "move semantics".
>
Of course, the above might be see as a bit self-contradictory. Since I
myself stated that "move semantics" is a user-level concept, you can
always claim that your original example is actually "move semantics",
i.e. it is your user-level vision of it.
After all, for flat types (like `int`) there's not much point in
implementing any kind of move semantics different from their usual copy
semantics. And that's what the original version of your function does.
One can also modify it as follows
int func(int &&a)
{
int result = a * 2;
a = 0;
return result;
}
and then document the behavior, stating that the version of move
semantics implemented by this function zeroes out the original argument
(or modifies it in some unspecified way). For some reason. That is also
perfectly fine.
However, keep in mind that this will not even attempt to modify the
original literal `123`. As I stated in my previous post, a modifiable
temporary of type `int` will be created as an argument for the call. It
is that temporary that will get modified. The literal will remain untouched.
--
Best regards,
Andrey
Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread
Move semantics with literals boltar@caprica.universe - 2026-04-14 14:57 +0000
Re: Move semantics with literals Jonathan Lamothe <jonathan@jlamothe.net> - 2026-04-14 11:01 -0400
Re: Move semantics with literals wij <wyniijj5@gmail.com> - 2026-04-14 23:04 +0800
Re: Move semantics with literals Jonathan Lamothe <jonathan@jlamothe.net> - 2026-04-14 11:10 -0400
Re: Move semantics with literals David Brown <david.brown@hesbynett.no> - 2026-04-14 17:26 +0200
Re: Move semantics with literals Bonita Montero <Bonita.Montero@gmail.com> - 2026-04-14 18:25 +0200
Re: Move semantics with literals Jonathan Lamothe <jonathan@jlamothe.net> - 2026-04-14 13:02 -0400
Re: Move semantics with literals boltar@caprica.universe - 2026-04-15 08:18 +0000
Re: Move semantics with literals Paavo Helde <eesnimi@osa.pri.ee> - 2026-04-15 12:50 +0300
Re: Move semantics with literals Bonita Montero <Bonita.Montero@gmail.com> - 2026-04-15 14:24 +0200
Re: Move semantics with literals boltar@caprica.universe - 2026-04-15 15:07 +0000
Re: Move semantics with literals Bonita Montero <Bonita.Montero@gmail.com> - 2026-04-15 17:49 +0200
Re: Move semantics with literals Bonita Montero <Bonita.Montero@gmail.com> - 2026-04-15 17:51 +0200
Re: Move semantics with literals boltar@caprica.universe - 2026-04-16 08:29 +0000
Re: Move semantics with literals scott@slp53.sl.home (Scott Lurndal) - 2026-04-16 14:41 +0000
Re: Move semantics with literals Chris Ahlstrom <OFeem1987@teleworm.us> - 2026-04-18 06:41 -0400
Re: Move semantics with literals Richard Damon <Richard@Damon-Family.org> - 2026-04-18 12:46 -0400
Re: Move semantics with literals "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-04-15 23:08 -0700
Re: Move semantics with literals Bonita Montero <Bonita.Montero@gmail.com> - 2026-04-16 09:02 +0200
Re: Move semantics with literals "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2026-04-16 04:39 -0700
Re: Move semantics with literals boltar@caprica.universe - 2026-04-14 15:10 +0000
Re: Move semantics with literals Jonathan Lamothe <jonathan@jlamothe.net> - 2026-04-14 11:15 -0400
Re: Move semantics with literals scott@slp53.sl.home (Scott Lurndal) - 2026-04-14 17:17 +0000
Re: Move semantics with literals Jonathan Lamothe <jonathan@jlamothe.net> - 2026-04-14 13:36 -0400
Re: Move semantics with literals boltar@caprica.universe - 2026-04-15 08:21 +0000
Re: Move semantics with literals Andrey Tarasevich <noone@noone.net> - 2026-04-18 10:16 -0700
Re: Move semantics with literals boltar@caprica.universe - 2026-04-19 08:59 +0000
Re: Move semantics with literals boltar@caprica.universe - 2026-04-19 09:09 +0000
Re: Move semantics with literals Andrey Tarasevich <noone@noone.net> - 2026-04-19 12:01 -0700
Re: Move semantics with literals Bonita Montero <Bonita.Montero@gmail.com> - 2026-04-14 17:14 +0200
Re: Move semantics with literals boltar@caprica.universe - 2026-04-14 15:23 +0000
Re: Move semantics with literals Bonita Montero <Bonita.Montero@gmail.com> - 2026-04-14 18:23 +0200
Re: Move semantics with literals Andrey Tarasevich <noone@noone.net> - 2026-04-18 09:27 -0700
Re: Move semantics with literals Andrey Tarasevich <noone@noone.net> - 2026-04-18 09:46 -0700
csiph-web