From Jason Turner

[util.smartptr.shared.const]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpa321_hbn/{from.md → to.md} +15 -14
tmp/tmpa321_hbn/{from.md → to.md} RENAMED
@@ -1,6 +1,6 @@
1
- #### Constructors <a id="util.smartptr.shared.const">[[util.smartptr.shared.const]]</a>
2
 
3
  In the constructor definitions below, enables `shared_from_this` with
4
  `p`, for a pointer `p` of type `Y*`, means that if `Y` has an
5
  unambiguous and accessible base class that is a specialization of
6
  `enable_shared_from_this` [[util.smartptr.enab]], then `remove_cv_t<Y>*`
@@ -24,18 +24,18 @@ constexpr shared_ptr() noexcept;
24
 
25
  ``` cpp
26
  template<class Y> explicit shared_ptr(Y* p);
27
  ```
28
 
29
- *Mandates:* `Y` is a complete type.
30
-
31
  *Constraints:* When `T` is an array type, the expression `delete[] p` is
32
  well-formed and either `T` is `U[N]` and `Y(*)[N]` is convertible to
33
  `T*`, or `T` is `U[]` and `Y(*)[]` is convertible to `T*`. When `T` is
34
  not an array type, the expression `delete p` is well-formed and `Y*` is
35
  convertible to `T*`.
36
 
 
 
37
  *Preconditions:* The expression `delete[] p`, when `T` is an array type,
38
  or `delete p`, when `T` is not an array type, has well-defined behavior,
39
  and does not throw exceptions.
40
 
41
  *Effects:* When `T` is not an array type, constructs a `shared_ptr`
@@ -46,11 +46,11 @@ with `p`. If an exception is thrown, `delete p` is called when `T` is
46
  not an array type, `delete[] p` otherwise.
47
 
48
  *Ensures:* `use_count() == 1 && get() == p`.
49
 
50
  *Throws:* `bad_alloc`, or an *implementation-defined* exception when a
51
- resource other than memory could not be obtained.
52
 
53
  ``` cpp
54
  template<class Y, class D> shared_ptr(Y* p, D d);
55
  template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
56
  template<class D> shared_ptr(nullptr_t p, D d);
@@ -66,22 +66,23 @@ well-formed expression. For the first two overloads:
66
  - If `T` is not an array type, then `Y*` is convertible to `T*`.
67
 
68
  *Preconditions:* Construction of `d` and a deleter of type `D`
69
  initialized with `std::move(d)` do not throw exceptions. The expression
70
  `d(p)` has well-defined behavior and does not throw exceptions. `A`
71
- meets the *Cpp17Allocator* requirements ([[cpp17.allocator]]).
 
72
 
73
  *Effects:* Constructs a `shared_ptr` object that owns the object `p` and
74
  the deleter `d`. When `T` is not an array type, the first and second
75
  constructors enable `shared_from_this` with `p`. The second and fourth
76
  constructors shall use a copy of `a` to allocate memory for internal
77
  use. If an exception is thrown, `d(p)` is called.
78
 
79
  *Ensures:* `use_count() == 1 && get() == p`.
80
 
81
  *Throws:* `bad_alloc`, or an *implementation-defined* exception when a
82
- resource other than memory could not be obtained.
83
 
84
  ``` cpp
85
  template<class Y> shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept;
86
  template<class Y> shared_ptr(shared_ptr<Y>&& r, element_type* p) noexcept;
87
  ```
@@ -90,13 +91,13 @@ template<class Y> shared_ptr(shared_ptr<Y>&& r, element_type* p) noexcept;
90
  ownership with the initial value of `r`.
91
 
92
  *Ensures:* `get() == p`. For the second overload, `r` is empty and
93
  `r.get() == nullptr`.
94
 
95
- [*Note 1*: To avoid the possibility of a dangling pointer, the user of
96
- this constructor should ensure that `p` remains valid at least until the
97
- ownership group of `r` is destroyed. — *end note*]
98
 
99
  [*Note 2*: This constructor allows creation of an empty `shared_ptr`
100
  instance with a non-null stored pointer. — *end note*]
101
 
102
  ``` cpp
@@ -119,12 +120,12 @@ template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
119
 
120
  *Constraints:* For the second constructor, `Y*` is compatible with `T*`.
121
 
122
  *Effects:* Move constructs a `shared_ptr` instance from `r`.
123
 
124
- *Ensures:* `*this` shall contain the old value of `r`. `r` shall be
125
- empty. `r.get() == nullptr`.
126
 
127
  ``` cpp
128
  template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
129
  ```
130
 
@@ -145,9 +146,9 @@ template<class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
145
  *Constraints:* `Y*` is compatible with `T*` and
146
  `unique_ptr<Y, D>::pointer` is convertible to `element_type*`.
147
 
148
  *Effects:* If `r.get() == nullptr`, equivalent to `shared_ptr()`.
