3 ms·
You can always implement that sort of thing with `unsafe` blocks. Since any use of raw, non-smart pointers in C++ counts as unsafe, I think it'd be pretty okay
by geofft 12y ago
You can always implement that sort of thing with `unsafe` blocks. Since any use of raw, non-smart pointers in C++ counts as unsafe, I think it'd be pretty okay to write a couple of helper functions to maintain that invariant, and then call those functions from safe code.
But yeah, that probably ought to end up in either the standard library or a very common third-party library, at some point.
- Animats 12y agoTo do that right, you need help from the borrow checker. When manipulating an owner pointer with a backlink, you'd need the backpointer to be unborrowed at the moment the ownership changes. A feature like this needs compile time checking. I really need to think this through and make a proposal for Rust 2.