From Jason Turner

[thread.lock.guard]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphn0fkbqs/{from.md → to.md} +12 -10
tmp/tmphn0fkbqs/{from.md → to.md} RENAMED
@@ -3,22 +3,24 @@
3
  ``` cpp
4
  namespace std {
5
  template <class Mutex>
6
  class lock_guard {
7
  public:
8
- typedef Mutex mutex_type;
9
 
10
  explicit lock_guard(mutex_type& m);
11
  lock_guard(mutex_type& m, adopt_lock_t);
12
  ~lock_guard();
13
 
14
- lock_guard(lock_guard const&) = delete;
15
- lock_guard& operator=(lock_guard const&) = delete;
16
 
17
  private:
18
  mutex_type& pm; // exposition only
19
  };
 
 
20
  }
21
  ```
22
 
23
  An object of type `lock_guard` controls the ownership of a lockable
24
  object within a scope. A `lock_guard` object maintains ownership of a
@@ -30,28 +32,28 @@ object referenced by `pm` does not exist for the entire lifetime of the
30
 
31
  ``` cpp
32
  explicit lock_guard(mutex_type& m);
33
  ```
34
 
35
- If `mutex_type` is not a recursive mutex, the calling thread does not
36
- own the mutex `m`.
37
 
38
- *Effects:* `m.lock()`
39
 
40
- `&pm == &m`
41
 
42
  ``` cpp
43
  lock_guard(mutex_type& m, adopt_lock_t);
44
  ```
45
 
46
- The calling thread owns the mutex `m`.
47
 
48
- `&pm == &m`
49
 
50
  *Throws:* Nothing.
51
 
52
  ``` cpp
53
  ~lock_guard();
54
  ```
55
 
56
- *Effects:* `pm.unlock()`
57
 
 
3
  ``` cpp
4
  namespace std {
5
  template <class Mutex>
6
  class lock_guard {
7
  public:
8
+ using mutex_type = Mutex;
9
 
10
  explicit lock_guard(mutex_type& m);
11
  lock_guard(mutex_type& m, adopt_lock_t);
12
  ~lock_guard();
13
 
14
+ lock_guard(const lock_guard&) = delete;
15
+ lock_guard& operator=(const lock_guard&) = delete;
16
 
17
  private:
18
  mutex_type& pm; // exposition only
19
  };
20
+
21
+ template<class Mutex> lock_guard(lock_guard<Mutex>) -> lock_guard<Mutex>;
22
  }
23
  ```
24
 
25
  An object of type `lock_guard` controls the ownership of a lockable
26
  object within a scope. A `lock_guard` object maintains ownership of a
 
32
 
33
  ``` cpp
34
  explicit lock_guard(mutex_type& m);
35
  ```
36
 
37
+ *Requires:* If `mutex_type` is not a recursive mutex, the calling thread
38
+ does not own the mutex `m`.
39
 
40
+ *Effects:* As if by `m.lock()`.
41
 
42
+ *Postconditions:* `&pm == &m`
43
 
44
  ``` cpp
45
  lock_guard(mutex_type& m, adopt_lock_t);
46
  ```
47
 
48
+ *Requires:* The calling thread owns the mutex `m`.
49
 
50
+ *Postconditions:* `&pm == &m`
51
 
52
  *Throws:* Nothing.
53
 
54
  ``` cpp
55
  ~lock_guard();
56
  ```
57
 
58
+ *Effects:* As if by `pm.unlock()`.
59