149
  Otherwise, if `D` is not a reference type, equivalent to
150
- `shared_ptr(r.release(), r.get_deleter())`. Otherwise, equivalent to
151
- `shared_ptr(r.release(), ref(r.get_deleter()))`. If an exception is
152
- thrown, the constructor has no effect.
153
 
 
1
+ ##### Constructors <a id="util.smartptr.shared.const">[[util.smartptr.shared.const]]</a>
2
 
3
  In the constructor definitions below, enables `shared_from_this` with
4
  `p`, for a pointer `p` of type `Y*`, means that if `Y` has an
5
  unambiguous and accessible base class that is a specialization of
6
  `enable_shared_from_this` [[util.smartptr.enab]], then `remove_cv_t<Y>*`
 
24
 
25
  ``` cpp
26
  template<class Y> explicit shared_ptr(Y* p);
27
  ```
28
 
 
 
29
  *Constraints:* When `T` is an array type, the expression `delete[] p` is
30
  well-formed and either `T` is `U[N]` and `Y(*)[N]` is convertible to
31
  `T*`, or `T` is `U[]` and `Y(*)[]` is convertible to `T*`. When `T` is
32
  not an array type, the expression `delete p` is well-formed and `Y*` is
33
  convertible to `T*`.
34
 
35
+ *Mandates:* `Y` is a complete type.
36
+
37
  *Preconditions:* The expression `delete[] p`, when `T` is an array type,
38
  or `delete p`, when `T` is not an array type, has well-defined behavior,
39
  and does not throw exceptions.
40
 
41
  *Effects:* When `T` is not an array type, constructs a `shared_ptr`
 
46
  not an array type, `delete[] p` otherwise.
47
 
48
  *Ensures:* `use_count() == 1 && get() == p`.
49
 
50
  *Throws:* `bad_alloc`, or an *implementation-defined* exception when a
51
+ resource other than memory cannot be obtained.
52
 
53
  ``` cpp
54
  template<class Y, class D> shared_ptr(Y* p, D d);
55
  template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
56
  template<class D> shared_ptr(nullptr_t p, D d);
 
66
  - If `T` is not an array type, then `Y*` is convertible to `T*`.
67
 
68
  *Preconditions:* Construction of `d` and a deleter of type `D`
69
  initialized with `std::move(d)` do not throw exceptions. The expression
70
  `d(p)` has well-defined behavior and does not throw exceptions. `A`
71
+ meets the *Cpp17Allocator*
72
+ requirements [[allocator.requirements.general]].
73
 
74
  *Effects:* Constructs a `shared_ptr` object that owns the object `p` and
75
  the deleter `d`. When `T` is not an array type, the first and second
76
  constructors enable `shared_from_this` with `p`. The second and fourth
77
  constructors shall use a copy of `a` to allocate memory for internal
78
  use. If an exception is thrown, `d(p)` is called.
79
 
80
  *Ensures:* `use_count() == 1 && get() == p`.
81
 
82
  *Throws:* `bad_alloc`, or an *implementation-defined* exception when a
83
+ resource other than memory cannot be obtained.
84
 
85
  ``` cpp
86
  template<class Y> shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept;
87
  template<class Y> shared_ptr(shared_ptr<Y>&& r, element_type* p) noexcept;
88
  ```
 
91
  ownership with the initial value of `r`.
92
 
93
  *Ensures:* `get() == p`. For the second overload, `r` is empty and
94
  `r.get() == nullptr`.
95
 
96
+ [*Note 1*: Use of this constructor leads to a dangling pointer unless
97
+ `p` remains valid at least until the ownership group of `r` is
98
+ destroyed. — *end note*]
99
 
100
  [*Note 2*: This constructor allows creation of an empty `shared_ptr`
101
  instance with a non-null stored pointer. — *end note*]
102
 
103
  ``` cpp
 
120
 
121
  *Constraints:* For the second constructor, `Y*` is compatible with `T*`.
122
 
123
  *Effects:* Move constructs a `shared_ptr` instance from `r`.
124
 
125
+ *Ensures:* `*this` contains the old value of `r`. `r` is empty, and
126
+ `r.get() == nullptr`.
127
 
128
  ``` cpp
129
  template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
130
  ```
131
 
 
146
  *Constraints:* `Y*` is compatible with `T*` and
147
  `unique_ptr<Y, D>::pointer` is convertible to `element_type*`.
148
 
149
  *Effects:* If `r.get() == nullptr`, equivalent to `shared_ptr()`.
150
  Otherwise, if `D` is not a reference type, equivalent to
151
+ `shared_ptr(r.release(), std::move(r.get_deleter()))`. Otherwise,
152
+ equivalent to `shared_ptr(r.release(), ref(r.get_deleter()))`. If an
153
+ exception is thrown, the constructor has no effect.
154