From Jason Turner

[util.smartptr.ownerless]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpu9c2j_j7/{from.md → to.md} +27 -14
tmp/tmpu9c2j_j7/{from.md → to.md} RENAMED
@@ -3,36 +3,49 @@
3
  The class template `owner_less` allows ownership-based mixed comparisons
4
  of shared and weak pointers.
5
 
6
  ``` cpp
7
  namespace std {
8
- template<class T> struct owner_less;
9
 
10
  template<class T> struct owner_less<shared_ptr<T>> {
11
- typedef bool result_type;
12
- typedef shared_ptr<T> first_argument_type;
13
- typedef shared_ptr<T> second_argument_type;
14
- bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const;
15
- bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
16
- bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
17
  };
18
 
19
  template<class T> struct owner_less<weak_ptr<T>> {
20
- typedef bool result_type;
21
- typedef weak_ptr<T> first_argument_type;
22
- typedef weak_ptr<T> second_argument_type;
23
- bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const;
24
- bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
25
- bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
 
 
 
 
 
 
 
 
 
 
26
  };
27
  }
28
  ```
29
 
30
- `operator()(x,y)` shall return `x.owner_before(y)`. Note that
 
 
 
 
31
 
32
  - `operator()` defines a strict weak ordering as defined in 
33
  [[alg.sorting]];
34
  - under the equivalence relation defined by `operator()`,
35
  `!operator()(a, b) && !operator()(b, a)`, two `shared_ptr` or
36
  `weak_ptr` instances are equivalent if and only if they share
37
  ownership or are both empty.
38
 
 
 
 
3
  The class template `owner_less` allows ownership-based mixed comparisons
4
  of shared and weak pointers.
5
 
6
  ``` cpp
7
  namespace std {
8
+ template<class T = void> struct owner_less;
9
 
10
  template<class T> struct owner_less<shared_ptr<T>> {
11
+ bool operator()(const shared_ptr<T>&, const shared_ptr<T>&) const noexcept;
12
+ bool operator()(const shared_ptr<T>&, const weak_ptr<T>&) const noexcept;
13
+ bool operator()(const weak_ptr<T>&, const shared_ptr<T>&) const noexcept;
 
 
 
14
  };
15
 
16
  template<class T> struct owner_less<weak_ptr<T>> {
17
+ bool operator()(const weak_ptr<T>&, const weak_ptr<T>&) const noexcept;
18
+ bool operator()(const shared_ptr<T>&, const weak_ptr<T>&) const noexcept;
19
+ bool operator()(const weak_ptr<T>&, const shared_ptr<T>&) const noexcept;
20
+ };
21
+
22
+ template<> struct owner_less<void> {
23
+ template<class T, class U>
24
+ bool operator()(const shared_ptr<T>&, const shared_ptr<U>&) const noexcept;
25
+ template<class T, class U>
26
+ bool operator()(const shared_ptr<T>&, const weak_ptr<U>&) const noexcept;
27
+ template<class T, class U>
28
+ bool operator()(const weak_ptr<T>&, const shared_ptr<U>&) const noexcept;
29
+ template<class T, class U>
30
+ bool operator()(const weak_ptr<T>&, const weak_ptr<U>&) const noexcept;
31
+
32
+ using is_transparent = unspecified;
33
  };
34
  }
35
  ```
36
 
37
+ `operator()(x, y)` shall return `x.owner_before(y)`.
38
+
39
+ [*Note 1*:
40
+
41
+ Note that
42
 
43
  - `operator()` defines a strict weak ordering as defined in 
44
  [[alg.sorting]];
45
  - under the equivalence relation defined by `operator()`,
46
  `!operator()(a, b) && !operator()(b, a)`, two `shared_ptr` or
47
  `weak_ptr` instances are equivalent if and only if they share
48
  ownership or are both empty.
49
 
50
+ — *end note*]
51
+