This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

2577. {shared,unique}_lock should use std::addressof

Section: 33.6.5.4.2 [thread.lock.unique.cons], 33.6.5.5.2 [thread.lock.shared.cons] Status: C++17 Submitter: Tim Song Opened: 2016-01-01 Last modified: 2017-07-30

Priority: 0

View all other issues in [thread.lock.unique.cons].

View all issues with C++17 status.

Discussion:

So that they work with user-defined types that have overloaded unary &.

[2016-02, Issues Telecon]

P0; move to Tentatively Ready.

Proposed resolution:

This wording is relative to N4567.

  1. Edit 33.6.5.4.2 [thread.lock.unique.cons] as indicated:

    explicit unique_lock(mutex_type& m);
    

    […]

    -5- Postconditions: pm == &maddressof(m) and owns == true.

    unique_lock(mutex_type& m, defer_lock_t) noexcept;
    

    […]

    -7- Postconditions: pm == &maddressof(m) and owns == false.

    unique_lock(mutex_type& m, try_to_lock_t);
    

    […]

    -10- Postconditions: pm == &maddressof(m) and owns == res, where res is the value returned by the call to m.try_lock().

    unique_lock(mutex_type& m, adopt_lock_t);
    

    […]

    -13- Postconditions: pm == &maddressof(m) and owns == true.

    -14- Throws: Nothing.

    template <class Clock, class Duration>
      unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
    

    […]

    -17- Postconditions: pm == &maddressof(m) and owns == res, where res is the value returned by the call to m.try_lock_until(abs_time).

    template <class Rep, class Period>
      unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
    

    […]

    -20- Postconditions: pm == &maddressof(m) and owns == res, where res is the value returned by the call to m.try_lock_for(rel_time).

  2. Edit 33.6.5.5.2 [thread.lock.shared.cons] as indicated:

    explicit shared_lock(mutex_type& m);
    

    […]

    -5- Postconditions: pm == &maddressof(m) and owns == true.

    shared_lock(mutex_type& m, defer_lock_t) noexcept;
    

    […]

    -7- Postconditions: pm == &maddressof(m) and owns == false.

    shared_lock(mutex_type& m, try_to_lock_t);
    

    […]

    -10- Postconditions: pm == &maddressof(m) and owns == res where res is the value returned by the call to m.try_lock_shared().

    shared_lock(mutex_type& m, adopt_lock_t);
    

    […]

    -13- Postconditions: pm == &maddressof(m) and owns == true.

    template <class Clock, class Duration>
      shared_lock(mutex_type& m,
                  const chrono::time_point<Clock, Duration>& abs_time);
    

    […]

    -16- Postconditions: pm == &maddressof(m) and owns == res where res is the value returned by the call to m.try_lock_shared_until(abs_time).

    template <class Rep, class Period>
      shared_lock(mutex_type& m,
                  const chrono::duration<Rep, Period>& rel_time);
    

    […]

    -19- Postconditions: pm == &maddressof(m) and owns == res where res is the value returned by the call to m.try_lock_shared_for(rel_time).