Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #85238
| From | Bo Persson <bo@bo-persson.se> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Is std::move() a misleading misnomer? |
| Date | 2022-07-15 16:01 +0200 |
| Message-ID | <jjdaaaFpvogU1@mid.individual.net> (permalink) |
| References | <tarkvv$jc4$1@gioia.aioe.org> |
On 2022-07-15 at 14:02, Juha Nieminen wrote: > Let's take a relatively simple line of code: > > v1 = std::move(v2); > > What does that do? Well, we know for certain (at least if the type of 'v1' > and 'v2' has been logically implemented) that 'v1' will contain what > 'v2' contained before this statement. > > But what will 'v2' contain? Why do we care? You move from v2 when you don't need to use its value anymore. > > It depends. (More particularly, it depends on whether the type in > question implements a move assignment operator, and it has been > implemented in the recommended way.) > > But should it really depend on anything? Isn't that statement > expressing the desire to *move* the contents of 'v2' into 'v1', > thus leaving 'v2' empty? (Even if under the hood a deep copy > is being done instead, consistency of behavior would dictate > for 'v2' to become empty nevertheless.) If you pass v2 as a parameter to some other function (or constructor) just before v2 goes out of scope, why spend time making it "empty" just before it goes out of scope? > > The fact is that if we don't know the type of 'v1' and 'v2' > we cannot assume that 'v2' will be empty. No we cannot. So what? > > Since std::move() does not guarantee that the contents will be > moved, isn't it quite a misnomer? > > std::to_rvalue() might be more cryptic, but at least it would > express much better what it's actually doing. There has been proposals for more "obvious" names like enable_move or allow_move, or make_movable. But they all suffer from the problem of being a lot longer to type. And not much easier to read. So "move" has the advantage of being short. We just have to learn what it means. Can't be much harder than to figure out what constexpr or decltype means.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is std::move() a misleading misnomer? Juha Nieminen <nospam@thanks.invalid> - 2022-07-15 12:02 +0000
Re: Is std::move() a misleading misnomer? Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-15 14:43 +0200
Re: Is std::move() a misleading misnomer? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-07-15 06:18 -0700
Re: Is std::move() a misleading misnomer? Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-15 19:09 +0200
Re: Is std::move() a misleading misnomer? Bo Persson <bo@bo-persson.se> - 2022-07-15 16:01 +0200
Re: Is std::move() a misleading misnomer? Juha Nieminen <nospam@thanks.invalid> - 2022-07-16 18:21 +0000
Re: Is std::move() a misleading misnomer? Bo Persson <bo@bo-persson.se> - 2022-07-16 21:11 +0200
Re: Is std::move() a misleading misnomer? Juha Nieminen <nospam@thanks.invalid> - 2022-07-17 14:28 +0000
Re: Is std::move() a misleading misnomer? Gawr Gura <gawrgura@mail.hololive.com> - 2022-07-15 08:34 -0700
Re: Is std::move() a misleading misnomer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2022-07-15 16:03 +0000
Re: Is std::move() a misleading misnomer? Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-15 19:12 +0200
Re: Is std::move() a misleading misnomer? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2022-07-16 19:24 +0000
Re: Is std::move() a misleading misnomer? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-07-15 23:08 +0200
Re: Is std::move() a misleading misnomer? Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-16 11:48 +0300
Re: Is std::move() a misleading misnomer? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-07-16 16:31 -0700
Re: Is std::move() a misleading misnomer? Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-07-16 18:32 -0700
Re: Is std::move() a misleading misnomer? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-07-19 16:41 -0700
Re: Is std::move() a misleading misnomer? wij <wyniijj2@gmail.com> - 2022-07-18 16:14 -0700
Re: Is std::move() a misleading misnomer? Bonita Montero <Bonita.Montero@gmail.com> - 2022-07-19 07:59 +0200
Re: Is std::move() a misleading misnomer? Anthony Capobianco <kiiwy112@gmail.com> - 2022-07-20 05:11 -0700
Re: Is std::move() a misleading misnomer? Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-20 15:26 +0300
Re: Is std::move() a misleading misnomer? Manfred <noname@add.invalid> - 2022-07-21 01:16 +0200
Re: Is std::move() a misleading misnomer? "Fred. Zwarts" <F.Zwarts@KVI.nl> - 2022-07-21 09:47 +0200
Re: Is std::move() a misleading misnomer? Juha Nieminen <nospam@thanks.invalid> - 2022-07-21 09:05 +0000
Re: Is std::move() a misleading misnomer? Paavo Helde <eesnimi@osa.pri.ee> - 2022-07-21 13:12 +0300
Re: Is std::move() a misleading misnomer? red floyd <no.spam.here@its.invalid> - 2022-07-21 13:09 -0700
Re: Is std::move() a misleading misnomer? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2022-07-20 13:08 -0700
csiph-web