Implement LWG2577: {shared,unique}_lock</tt> should use std::addressof

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@263506 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__mutex_base b/include/__mutex_base
index b019b47..6165023 100644
--- a/include/__mutex_base
+++ b/include/__mutex_base
@@ -109,24 +109,24 @@
     unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
     _LIBCPP_INLINE_VISIBILITY
     explicit unique_lock(mutex_type& __m)
-        : __m_(&__m), __owns_(true) {__m_->lock();}
+        : __m_(addressof(__m)), __owns_(true) {__m_->lock();}
     _LIBCPP_INLINE_VISIBILITY
     unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
-        : __m_(&__m), __owns_(false) {}
+        : __m_(addressof(__m)), __owns_(false) {}
     _LIBCPP_INLINE_VISIBILITY
     unique_lock(mutex_type& __m, try_to_lock_t)
-        : __m_(&__m), __owns_(__m.try_lock()) {}
+        : __m_(addressof(__m)), __owns_(__m.try_lock()) {}
     _LIBCPP_INLINE_VISIBILITY
     unique_lock(mutex_type& __m, adopt_lock_t)
-        : __m_(&__m), __owns_(true) {}
+        : __m_(addressof(__m)), __owns_(true) {}
     template <class _Clock, class _Duration>
     _LIBCPP_INLINE_VISIBILITY
         unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
-            : __m_(&__m), __owns_(__m.try_lock_until(__t)) {}
+            : __m_(addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
     template <class _Rep, class _Period>
     _LIBCPP_INLINE_VISIBILITY
         unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
-            : __m_(&__m), __owns_(__m.try_lock_for(__d)) {}
+            : __m_(addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
     _LIBCPP_INLINE_VISIBILITY
     ~unique_lock()
     {
diff --git a/include/shared_mutex b/include/shared_mutex
index dcb9394..45e7fd0 100644
--- a/include/shared_mutex
+++ b/include/shared_mutex
@@ -319,25 +319,25 @@
 
     _LIBCPP_INLINE_VISIBILITY
     explicit shared_lock(mutex_type& __m)
-        : __m_(&__m),
+        : __m_(addressof(__m)),
           __owns_(true)
         {__m_->lock_shared();}
 
     _LIBCPP_INLINE_VISIBILITY
     shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
-        : __m_(&__m),
+        : __m_(addressof(__m)),
           __owns_(false)
         {}
 
     _LIBCPP_INLINE_VISIBILITY
     shared_lock(mutex_type& __m, try_to_lock_t)
-        : __m_(&__m),
+        : __m_(addressof(__m)),
           __owns_(__m.try_lock_shared())
         {}
 
     _LIBCPP_INLINE_VISIBILITY
     shared_lock(mutex_type& __m, adopt_lock_t)
-        : __m_(&__m),
+        : __m_(addressof(__m)),
           __owns_(true)
         {}
 
@@ -345,7 +345,7 @@
         _LIBCPP_INLINE_VISIBILITY
         shared_lock(mutex_type& __m,
                     const chrono::time_point<_Clock, _Duration>& __abs_time)
-            : __m_(&__m),
+            : __m_(addressof(__m)),
               __owns_(__m.try_lock_shared_until(__abs_time))
             {}
 
@@ -353,7 +353,7 @@
         _LIBCPP_INLINE_VISIBILITY
         shared_lock(mutex_type& __m,
                     const chrono::duration<_Rep, _Period>& __rel_time)
-            : __m_(&__m),
+            : __m_(addressof(__m)),
               __owns_(__m.try_lock_shared_for(__rel_time))
             {}