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

### 2819. Unspecified Return type: elements

Section: 32.2.5 [thread.req.lockable], 32.5.4 [thread.mutex.requirements] Status: New Submitter: Agustín K-ballo Bergé Opened: 2016-11-12 Last modified: 2020-05-12

Priority: 3

View all issues with New status.

Discussion:

The current draft contains 14 occurrences of a Return type: clause. That clause is not covered by 16.3.2.4 [structure.specifications] p3. This was reported as editorial request #266.

[Issues Telecon 16-Dec-2016]

Priority 3; Jonathan to provide wording.

[12-May-2020, Jonathan provides wording to correct the 13 occurences.]

Proposed resolution:

This wording is relative to N4681.

1. Modify 32.2.5.3 [thread.req.lockable.req] as indicated:

   > -1- A type `L` meets the Cpp17Lockable requirements if it meets the Cpp17BasicLockable requirements and the following expressions are well-formed, have type `bool`, and have the specified semantics (`m` denotes a value of type `L`).

   > `m.try_lock()`

   > > -2- Effects: [...]

   > > -3- Return type: `bool`.

   > > -4- Returns: `true` if the lock was acquired, `false` otherwise.

2. Modify 32.2.5.4 [thread.req.lockable.timed] as indicated:

   > -1- A type `L` meets the Cpp17TimedLockable requirements if it meets the Cpp17BasicLockable requirements and the following expressions are well-formed, have type `bool`, and have the specified semantics (`m` denotes a value of type `L`, `rel_time` denotes a value of an instantiation of `duration` (27.5 [time.duration]), and `abs_time` denotes a value of an instantiation of `time_point` (27.6 [time.point])).

   > `m.try_lock_for(rel_time)`

   > > -2- Effects: [...]

   > > -3- Return type: `bool`.

   > > -4- Returns: `true` if the lock was acquired, `false` otherwise.

   > `m.try_lock_until(abs_time)`

   > > -2- Effects: [...]

   > > -3- Return type: `bool`.

   > > -4- Returns: `true` if the lock was acquired, `false` otherwise.

3. Modify 32.5.4.2 [thread.mutex.requirements.mutex] as indicated:

   > -6- The expression `m.lock()` is well-formed, has type `void`, and has the following semantics:

   > > -7- Preconditions: [...]

   > > -8- Effects: [...]

   > > -9- Postconditions: [...]

   > > -10- Return type: `void`.

   > > -11- Synchronization: [...]

   > > -12- Throws: [...]

   > > -13- Error conditions: [...]

   > -14- The expression `m.try_lock()` is well-formed, has type `bool`, and has the following semantics:

   > > -15- Preconditions: [...]

   > > -16- Effects: [...]

   > > -17- Return type: `bool`.

   > > -18- Returns: `true` if ownership of the mutex was obtained for the calling thread, otherwise `false`.

   > > -19- Synchronization: [...]

   > > -20- Throws: Nothing.

   > -21- The expression `m.unlock()` is well-formed, has type `void`, and has the following semantics:

   > > -22- Preconditions: [...]

   > > -23- Effects: [...]

   > > -24- Return type: `void`.

   > > -25- Synchronization: [...]

   > > -26- Throws: Nothing.

4. Modify 32.5.4.3 [thread.timedmutex.requirements] as indicated:

   > -1- The timed mutex types are the standard library types [...]

   > -2- The timed mutex types meet the Cpp17TimedLockable requirements (32.2.5.4 [thread.req.lockable.timed]).

   > -3- The expression `m.try_lock_for(rel_time)` is well-formed, has type `bool`, and has the following semantics:

   > > -4- Preconditions: [...]

   > > -5- Effects: [...]

   > > -6- Return type: `bool`.

   > > -7- Returns: `true` if the shared lock was acquired, `false` otherwise.

   > > -8- Synchronization: [...]

   > > -9- Throws: [...]

   > -10- The expression `m.try_lock_until(abs_time)` is well-formed, has type `bool`, and has the following semantics:

   > > -11- Preconditions: [...]

   > > -12- Effects: [...]

   > > -13- Return type: `bool`.

   > > -14- Returns: `true` if ownership was obtained, otherwise `false`.

   > > -15- Synchronization: [...]

   > > -16- Throws: [...]

5. Modify 32.5.4.4 [thread.sharedmutex.requirements] as indicated:

   > -1- The standard library types `shared_mutex` and `shared_timed_mutex` are shared mutex types. [...]

   > -2- In addition to the exclusive lock ownership mode [...]

   > -3- The expression `m.lock_shared()` is well-formed, has type `void`, and has the following semantics:

   > > -4- Preconditions: [...]

   > > -5- Effects: [...]

   > > -6- Postconditions: [...]

   > > -7- Return type: `void`.

   > > -8- Synchronization: [...]

   > > -9- Throws: [...]

   > > -10- Error conditions: [...]

   > -11- The expression `m.unlock_shared()` is well-formed, has type `void`, and has the following semantics:

   > > -12- Preconditions: [...]

   > > -13- Effects: [...]

   > > -14- Return type: `void`.

   > > -15- Synchronization: [...]

   > > -16- Throws: [...]

   > -17- The expression `m.try_lock_shared()` is well-formed, has type `bool`, and has the following semantics:

   > > -18- Preconditions: [...]

   > > -19- Effects: [...]

   > > -20- Return type: `bool`.

   > > -21- Returns: `true` if the shared ownership lock was acquired, `false` otherwise.

   > > -22- Synchronization: [...]

   > > -23- Throws: [...]

6. Modify 32.5.4.5 [thread.sharedtimedmutex.requirements] as indicated:

   > -1- The standard library type `shared_timed_mutex` is a shared timed mutex type. [...]

   > -2- The expression `m.try_lock_shared_for(rel_time)` is well-formed, has type `bool`, and has the following semantics:

   > > -3- Preconditions: [...]

   > > -4- Effects: [...]

   > > -5- Return type: `bool`.

   > > -6- Returns: `true` if the shared lock was acquired, `false` otherwise.

   > > -7- Synchronization: [...]

   > > -8- Throws: [...]

   > -9- The expression `m.try_lock_shared_until(abs_time)` is well-formed, has type `bool`, and has the following semantics:

   > > -10- Preconditions: [...]

   > > -11- Effects: [...]

   > > -12- Return type: `bool`.

   > > -13- Returns: `true` if the shared lock was acquired, `false` otherwise.

   > > -14- Synchronization: [...]

   > > -15- Throws: [...]