← Back to context

Comment by tcfhgj

1 hour ago

Why not though?

Have a boxed object have implemented drop, then when the box leaves some scope the Box will clean up it's stuff (drop implementation if there is any) and deallocate it's memory using the allocator (which the arena will treat as noop).

Yes, that would work. But you would need to carry pointer to allocator inside box and it is extra code to run for every object.