tmp/tmppxk80745/{from.md → to.md}
RENAMED
|
@@ -15,12 +15,12 @@ namespace std {
|
|
| 15 |
// [util.smartptr.shared.const], constructors:
|
| 16 |
constexpr shared_ptr() noexcept;
|
| 17 |
template<class Y> explicit shared_ptr(Y* p);
|
| 18 |
template<class Y, class D> shared_ptr(Y* p, D d);
|
| 19 |
template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
|
| 20 |
-
template <class D> shared_ptr(nullptr_t p, D d)
|
| 21 |
-
template <class D, class A> shared_ptr(nullptr_t p, D d, A a)
|
| 22 |
template<class Y> shared_ptr(const shared_ptr<Y>& r, T* p) noexcept;
|
| 23 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 24 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 25 |
shared_ptr(shared_ptr&& r) noexcept;
|
| 26 |
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
|
|
@@ -147,11 +147,11 @@ races.
|
|
| 147 |
constexpr shared_ptr() noexcept;
|
| 148 |
```
|
| 149 |
|
| 150 |
*Effects:* Constructs an *empty* `shared_ptr` object.
|
| 151 |
|
| 152 |
-
*Postconditions:* `use_count() == 0 && get() ==
|
| 153 |
|
| 154 |
``` cpp
|
| 155 |
template<class Y> explicit shared_ptr(Y* p);
|
| 156 |
```
|
| 157 |
|
|
@@ -205,19 +205,19 @@ template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
|
|
| 205 |
To avoid the possibility of a dangling pointer, the user of this
|
| 206 |
constructor must ensure that `p` remains valid at least until the
|
| 207 |
ownership group of `r` is destroyed.
|
| 208 |
|
| 209 |
This constructor allows creation of an *empty* `shared_ptr` instance
|
| 210 |
-
with a non-
|
| 211 |
|
| 212 |
``` cpp
|
| 213 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 214 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 215 |
```
|
| 216 |
|
| 217 |
-
|
| 218 |
-
|
| 219 |
|
| 220 |
*Effects:* If `r` is *empty*, constructs an *empty* `shared_ptr` object;
|
| 221 |
otherwise, constructs a `shared_ptr` object that *shares ownership* with
|
| 222 |
`r`.
|
| 223 |
|
|
@@ -232,11 +232,11 @@ The second constructor shall not participate in overload resolution
|
|
| 232 |
unless `Y*` is convertible to `T*`.
|
| 233 |
|
| 234 |
*Effects:* Move-constructs a `shared_ptr` instance from `r`.
|
| 235 |
|
| 236 |
*Postconditions:* `*this` shall contain the old value of `r`. `r` shall
|
| 237 |
-
be *empty*. `r.get() ==
|
| 238 |
|
| 239 |
``` cpp
|
| 240 |
template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
|
| 241 |
```
|
| 242 |
|
|
@@ -260,11 +260,11 @@ complete type. The expression `delete r.release()` shall be well formed,
|
|
| 260 |
shall have well defined behavior, and shall not throw exceptions.
|
| 261 |
|
| 262 |
*Effects:* Constructs a `shared_ptr` object that stores and *owns*
|
| 263 |
`r.release()`.
|
| 264 |
|
| 265 |
-
*Postconditions:* `use_count() == 1` `&&` `r.get() ==
|
| 266 |
|
| 267 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 268 |
resource other than memory could not be obtained.
|
| 269 |
|
| 270 |
If an exception is thrown, the constructor has no effect.
|
|
@@ -417,11 +417,11 @@ bool unique() const noexcept;
|
|
| 417 |
|
| 418 |
*Returns:* `use_count() == 1`.
|
| 419 |
|
| 420 |
`unique()` may be faster than `use_count()`. If you are using `unique()`
|
| 421 |
to implement copy on write, do not rely on a specific value when
|
| 422 |
-
`get() ==
|
| 423 |
|
| 424 |
``` cpp
|
| 425 |
explicit operator bool() const noexcept;
|
| 426 |
```
|
| 427 |
|
|
@@ -467,13 +467,13 @@ the newly constructed object of type `T`.
|
|
| 467 |
*Postconditions:* `get() != 0 && use_count() == 1`
|
| 468 |
|
| 469 |
*Throws:* `bad_alloc`, or an exception thrown from `A::allocate` or from
|
| 470 |
the constructor of `T`.
|
| 471 |
|
| 472 |
-
*Remarks:* Implementations
|
| 473 |
-
|
| 474 |
-
|
| 475 |
|
| 476 |
These functions will typically allocate more memory than `sizeof(T)` to
|
| 477 |
allow for internal bookkeeping structures such as the reference counts.
|
| 478 |
|
| 479 |
##### `shared_ptr` comparison <a id="util.smartptr.shared.cmp">[[util.smartptr.shared.cmp]]</a>
|
|
@@ -487,11 +487,11 @@ template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_
|
|
| 487 |
``` cpp
|
| 488 |
template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
|
| 489 |
```
|
| 490 |
|
| 491 |
*Returns:* `less<V>()(a.get(), b.get())`, where `V` is the composite
|
| 492 |
-
pointer type
|
| 493 |
|
| 494 |
Defining a comparison operator allows `shared_ptr` objects to be used as
|
| 495 |
keys in associative containers.
|
| 496 |
|
| 497 |
``` cpp
|
|
@@ -624,14 +624,14 @@ undefined behavior, attempting to delete the same object twice.
|
|
| 624 |
``` cpp
|
| 625 |
template<class D, class T> D* get_deleter(const shared_ptr<T>& p) noexcept;
|
| 626 |
```
|
| 627 |
|
| 628 |
*Returns:* If `p` *owns* a deleter `d` of type cv-unqualified `D`,
|
| 629 |
-
returns `&d`; otherwise returns `
|
| 630 |
-
as long as there exists a `shared_ptr` instance that owns `d`. It
|
| 631 |
-
unspecified whether the pointer remains valid longer than that. This
|
| 632 |
-
happen if the implementation doesn’t destroy the deleter until all
|
| 633 |
`weak_ptr` instances that share ownership with `p` have been destroyed.
|
| 634 |
|
| 635 |
##### `shared_ptr` I/O <a id="util.smartptr.shared.io">[[util.smartptr.shared.io]]</a>
|
| 636 |
|
| 637 |
``` cpp
|
|
|
|
| 15 |
// [util.smartptr.shared.const], constructors:
|
| 16 |
constexpr shared_ptr() noexcept;
|
| 17 |
template<class Y> explicit shared_ptr(Y* p);
|
| 18 |
template<class Y, class D> shared_ptr(Y* p, D d);
|
| 19 |
template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
|
| 20 |
+
template <class D> shared_ptr(nullptr_t p, D d);
|
| 21 |
+
template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
|
| 22 |
template<class Y> shared_ptr(const shared_ptr<Y>& r, T* p) noexcept;
|
| 23 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 24 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 25 |
shared_ptr(shared_ptr&& r) noexcept;
|
| 26 |
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
|
|
|
|
| 147 |
constexpr shared_ptr() noexcept;
|
| 148 |
```
|
| 149 |
|
| 150 |
*Effects:* Constructs an *empty* `shared_ptr` object.
|
| 151 |
|
| 152 |
+
*Postconditions:* `use_count() == 0 && get() == nullptr`.
|
| 153 |
|
| 154 |
``` cpp
|
| 155 |
template<class Y> explicit shared_ptr(Y* p);
|
| 156 |
```
|
| 157 |
|
|
|
|
| 205 |
To avoid the possibility of a dangling pointer, the user of this
|
| 206 |
constructor must ensure that `p` remains valid at least until the
|
| 207 |
ownership group of `r` is destroyed.
|
| 208 |
|
| 209 |
This constructor allows creation of an *empty* `shared_ptr` instance
|
| 210 |
+
with a non-null stored pointer.
|
| 211 |
|
| 212 |
``` cpp
|
| 213 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 214 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 215 |
```
|
| 216 |
|
| 217 |
+
The second constructor shall not participate in overload resolution
|
| 218 |
+
unless `Y*` is implicitly convertible to `T*`.
|
| 219 |
|
| 220 |
*Effects:* If `r` is *empty*, constructs an *empty* `shared_ptr` object;
|
| 221 |
otherwise, constructs a `shared_ptr` object that *shares ownership* with
|
| 222 |
`r`.
|
| 223 |
|
|
|
|
| 232 |
unless `Y*` is convertible to `T*`.
|
| 233 |
|
| 234 |
*Effects:* Move-constructs a `shared_ptr` instance from `r`.
|
| 235 |
|
| 236 |
*Postconditions:* `*this` shall contain the old value of `r`. `r` shall
|
| 237 |
+
be *empty*. `r.get() == nullptr.`
|
| 238 |
|
| 239 |
``` cpp
|
| 240 |
template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
|
| 241 |
```
|
| 242 |
|
|
|
|
| 260 |
shall have well defined behavior, and shall not throw exceptions.
|
| 261 |
|
| 262 |
*Effects:* Constructs a `shared_ptr` object that stores and *owns*
|
| 263 |
`r.release()`.
|
| 264 |
|
| 265 |
+
*Postconditions:* `use_count() == 1` `&&` `r.get() == nullptr`.
|
| 266 |
|
| 267 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 268 |
resource other than memory could not be obtained.
|
| 269 |
|
| 270 |
If an exception is thrown, the constructor has no effect.
|
|
|
|
| 417 |
|
| 418 |
*Returns:* `use_count() == 1`.
|
| 419 |
|
| 420 |
`unique()` may be faster than `use_count()`. If you are using `unique()`
|
| 421 |
to implement copy on write, do not rely on a specific value when
|
| 422 |
+
`get() == nullptr`.
|
| 423 |
|
| 424 |
``` cpp
|
| 425 |
explicit operator bool() const noexcept;
|
| 426 |
```
|
| 427 |
|
|
|
|
| 467 |
*Postconditions:* `get() != 0 && use_count() == 1`
|
| 468 |
|
| 469 |
*Throws:* `bad_alloc`, or an exception thrown from `A::allocate` or from
|
| 470 |
the constructor of `T`.
|
| 471 |
|
| 472 |
+
*Remarks:* Implementations should perform no more than one memory
|
| 473 |
+
allocation. This provides efficiency equivalent to an intrusive smart
|
| 474 |
+
pointer.
|
| 475 |
|
| 476 |
These functions will typically allocate more memory than `sizeof(T)` to
|
| 477 |
allow for internal bookkeeping structures such as the reference counts.
|
| 478 |
|
| 479 |
##### `shared_ptr` comparison <a id="util.smartptr.shared.cmp">[[util.smartptr.shared.cmp]]</a>
|
|
|
|
| 487 |
``` cpp
|
| 488 |
template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
|
| 489 |
```
|
| 490 |
|
| 491 |
*Returns:* `less<V>()(a.get(), b.get())`, where `V` is the composite
|
| 492 |
+
pointer type (Clause [[expr]]) of `T*` and `U*`.
|
| 493 |
|
| 494 |
Defining a comparison operator allows `shared_ptr` objects to be used as
|
| 495 |
keys in associative containers.
|
| 496 |
|
| 497 |
``` cpp
|
|
|
|
| 624 |
``` cpp
|
| 625 |
template<class D, class T> D* get_deleter(const shared_ptr<T>& p) noexcept;
|
| 626 |
```
|
| 627 |
|
| 628 |
*Returns:* If `p` *owns* a deleter `d` of type cv-unqualified `D`,
|
| 629 |
+
returns `&d`; otherwise returns `nullptr`. The returned pointer remains
|
| 630 |
+
valid as long as there exists a `shared_ptr` instance that owns `d`. It
|
| 631 |
+
is unspecified whether the pointer remains valid longer than that. This
|
| 632 |
+
can happen if the implementation doesn’t destroy the deleter until all
|
| 633 |
`weak_ptr` instances that share ownership with `p` have been destroyed.
|
| 634 |
|
| 635 |
##### `shared_ptr` I/O <a id="util.smartptr.shared.io">[[util.smartptr.shared.io]]</a>
|
| 636 |
|
| 637 |
``` cpp
|