I see that the constructor overload that takes a mutex is marked explicit
. I don't see the reason to specify it so. I think there is no harm to allow implicit conversion from mutex to a corresponding std::unique_lock
. This can actually be convenient. For example, given void func_a(std::unique_lock<std::mutex> lock)
and std::mutex mut
, we could directly invoke func_a
on mut
like func_a(mut)
. What may be the potential harm with respect to the call func_a(mut)
? I don't think there is any effect that may surprise the user. So, the question is: what is the rationale behind marking the constructor explicit
?
mercredi 25 novembre 2015
Explicit std::unique_lock constructor from mutex
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire