Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #85522
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Is std::move() a misleading misnomer? |
| Date | 2022-07-21 09:05 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <tbb4ti$1jfm$1@gioia.aioe.org> (permalink) |
| References | <tarkvv$jc4$1@gioia.aioe.org> <4c88540f-b28b-4130-895c-8cf71f17e8f2n@googlegroups.com> |
Anthony Capobianco <kiiwy112@gmail.com> wrote: > On Friday, July 15, 2022 at 2:02:28 PM UTC+2, Juha Nieminen wrote: >> 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. > > The name of the function doesn't describe what it does, it describes the intent of a dev using it. > You use it when you intend to move something. If you only intend to make it an rvalue reference, then you can cast it. > The intent is different. The compiler doesn't care what you call it, your coworkers might. I think that the name 'std::move()' breaks more clarity conventions than that. 'move()', as a verb, would indicate that the function itself does something, in this case, that it does the moving. It would be completely concordant with myriads of other such functions, like std::sort() (which itself does the sorting), std::find() (which itself does the finding), std::copy() (which itself does the copying) and so on. Particularly that last one is extremely telling: Compare "std::copy()" to "std::move()". They both sound, by their name, extraordinarily closely related. It sounds like the former copies stuff from one place to another (doing it itself), while the latter moves stuff from one place to another (likewise doing it itself). It would be highly bizarre if "std::copy()" would mean "this doesn't actually copy anything, it just casts the parameter in such a manner that it becomes copyable". If the latter thing were needed, certainly it would be named something clearer, like for example std::make_copyable(), or std::cast_to_copyable() or something along those lines. Not just std::copy(). Likewise it would be highly bizarre if "std::sort()" did no sorting but instead just somehow cast the parameter into something that can be sorted. std::move() is extraordinarily unique among all standard library functions in that it breaks this fundamental naming convention. Certainly someone who knows well what std::copy() does but doesn't know what std::move() does (but knows about move semantics) would assume that the latter does the same thing as the former, but moving the elements instead of copying them. It can't even be a question of "move" being a short name. The standard library doesn't shy away from using very long names if needed. Take for example: std::filesystem::recursive_directory_iterator::disable_recursion_pending()
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