Which RAII wrapper should be used to lock a std::mutex?
- A Calling lock() and unlock() manually
- B std::lock_guard or std::unique_lock
- C std::atomic
- D std::thread
Answer
std::lock_guard or std::unique_lock
RAII locking releases the mutex even if an exception propagates. Manual unlocking is skipped when an exception is thrown.





