In C++, lock_guard allows you to be RAII compliant when using locks. It calls lock() when constructing the lock_guard, and unlock() when destroying it once it goes out of scope.
Is it possible to tighten the scope of lock_guard such that it is destroyed sooner, to avoid keeping the lock for longer than necessary?