Multiple ChoiceIntermediate 45s
make_shared weak_ptr memory retention
A downside of `std::make_shared` is that:
Options
- 1It cannot be used with classes that have a private constructor, since the helper is not a friend.
- 2Memory for the object is only reclaimed once the control block is destroyed, so a lingering weak_ptr keeps the whole block alive.
- 3It always performs two separate allocations, so it is strictly worse than constructing a shared_ptr directly.
- 4It disables custom deleters for the lifetime of the pointer, so the resource is silently leaked instead of freed.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.