Unlocker<C> is a friend class that locks a mutex inside of LockBox<C> and acts as a lock_guard for that mutex. it also uses the -> and * operators to let you access members of the underlying C class
there is a wrinkle because there is no copy constructor since std::mutex has no copy constructor, but you could potentially get around this by wrapping the mutex in a std::shared_ptr
@SuricrasiaOnline it's kinda like a capability almost
@SuricrasiaOnline so it's kinda like rust's idea of mutexes?
I like this, and agree, why the heck isn't it in std
@k thankfully it's not too difficult to implement yourself, you just need to piece together std::mutex and std::lock_guard together in a particular way
@k @SuricrasiaOnline (i was thinking the same)
@k @SuricrasiaOnline it's almost like, until rust came around no systems programming language thought about making threading… safe?!
https://github.com/blackle/Basilisk-Hunter/blob/master/src/util/LockBox.h