I have a simple class with the following declared privately:
std::mutex headMutex;
std::unique_lock<std::mutex> usingHeadNode(){return std::unique_lock<std::mutex>(headMutex);}
my aim is to provide a simple helper function that returns a unique_lock wrapping the mutex, so that my calling code can be
auto headGuard = usingHeadNode();
to lock the mutex with the RAII technique. However compiling this raises an error:
error: use of deleted function ‘std::lock_guard<_Mutex>::lock_guard(const std::lock_guard<_Mutex>&) [with _Mutex = std::mutex]
... which looks like the constructor for the lock_guard class is missing or something? I haven't deleted anything as far as I'm aware...
Aucun commentaire:
Enregistrer un commentaire