Why is std :: unique_lock not derived from std :: lock_guard
They have no wildcard semantics: they are lock_guard
guaranteed to be blocked after their entire lifetime. unique_lock
does not guarantee that it will not follow "IS A" -rle ( unique_lock
it cannot lock_guard
, since it offers fewer guarantees).
Also a unique_lock
based implementation lock_guard
would not be trivial (maybe even impossible) for this reason.
Obviously, the same is true and vice versa: while you can implement lock_guard
in terms of unique_lock
(private inheritance), it lock_guard
does not provide the same functionality as ( lock()/unlock()
) unique_lock
, so it cannot be publicly derived from it.
source to share