3 ms·
Personally, I like shared_ptr not just when ownership is unclear, but also for when ownership doesn't matter too much. There's obviously some risk involved if y
by obstinate 11y ago
Personally, I like shared_ptr not just when ownership is unclear, but also for when ownership doesn't matter too much. There's obviously some risk involved if you have complex object graphs set up, but when the graph is simple, I like the ability to pay less attention to lifetime management.
Way I think of it is that using shared_ptr gets me some of the productivity advantages of garbage collected languages, with some of the costs. In areas where performance is not terribly sensitive, this can be a good trade off.
On the other hand, you're absolutely right that this constructor is too clever by half.