Skip to content

Commit

Permalink
Update detail/mutex.hpp to use std::shared_mutex under the MS STL
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jan 19, 2023
1 parent 4bca94f commit 8449c62
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions include/boost/system/detail/mutex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ struct mutex
} // namespace system
} // namespace boost

#elif defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION >= 140

// Under the MS STL, std::mutex::mutex() is not constexpr, as is
// required by the standard, which leads to initialization order
// issues. However, shared_mutex is based on SRWLock and its
// default constructor is constexpr, so we use that instead.

#include <shared_mutex>

namespace boost
{
namespace system
{
namespace detail
{

typedef std::shared_mutex mutex;

} // namespace detail
} // namespace system
} // namespace boost

#else

#include <mutex>
Expand Down

0 comments on commit 8449c62

Please sign in to comment.