2 ms·
A shared pointer is one where ownership can be shared across any part of the application. That sounds great initially, as it assures the thing you’re pointing a
by MontagFTB 4y ago
A shared pointer is one where ownership can be shared across any part of the application. That sounds great initially, as it assures the thing you’re pointing at will still be alive while you need it. In reality it creates a vague notion of ownership, where no one is responsible for object lifetime, because everyone is. This creates a “functional global” in your application per instance of your shared pointer class. The net effect is a more modern looking architectural morass.
- t6jvcereio 4y agoWhat does ownership mean? Specifically.
- im3w1l 4y agoIf object a owns object b, then it means that a is responsible for managing b's lifetime - that is to delete b and free the memory. Edit: A may also fulfill its obligation by transferring b to a new owner.