2 ms·
Right; you can't have an array of references, and it's "unique_ptr", not "unique_ref". But pointers do get set to null. If p1 is a unique_ptr, and you do
by Animats 11y ago
Right; you can't have an array of references, and it's "unique_ptr", not "unique_ref". But pointers do get set to null.
If p1 is a unique_ptr, and you do
p2 = std::move(p1);
p1's pointer is set to null. Further uses of p1 will fail, or crash, or something.
p1.get()
returns the underlying pointer or null, apparently escaping the unique_ptr protection.
It's far inferior to Rust's borrow checker.