I have code that controls a mutex lock/unlock based on scope:
void PerformLogin()
{
ScopeLock < Lock > LoginLock( &m_LoginLock );
doLoginCommand();
ScopeLock < SharedMemoryBase > MemoryLock( &m_SharedMemory );
doStoreLogin();
...
}
Can I guarantee that MemoryLock will be destructed before LoginLock?
Yes, it is. In any particular scope local objects are destroyed in the reverse order that they were constructed.