Multiple ChoiceBeginner 45s
weak_ptr lock pattern
The correct idiomatic way to safely use a `std::weak_ptr<T>` is:
Options
- 1Call `lock()` to obtain a temporary `shared_ptr<T>` and check it is non-null before dereferencing.
- 2Call `use_count()` and, if non-zero, dereference the weak_ptr directly.
- 3Call `get()` and compare to nullptr, then use the raw pointer indefinitely.
- 4Dereference it directly; a weak_ptr is null-safe by design.
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.