Can you guarantee destructor order when objects are declared on a stack?

后端 未结 5 644
-上瘾入骨i
-上瘾入骨i 2021-02-12 14:34

I have code that controls a mutex lock/unlock based on scope:

void PerformLogin()
{
    ScopeLock < Lock > LoginLock( &m_LoginLock );

    doLoginComma         


        
5条回答
  •  有刺的猬
    2021-02-12 14:46

    Yes, it is. In any particular scope local objects are destroyed in the reverse order that they were constructed.

提交回复
热议问题