Post AjpJQ34AzKERYDB2CO by fasterthanlime@hachyderm.io
(DIR) More posts by fasterthanlime@hachyderm.io
(DIR) Post #AjpJQ2CeCLPisC8HlQ by fasterthanlime@hachyderm.io
2024-07-11T16:25:51Z
0 likes, 0 repeats
I'm reading up about C++ move semantics and I don't understand why anybody in the history of humankind has ever tried defending this language.
(DIR) Post #AjpJQ34AzKERYDB2CO by fasterthanlime@hachyderm.io
2024-07-11T16:27:37Z
1 likes, 0 repeats
me: please move thisclang++: I copied this, do you like this?me: no, please MOVE thisclang++: hey you deleted the copy constructorme: yes. I need you to move this.clang++: have you tried not deleting the copy constructor
(DIR) Post #AjpJQ3ocCfNXsEu7aC by Ace6V8h03hxzselrPM.jeff@mk.magicka.org
2024-07-11T16:35:10.721Z
0 likes, 0 repeats
@fasterthanlime@hachyderm.io std::move
(DIR) Post #AjpJQ6Kaqk99fzsghk by fasterthanlime@hachyderm.io
2024-07-11T16:28:37Z
0 likes, 0 repeats
clearly I don't know what I'm doing in this instance, but I'm not convinced anyone else does, either
(DIR) Post #AjpJRVd2HPaoQOB91s by deoxys314@neovibe.app
2024-07-11T16:30:17Z
1 likes, 0 repeats
@fasterthanlime Just add more std::move(). It might or might not work, but it might also cause confusing errors!
(DIR) Post #AjpJU46x2tP3wvOGau by Ace6V8h03hxzselrPM.jeff@mk.magicka.org
2024-07-11T16:35:54.403Z
0 likes, 0 repeats
@deoxys314@neovibe.app @fasterthanlime@hachyderm.io call it std::bust_a_move
(DIR) Post #AjpJUuwUcVWrnpuA9Q by fasterthanlime@hachyderm.io
2024-07-11T16:34:03Z
2 likes, 0 repeats
pleaseyou cannot be serious
(DIR) Post #AjpRjZtLy2QiUawDPE by arnelson@fosstodon.org
2024-07-11T16:36:06Z
1 likes, 0 repeats
@fasterthanlime probably needs both a move constructor and a move assignment operator, see the "rule of zero/three/five" (https://en.cppreference.com/w/cpp/language/rule_of_three), like most things in C++ it's verbose and tedious and you'd never know what you were doing wrong without reading about it first, but it does work if you're consistent.
(DIR) Post #AjpRjb0Tp1izwzHQ9Y by arnelson@fosstodon.org
2024-07-11T16:39:20Z
0 likes, 0 repeats
@fasterthanlime of course there are some containers and smart pointers that just refuse to use a move constructor no matter what you do, but if you add move constructors and move operator=, then delete the copy constructor and copy operator=, you'll at least know for certain when this happens instead of having something copied silently.