Title
Existence of lock_guard<MutexTypes...>::mutex_type typedef unclear
Status
c++23
Section
[thread.lock.guard]
Submitter
Eric Fiselier

Created on 2016-06-13.00:00:00 last changed 5 months ago

Messages

Date: 2020-11-09.21:40:50

Proposed resolution:

This wording is relative to N4861.

  1. Edit [thread.lock.scoped], class template scoped_lock synopsis, as indicated:

    template <class... MutexTypes>
    class scoped_lock {
    public:
      using mutex_type = Mutex; // If MutexTypes... consists of the single type Mutex
      using mutex_type = see below; // Only if  sizeof...(MutexTypes) == 1
      […]
    };
    

    -1- An object of type scoped_lock controls the ownership of lockable objects within a scope. A scoped_lock object maintains ownership of lockable objects throughout the scoped_lock object's lifetime ([basic.life]). The behavior of a program is undefined if the lockable objects referenced by pm do not exist for the entire lifetime of the scoped_lock object.

    • WhenIf sizeof...(MutexTypes) is 1one, let Mutex denote the sole type constituting the pack MutexTypes., the supplied Mutex type shall meet the Cpp17BasicLockable requirements ([thread.req.lockable.basic]). The member typedef-name mutex_type denotes the same type as Mutex.

    • Otherwise, each of the mutex typesall types in the template parameter pack MutexTypes shall meet the Cpp17Lockable requirements ([thread.req.lockable.req]) and there is no member mutex_type.

Date: 2020-11-09.00:00:00

[ 2020-11-09 Approved In November virtual meeting. Status changed: Tentatively Ready → WP. ]

Date: 2020-05-16.00:00:00

[ 2020-05-16 Reflector discussions ]

Status to Tentatively Ready after five positive votes on the reflector.

Date: 2020-05-15.00:00:00

[ 2020-05-11; Daniel provides improved wording ]

Date: 2018-03-14.00:00:00

[ 2018-3-14 Wednesday evening issues processing; general agreement to adopt once the wording is updated. ]

2018-03-18 Marshall provides updated wording.

Previous resolution: [SUPERSEDED]

This wording is relative to N4594.

  1. Edit [thread.lock.guard]/1, class template lock_guard synopsis, as indicated:

    template <class... MutexTypes>
    class lock_guard {
    public:
      typedef Mutex mutex_type; // Only iIf MutexTypes... consists of theexpands to a single type Mutex
      […]
    };
    
Previous resolution: [SUPERSEDED]

This wording is relative to N4727.

  1. Edit [thread.lock.guard]/1, class template lock_guard synopsis, as indicated:

    template <class... MutexTypes>
    class scoped_lock {
    public:
      using mutex_type = Mutex; // Only iIf sizeof(MutexTypes...) == 1 MutexTypes... consists of the single type Mutex
      […]
    };
    
Date: 2017-07-16.20:43:29

[ 2016-07, Toronto Saturday afternoon issues processing ]

General feeling that sizeof(MutexTypes...) == 1 is a better way to state the requirement.

Reworked the text to refer to scoped_lock instead of lock_guard

Marshall and Eric to reword and discuss on reflector. Status to Open

Date: 2017-07-16.20:43:29

In the synopsis of [thread.lock.scoped] the mutex_type typedef is specified as follows:

template <class... MutexTypes>
class scoped_lock {
public:
  typedef Mutex mutex_type; // If MutexTypes... consists of the single type Mutex
  […]
};

The comment seems ambiguous as it could mean either:

  1. sizeof...(MutexTypes) == 1.
  2. sizeof...(MutexTypes) >= 1 and every type in MutexTypes... is the same type.

I originally took the language to mean (2), but upon further review it seems that (1) is the intended interpretation, as suggested in the LEWG discussion in Lenexa.

I think the language should be clarified to prevent implementation divergence.

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2020-11-09 21:40:50adminsetmessages: + msg11551
2020-11-09 21:40:50adminsetstatus: ready -> wp
2020-05-16 17:05:14adminsetmessages: + msg11298
2020-05-16 17:05:14adminsetstatus: open -> ready
2020-05-11 16:22:21adminsetmessages: + msg11289
2018-03-19 00:12:24adminsetmessages: + msg9761
2017-07-16 20:43:29adminsetmessages: + msg9419
2017-07-16 20:43:29adminsetstatus: new -> open
2016-07-02 13:37:12adminsetmessages: + msg8221
2016-06-13 00:00:00admincreate