3 ms·
> I'm not sure your first point is actually right - it tends to be pretty hard to use after move. std::unique_ptr<int> foo(new int(10)); void bar(
by pcwalton 8y ago
> I'm not sure your first point is actually right - it tends to be pretty hard to use after move.
std::unique_ptr<int> foo(new int(10));
void bar(int& x);
int main() {
bar(*foo);
return 0;
}
void bar(int& x) {
foo = std::unique_ptr<int>(new int(20));
std::cout << x; // use after free
}
No warnings on any warning level.