C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Implementing a movable container for immovable objects: std::box<T>

From: Ivan Matek <libbooze_at_[hidden]>
Date: Sat, 14 Dec 2024 23:02:58 +0100
On Sat, Dec 14, 2024 at 10:36 PM Oskars Putans <o.putaans_at_[hidden]> wrote:

>
> Of course. However if you have to both add and remove functionality, those
> are grounds to make it a separate object.
> As this is an even more strict unique_ptr, I would like to see it
> implemented in the standard.
> I believe more frequent usage of this could lead to safer code.
>

I generally agree that having something like this would be nice, but

   1. IDK Rust well, but AFAIK Rust Box works better than std::unique_ptr
   because of Rust language borrow checking, not something you can fix by new
   type in C++
   2. I believe proposal I linked(not related to it in any way personally)
   gives us best emulation of never empty pointer we can get in
   C++(considering weaker language tracking of references/pointers), if after
   reading that proposal you still think your suggestion addresses some
   usecase feel free to correct me, maybe I misunderstood you or proposal I
   linked.

Received on 2024-12-14 22:03:12