3 ms·
I left C++ almost 10 years ago but I still remember how surprised and frustrated I was when auto_ptr was deprecated and then removed from the C++ standard as we
by oezi 5mo ago
I left C++ almost 10 years ago but I still remember how surprised and frustrated I was when auto_ptr was deprecated and then removed from the C++ standard as we had built our dependency injection framework and progress primitive on it.
- kennu 5mo agoWasn't unique_ptr added as a migration path away from auto_ptr to provide similar functionality more safely? I've never used them but was just reading the history.
- oezi 5mo agoSure, but auto_ptr is different in that copying transfers ownership, while unique_ptr prohibits copying.
- kennu 5mo agoBut if I understand it right, auto_ptr assignment didn't actually copy the pointer, but instead moved it to a new variable and quietly made the original variable null? And unique_ptr made this operation require an explicit move() call, because the assignment-only style caused too many null pointer bugs. I'm just curious about this for historical interest.
- oezi 5mo agoYes, it was a design decision of the auto_ptr to have this move semantics and it worked very nicely for us because we used for instance to pass progress monitors down the stack.