explicitly declared guards' copy ctors as it prevents VS from doing spurious copies (!)

This commit is contained in:
joaquintides
2023-04-15 09:51:01 +02:00
parent 1723358298
commit b1a52d0236

View File

@ -106,6 +106,9 @@ public:
shared_lock(Mutex& m_)noexcept:m{m_}{m.lock_shared();}
~shared_lock()noexcept{if(owns)m.unlock_shared();}
/* not used but VS in pre-C++17 mode needs to see it for RVO */
shared_lock(const shared_lock&);
void lock(){BOOST_ASSERT(!owns);m.lock_shared();owns=true;}
void unlock(){BOOST_ASSERT(owns);m.unlock_shared();owns=false;}
@ -125,6 +128,9 @@ public:
lock_guard(Mutex& m_)noexcept:m{m_}{m.lock();}
~lock_guard()noexcept{m.unlock();}
/* not used but VS in pre-C++17 mode needs to see it for RVO */
lock_guard(const lock_guard&);
private:
Mutex &m;
};