Reputation: 604
I just learned about std::lock_guard
and I was wondering why it is a template.
Until now I have only seen std::lock_guard<std::mutex>
with std::mutex
inside the angle brackets.
Upvotes: 2
Views: 784
Reputation: 28609
Using std::lock_guard<std::mutex>
is indeed quite common.
But you can use std::lock_guard
with other mutex types:
std::recursive_mutex
.BasicLockable
, i.e. it supports the required methods: lock()
, unlock()
.Upvotes: 6