I've been having issues using scoped_locked in VS 2017. I believe I traced them back to the <mutex>
declaration, copied below. What would be the safest way to disable the #if
switch at the beginning to gain use to scoped_lock? Thanks again.
#if _HAS_CXX17
// CLASS TEMPLATE scoped_lock
template<class... _Mutexes>
class scoped_lock
{ // class with destructor that unlocks mutexes
public:
explicit scoped_lock(_Mutexes&... _Mtxes)
: _MyMutexes(_Mtxes...)
{ // construct and lock
_STD lock(_Mtxes...);
}
explicit scoped_lock(adopt_lock_t, _Mutexes&... _Mtxes)
: _MyMutexes(_Mtxes...)
{ // construct but don't lock
}
~scoped_lock() _NOEXCEPT
{ // unlock all
_For_each_tuple_element(
_MyMutexes,
[](auto& _Mutex) _NOEXCEPT { _Mutex.unlock(); });
}
scoped_lock(const scoped_lock&) = delete;
scoped_lock& operator=(const scoped_lock&) = delete;
private:
tuple<_Mutexes&...> _MyMutexes;
};