Date: Sun, 15 Dec 2024 14:39:22 +0200
> A consuming move is called a relocation in C++. See Relocating prvalues:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2785r3.html
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2785r3.html>Nontrivial
Relocation via a New owning reference Type:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2839r0.html
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2839r0.html>There
are also some papers about trivial relocatability.
Thank you for pointing these out. Should this proposal be introduced, my
box would become a lot more intuitive as it could be a very simple use of
relocatable-only structure for dynamically-allocated types. I believe this
could be introduced in a valid way without P2785, but it would
greatly benefit from it as otherwise the contained item has to be
initialized in some way in order to satisfy the invariants. In regards to
P2839, an owning reference type seems to be very close to what I had
wanted, but it does introduce changes to the language itself and thus has a
lot of challenges in implementation and that is not my goal. I suppose this
would be a standard library alternative of P2839, while providing custom
allocators and destructors. Something like an std::owning_reference or
std::strict_ptr, or std::valid_ptr is probably a better name for this. The
box name does come from rust and it would probably benefit by being named
something more descriptive. relocation would also enable a relocation into
a unique_ptr which would be very handy.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2785r3.html
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2785r3.html>Nontrivial
Relocation via a New owning reference Type:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2839r0.html
<https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2839r0.html>There
are also some papers about trivial relocatability.
Thank you for pointing these out. Should this proposal be introduced, my
box would become a lot more intuitive as it could be a very simple use of
relocatable-only structure for dynamically-allocated types. I believe this
could be introduced in a valid way without P2785, but it would
greatly benefit from it as otherwise the contained item has to be
initialized in some way in order to satisfy the invariants. In regards to
P2839, an owning reference type seems to be very close to what I had
wanted, but it does introduce changes to the language itself and thus has a
lot of challenges in implementation and that is not my goal. I suppose this
would be a standard library alternative of P2839, while providing custom
allocators and destructors. Something like an std::owning_reference or
std::strict_ptr, or std::valid_ptr is probably a better name for this. The
box name does come from rust and it would probably benefit by being named
something more descriptive. relocation would also enable a relocation into
a unique_ptr which would be very handy.
Received on 2024-12-15 12:39:37