3 ms·
> This is dangerous, but if well documented and understood it might be okay. I agree in principle. I think even something like std::unique_ptr could work; the
by scottlamb 5y ago
> This is dangerous, but if well documented and understood it might be okay.
I agree in principle. I think even something like std::unique_ptr could work; the concern would be self-referential types. Notably Rust doesn't allow those anyway, so I think any Rust type would be fine, not just Copy types.
> Then there is the fact that you basically make every insertion 3x as costly. You better have a good reason to need this given the additional complexity and caveats.
Still might be a lot better than a linked list for small types (due to less RAM spent on pointers and better cache locality because it's contiguous). With the exception of intrusive linked lists of stuff that is separately allocated anyway, I really hate linked lists.