forked from boostorg/smart_ptr
More asciidoctor changes
Reinstate the none/blank trick, but remove the blank line after it in local_shared_ptr.adoc that causes the problem. Also use that trick in place of the nested DLs which don't work with Asciidoctor 2
This commit is contained in:
@ -136,14 +136,18 @@ Provides the type of the template parameter T.
|
||||
intrusive_ptr() noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Postconditions:: `get() == 0`.
|
||||
|
||||
```
|
||||
intrusive_ptr(T * p, bool add_ref = true);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `if(p != 0 && add_ref) intrusive_ptr_add_ref(p);`.
|
||||
Postconditions:: `get() == p`.
|
||||
|
||||
@ -154,7 +158,9 @@ intrusive_ptr(intrusive_ptr const & r);
|
||||
template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `T * p = r.get(); if(p != 0) intrusive_ptr_add_ref(p);`.
|
||||
Postconditions:: `get() == r.get()`.
|
||||
|
||||
@ -165,7 +171,9 @@ intrusive_ptr(intrusive_ptr && r);
|
||||
template<class Y> intrusive_ptr(intrusive_ptr<Y> && r);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Postconditions:: `get()` equals the old value of `r.get()`. `r.get() == 0`.
|
||||
|
||||
### destructor
|
||||
@ -174,7 +182,9 @@ Postconditions:: `get()` equals the old value of `r.get()`. `r.get() == 0`.
|
||||
~intrusive_ptr();
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `if(get() != 0) intrusive_ptr_release(get());`.
|
||||
|
||||
### assignment
|
||||
@ -189,7 +199,9 @@ template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> const & r);
|
||||
intrusive_ptr & operator=(T * r);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `intrusive_ptr(r).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@ -200,7 +212,9 @@ intrusive_ptr & operator=(intrusive_ptr && r);
|
||||
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> && r);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `intrusive_ptr(std::move(r)).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@ -210,21 +224,27 @@ Returns:: `*this`.
|
||||
void reset();
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `intrusive_ptr().swap(*this)`.
|
||||
|
||||
```
|
||||
void reset(T * r);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `intrusive_ptr(r).swap(*this)`.
|
||||
|
||||
```
|
||||
void reset(T * r, bool add_ref);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `intrusive_ptr(r, add_ref).swap(*this)`.
|
||||
|
||||
### indirection
|
||||
@ -233,7 +253,9 @@ Effects:: Equivalent to `intrusive_ptr(r, add_ref).swap(*this)`.
|
||||
T & operator*() const noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requirements:: `get() != 0`.
|
||||
Returns:: `*get()`.
|
||||
|
||||
@ -241,7 +263,9 @@ Returns:: `*get()`.
|
||||
T * operator->() const noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requirements:: `get() != 0`.
|
||||
Returns:: `get()`.
|
||||
|
||||
@ -251,7 +275,9 @@ Returns:: `get()`.
|
||||
T * get() const noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: the stored pointer.
|
||||
|
||||
### detach
|
||||
@ -260,7 +286,9 @@ Returns:: the stored pointer.
|
||||
T * detach() noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: the stored pointer.
|
||||
Postconditions:: `get() == 0`.
|
||||
|
||||
@ -278,7 +306,9 @@ the implications are thoroughly understood.
|
||||
explicit operator bool () const noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `get() != 0`.
|
||||
|
||||
NOTE: This conversion operator allows `intrusive_ptr` objects to be used in boolean contexts,
|
||||
@ -292,7 +322,9 @@ NOTE: On C++03 compilers, the return value is of an unspecified type.
|
||||
void swap(intrusive_ptr & b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
## Free Functions
|
||||
@ -304,7 +336,9 @@ template<class T, class U>
|
||||
bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() == b.get()`.
|
||||
|
||||
```
|
||||
@ -312,7 +346,9 @@ template<class T, class U>
|
||||
bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() != b.get()`.
|
||||
|
||||
```
|
||||
@ -320,7 +356,9 @@ template<class T, class U>
|
||||
bool operator==(intrusive_ptr<T> const & a, U * b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() == b`.
|
||||
|
||||
```
|
||||
@ -328,7 +366,9 @@ template<class T, class U>
|
||||
bool operator!=(intrusive_ptr<T> const & a, U * b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() != b`.
|
||||
|
||||
```
|
||||
@ -336,7 +376,9 @@ template<class T, class U>
|
||||
bool operator==(T * a, intrusive_ptr<U> const & b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a == b.get()`.
|
||||
|
||||
```
|
||||
@ -344,7 +386,9 @@ template<class T, class U>
|
||||
bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a != b.get()`.
|
||||
|
||||
```
|
||||
@ -352,7 +396,9 @@ template<class T>
|
||||
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `std::less<T *>()(a.get(), b.get())`.
|
||||
|
||||
NOTE: Allows `intrusive_ptr` objects to be used as keys in associative containers.
|
||||
@ -363,7 +409,9 @@ NOTE: Allows `intrusive_ptr` objects to be used as keys in associative container
|
||||
template<class T> void swap(intrusive_ptr<T> & a, intrusive_ptr<T> & b) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
### get_pointer
|
||||
@ -372,7 +420,9 @@ Effects:: Equivalent to `a.swap(b)`.
|
||||
template<class T> T * get_pointer(intrusive_ptr<T> const & p) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `p.get()`.
|
||||
|
||||
NOTE: Provided as an aid to generic programming. Used by `mem_fn`.
|
||||
@ -384,7 +434,9 @@ template<class T, class U>
|
||||
intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & r) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `intrusive_ptr<T>(static_cast<T*>(r.get()))`.
|
||||
|
||||
### const_pointer_cast
|
||||
@ -394,7 +446,9 @@ template<class T, class U>
|
||||
intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & r) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `intrusive_ptr<T>(const_cast<T*>(r.get()))`.
|
||||
|
||||
### dynamic_pointer_cast
|
||||
@ -404,7 +458,9 @@ template<class T, class U>
|
||||
intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & r) noexcept;
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `intrusive_ptr<T>(dynamic_cast<T*>(r.get()))`.
|
||||
|
||||
### operator<<
|
||||
@ -415,6 +471,8 @@ template<class E, class T, class Y>
|
||||
intrusive_ptr<Y> const & p);
|
||||
```
|
||||
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `os << p.get();`.
|
||||
Returns:: `os`.
|
||||
|
@ -81,7 +81,9 @@ intrusive_ref_counter() noexcept;
|
||||
```
|
||||
intrusive_ref_counter(const intrusive_ref_counter&) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Postconditions:: `use_count() == 0`.
|
||||
|
||||
NOTE: The pointer to the constructed object is expected to be passed to
|
||||
@ -93,7 +95,9 @@ would increment the reference counter.
|
||||
```
|
||||
~intrusive_ref_counter();
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Destroys the counter object.
|
||||
|
||||
NOTE: The destructor is protected so that the object can only be destroyed
|
||||
@ -104,7 +108,9 @@ through the `Derived` class.
|
||||
```
|
||||
intrusive_ref_counter& operator=(const intrusive_ref_counter& v) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Does nothing, reference counter is not modified.
|
||||
|
||||
### use_count
|
||||
@ -112,7 +118,9 @@ Effects:: Does nothing, reference counter is not modified.
|
||||
```
|
||||
unsigned int use_count() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The current value of the reference counter.
|
||||
|
||||
NOTE: The returned value may not be actual in multi-threaded applications.
|
||||
@ -126,7 +134,9 @@ template<class Derived, class CounterPolicy>
|
||||
void intrusive_ptr_add_ref(
|
||||
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Increments the reference counter.
|
||||
|
||||
### intrusive_ptr_release
|
||||
@ -136,6 +146,8 @@ template<class Derived, class CounterPolicy>
|
||||
void intrusive_ptr_release(
|
||||
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Decrements the reference counter. If the reference counter reaches
|
||||
0, calls `delete static_cast<const Derived*>(p)`.
|
||||
|
@ -227,7 +227,9 @@ constexpr local_shared_ptr() noexcept;
|
||||
```
|
||||
constexpr local_shared_ptr(std::nullptr_t) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs an empty `local_shared_ptr`.
|
||||
Postconditions:: `local_use_count() == 0 && get() == 0`.
|
||||
|
||||
@ -235,7 +237,9 @@ Postconditions:: `local_use_count() == 0 && get() == 0`.
|
||||
```
|
||||
template<class Y> explicit local_shared_ptr(Y * p);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p )`.
|
||||
|
||||
Postconditions:: `local_use_count() == 1 && get() == p`.
|
||||
@ -249,7 +253,9 @@ template<class Y, class D> local_shared_ptr(Y * p, D d);
|
||||
```
|
||||
template<class D> local_shared_ptr(std::nullptr_t p, D d);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p, d )`.
|
||||
|
||||
Postconditions:: `local_use_count() == 1 && get() == p`.
|
||||
@ -262,7 +268,9 @@ template<class Y, class D, class A> local_shared_ptr(Y * p, D d, A a);
|
||||
```
|
||||
template<class D, class A> local_shared_ptr(std::nullptr_t p, D d, A a);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p, d, a )`.
|
||||
|
||||
Postconditions:: `local_use_count() == 1 && get() == p`.
|
||||
@ -276,7 +284,9 @@ local_shared_ptr(local_shared_ptr const & r) noexcept;
|
||||
```
|
||||
template<class Y> local_shared_ptr(local_shared_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects:: If `r` is empty, constructs an empty `local_shared_ptr`; otherwise, constructs a `local_shared_ptr` that shares ownership with `r`.
|
||||
@ -290,7 +300,9 @@ local_shared_ptr(local_shared_ptr && r) noexcept;
|
||||
```
|
||||
template<class Y> local_shared_ptr(local_shared_ptr<Y> && r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects:: Move-constructs a `local_shared_ptr` from `r`.
|
||||
@ -304,7 +316,9 @@ template<class Y> local_shared_ptr( shared_ptr<Y> const & r );
|
||||
```
|
||||
template<class Y> local_shared_ptr( shared_ptr<Y> && r );
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `r`.
|
||||
|
||||
Postconditions:: `local_use_count() == 1`. `get()` returns the old value of `r.get()`.
|
||||
@ -315,7 +329,9 @@ Throws:: `std::bad_alloc`, or an implementation-defined exception when a resourc
|
||||
```
|
||||
template<class Y> local_shared_ptr(local_shared_ptr<Y> const & r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: constructs a `local_shared_ptr` that shares ownership with `r` and stores `p`.
|
||||
|
||||
Postconditions:: `get() == p && local_use_count() == r.local_use_count()`.
|
||||
@ -324,7 +340,9 @@ Postconditions:: `get() == p && local_use_count() == r.local_use_count()`.
|
||||
```
|
||||
template<class Y> local_shared_ptr(local_shared_ptr<Y> && r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Move-constructs a `local_shared_ptr` from `r`, while storing `p` instead.
|
||||
|
||||
Postconditions:: `get() == p` and `local_use_count()` equals the old count of `r`. `r` is empty and `r.get() == 0`.
|
||||
@ -333,7 +351,9 @@ Postconditions:: `get() == p` and `local_use_count()` equals the old count of `r
|
||||
```
|
||||
template<class Y, class D> local_shared_ptr(std::unique_ptr<Y, D> && r);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects::
|
||||
@ -348,7 +368,9 @@ Exception safety:: If an exception is thrown, the constructor has no effect.
|
||||
```
|
||||
~local_shared_ptr() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects::
|
||||
- If `*this` is empty, or shares ownership with another `local_shared_ptr` instance (`local_use_count() > 1`), there are no side effects.
|
||||
- Otherwise, destroys the owned `shared_ptr`.
|
||||
@ -360,7 +382,9 @@ local_shared_ptr & operator=(local_shared_ptr const & r) noexcept;
|
||||
```
|
||||
template<class Y> local_shared_ptr & operator=(local_shared_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr(r).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@ -373,14 +397,18 @@ template<class Y> local_shared_ptr & operator=(local_shared_ptr<Y> && r) noexcep
|
||||
```
|
||||
template<class Y, class D> local_shared_ptr & operator=(std::unique_ptr<Y, D> && r);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr(std::move(r)).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
```
|
||||
local_shared_ptr & operator=(std::nullptr_t) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr().swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@ -388,58 +416,76 @@ Returns:: `*this`.
|
||||
```
|
||||
void reset() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr().swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(Y * p);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr(p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y, class D> void reset(Y * p, D d);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr(p, d).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y, class D, class A> void reset(Y * p, D d, A a);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr(p, d, a).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(local_shared_ptr<Y> const & r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr(r, p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(local_shared_ptr<Y> && r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `local_shared_ptr(std::move(r), p).swap(*this)`.
|
||||
|
||||
### indirection
|
||||
```
|
||||
T & operator*() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `T` should not be an array type.
|
||||
Returns:: `*get()`.
|
||||
|
||||
```
|
||||
T * operator->() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `T` should not be an array type.
|
||||
Returns:: `get()`.
|
||||
|
||||
```
|
||||
element_type & operator[](std::ptrdiff_t i) const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `T` should be an array type. The stored pointer must not be 0. `i >= 0`. If `T` is `U[N]`, `i < N`.
|
||||
Returns:: `get()[i]`.
|
||||
|
||||
@ -448,21 +494,27 @@ Returns:: `get()[i]`.
|
||||
```
|
||||
element_type * get() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The stored pointer.
|
||||
|
||||
### local_use_count
|
||||
```
|
||||
long local_use_count() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The number of `local_shared_ptr` objects, `*this` included, that share ownership with `*this`, or 0 when `*this` is empty.
|
||||
|
||||
### conversions
|
||||
```
|
||||
explicit operator bool() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `get() != 0`.
|
||||
|
||||
NOTE: On C++03 compilers, the return value is of an unspecified type.
|
||||
@ -473,7 +525,9 @@ template<class Y> operator shared_ptr<Y>() const noexcept;
|
||||
```
|
||||
template<class Y> operator weak_ptr<Y>() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `T*` should be convertible to `Y*`.
|
||||
Returns:: a copy of the owned `shared_ptr`.
|
||||
|
||||
@ -481,14 +535,18 @@ Returns:: a copy of the owned `shared_ptr`.
|
||||
```
|
||||
void swap(local_shared_ptr & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
### owner_before
|
||||
```
|
||||
template<class Y> bool owner_before(local_shared_ptr<Y> const & rhs) const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: See the description of `operator<`.
|
||||
|
||||
## Free Functions
|
||||
@ -506,7 +564,9 @@ template<class T, class U>
|
||||
template<class T, class U>
|
||||
bool operator==(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() == b.get()`.
|
||||
|
||||
```
|
||||
@ -521,7 +581,9 @@ template<class T, class U>
|
||||
template<class T, class U>
|
||||
bool operator!=(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() != b.get()`.
|
||||
|
||||
```
|
||||
@ -530,7 +592,9 @@ template<class T> bool operator==(local_shared_ptr<T> const & p, std::nullptr_t)
|
||||
```
|
||||
template<class T> bool operator==(std::nullptr_t, local_shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `p.get() == 0`.
|
||||
|
||||
```
|
||||
@ -539,14 +603,18 @@ template<class T> bool operator!=(local_shared_ptr<T> const & p, std::nullptr_t)
|
||||
```
|
||||
template<class T> bool operator!=(std::nullptr_t, local_shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `p.get() != 0`.
|
||||
|
||||
```
|
||||
template<class T, class U>
|
||||
bool operator<(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: An unspecified value such that
|
||||
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
|
||||
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `local_shared_ptr` instances
|
||||
@ -560,7 +628,9 @@ NOTE: The rest of the comparison operators are omitted by design.
|
||||
```
|
||||
template<class T> void swap(local_shared_ptr<T> & a, local_shared_ptr<T> & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
### get_pointer
|
||||
@ -569,7 +639,9 @@ template<class T>
|
||||
typename local_shared_ptr<T>::element_type *
|
||||
get_pointer(local_shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `p.get()`.
|
||||
|
||||
NOTE: Provided as an aid to generic programming. Used by `mem_fn`.
|
||||
@ -579,7 +651,9 @@ NOTE: Provided as an aid to generic programming. Used by `mem_fn`.
|
||||
template<class T, class U>
|
||||
local_shared_ptr<T> static_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `static_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns:: `local_shared_ptr<T>( r, static_cast<typename local_shared_ptr<T>::element_type*>(r.get()) )`.
|
||||
|
||||
@ -591,7 +665,9 @@ result in undefined behavior, attempting to delete the same object twice.
|
||||
template<class T, class U>
|
||||
local_shared_ptr<T> const_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `const_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns:: `local_shared_ptr<T>( r, const_cast<typename local_shared_ptr<T>::element_type*>(r.get()) )`.
|
||||
|
||||
@ -600,7 +676,9 @@ Returns:: `local_shared_ptr<T>( r, const_cast<typename local_shared_ptr<T>::elem
|
||||
template<class T, class U>
|
||||
local_shared_ptr<T> dynamic_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `dynamic_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns::
|
||||
- When `dynamic_cast<typename local_shared_ptr<T>::element_type*>(r.get())` returns a nonzero value `p`, `local_shared_ptr<T>(r, p)`;
|
||||
@ -611,7 +689,9 @@ Returns::
|
||||
template<class T, class U>
|
||||
local_shared_ptr<T> reinterpret_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `reinterpret_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns:: `local_shared_ptr<T>( r, reinterpret_cast<typename local_shared_ptr<T>::element_type*>(r.get()) )`.
|
||||
|
||||
@ -621,7 +701,9 @@ template<class E, class T, class Y>
|
||||
std::basic_ostream<E, T> &
|
||||
operator<< (std::basic_ostream<E, T> & os, local_shared_ptr<Y> const & p);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `os << p.get();`.
|
||||
Returns:: `os`.
|
||||
|
||||
@ -630,6 +712,7 @@ Returns:: `os`.
|
||||
template<class D, class T>
|
||||
D * get_deleter(local_shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: If `*this` owns a `shared_ptr` instance `p`, `get_deleter<D>( p )`, otherwise 0.
|
||||
|
||||
|
@ -178,7 +178,9 @@ template<class T, class... Args>
|
||||
template<class T, class A, class... Args>
|
||||
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns:: A `shared_ptr` to an object of type `T`, constructed from
|
||||
@ -195,7 +197,9 @@ template<class T>
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared(const A& a, std::size_t n);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns:: A `shared_ptr` to a sequence of `n` value-initialized objects of
|
||||
@ -212,7 +216,9 @@ template<class T>
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared(const A& a);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[N]`.
|
||||
Returns:: A `shared_ptr` to a sequence of `N` value-initialized objects of
|
||||
@ -229,7 +235,9 @@ template<class T> shared_ptr<T>
|
||||
template<class T, class A> shared_ptr<T>
|
||||
allocate_shared(const A& a, std::size_t n, const remove_extent_t<T>& v);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns:: A `shared_ptr` to a sequence of `n` objects of type `U`, each
|
||||
@ -247,7 +255,9 @@ template<class T>
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& v);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[N]`.
|
||||
Returns:: A `shared_ptr` to a sequence of `N` objects of type `U`, each
|
||||
@ -265,7 +275,9 @@ template<class T>
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared_noinit(const A& a);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type, or an array type of the `U[N]`.
|
||||
Returns:: A `shared_ptr` to a default-initialized object of type `T`, or a
|
||||
@ -280,7 +292,9 @@ template<class T>
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared_noinit(const A& a, std::size_t n);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns:: A `shared_ptr` to a sequence of `_n_` default-initialized objects
|
||||
|
@ -68,7 +68,9 @@ namespace boost {
|
||||
template<class T, class... Args>
|
||||
std::unique_ptr<T> make_unique(Args&&... args);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns:: `std::unique_ptr<T>(new T(std::forward<Args>(args)\...)`.
|
||||
@ -78,7 +80,9 @@ Example:: `auto p = make_unique<int>();`
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique(remove_reference_t<T>&& v);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns:: `std::unique_ptr<T>(new T(std::move(v))`.
|
||||
@ -88,7 +92,9 @@ Example:: `auto p = make_unique<std::vector<int> >({1, 2});`
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique(std::size_t n);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns:: `std::unique_ptr<U[]>(new U[n]())`.
|
||||
@ -98,7 +104,9 @@ Example:: `auto p = make_unique<double[]>(1024);`
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique_noinit();
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns:: `std::unique_ptr<T>(new T)`.
|
||||
@ -108,7 +116,9 @@ Example:: `auto p = make_unique_noinit<double[1024]>();`
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique_noinit(std::size_t n);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns:: `std::unique_ptr<U[]>(new U[n])`.
|
||||
|
@ -78,21 +78,27 @@ namespace boost {
|
||||
```
|
||||
template<class T, class U> T* static_pointer_cast(U* p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `static_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
static_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `std::static_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
static_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `static_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns:: `std::unique_ptr<T>(static_cast<typename
|
||||
std::unique_ptr<T>::element_type*>(p.release()))`.
|
||||
@ -106,21 +112,27 @@ undefined behavior, attempting to delete the same object twice.
|
||||
```
|
||||
template<class T, class U> T* dynamic_pointer_cast(U* p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `dynamic_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
dynamic_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `std::dynamic_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
dynamic_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires::
|
||||
* The expression `static_cast<T*>((U*)0)` must be well-formed.
|
||||
* `T` must have a virtual destructor.
|
||||
@ -135,21 +147,27 @@ std::unique_ptr<T>::element_type*>(p.release()));`.
|
||||
```
|
||||
template<class T, class U> T* const_pointer_cast(U* p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `const_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
const_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `std::const_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
const_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `const_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns:: `std::unique_ptr<T>(const_cast<typename
|
||||
std::unique_ptr<T>::element_type*>(p.release()))`.
|
||||
@ -159,21 +177,27 @@ std::unique_ptr<T>::element_type*>(p.release()))`.
|
||||
```
|
||||
template<class T, class U> T* reinterpret_pointer_cast(U* p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `reinterpret_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
reinterpret_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `std::reinterpret_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
reinterpret_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `reinterpret_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns:: `std::unique_ptr<T>(reinterpret_cast<typename
|
||||
std::unique_ptr<T>::element_type*>(p.release()))`.
|
||||
@ -210,4 +234,4 @@ int main()
|
||||
|
||||
delete ptr;
|
||||
}
|
||||
```
|
||||
```
|
||||
|
@ -105,7 +105,9 @@ Type:: Provides the type of the stored pointer.
|
||||
```
|
||||
explicit shared_array(T* p = 0);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `shared_array`, storing a copy of `p`, which must be a
|
||||
pointer to an array that was allocated via a C++ `new[]` expression or be 0.
|
||||
Afterwards, the use count is 1 (even if `p == 0`; see `~shared_array`).
|
||||
@ -115,11 +117,13 @@ Throws:: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
|
||||
```
|
||||
template<class D> shared_array(T* p, D d);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `shared_array`, storing a copy of `p` and of `d`.
|
||||
Afterwards, the use count is 1. When the the time comes to delete the array
|
||||
pointed to by `p`, the object `d` is used in the statement `d(p)`.
|
||||
Requires[horizontal]
|
||||
Requires::
|
||||
* `T` is a complete type.
|
||||
* The copy constructor and destructor of `D` must not throw.
|
||||
* Invoking the object `d` with parameter `p` must not throw.
|
||||
@ -128,7 +132,9 @@ Throws:: `std::bad_alloc`. If an exception is thrown, `d(p)` is called.
|
||||
```
|
||||
shared_array(const shared_array& v) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `shared_array`, as if by storing a copy of the pointer
|
||||
stored in `v`. Afterwards, the use count for all copies is 1 more than the
|
||||
initial use count.
|
||||
@ -139,7 +145,9 @@ Requires:: `T` is a complete type.
|
||||
```
|
||||
~shared_array() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Decrements the use count. Then, if the use count is 0, deletes the
|
||||
array pointed to by the stored pointer. Note that `delete[]` on a pointer with
|
||||
a value of 0 is harmless.
|
||||
@ -149,7 +157,9 @@ a value of 0 is harmless.
|
||||
```
|
||||
shared_array& operator=(const shared_array& v) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a new `shared_array` as described above, then replaces
|
||||
this `shared_array` with the new one, destroying the replaced object.
|
||||
Requires:: `T` is a complete type.
|
||||
@ -160,7 +170,9 @@ Returns:: `*this`.
|
||||
```
|
||||
void reset(T* p = 0);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a new `shared_array` as described above, then replaces
|
||||
this `shared_array` with the new one, destroying the replaced object.
|
||||
Requires:: `T` is a complete type.
|
||||
@ -169,10 +181,12 @@ Throws:: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
|
||||
```
|
||||
template<class D> void reset(T* p, D d);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a new `shared_array` as described above, then replaces
|
||||
this `shared_array` with the new one, destroying the replaced object.
|
||||
Requires[horizontal]
|
||||
Requires::
|
||||
* `T` is a complete type.
|
||||
* The copy constructor of `D` must not throw.
|
||||
Throws:: `std::bad_alloc`. If an exception is thrown, `d(p)` is called.
|
||||
@ -193,7 +207,9 @@ Requires:: `T` is a complete type.
|
||||
```
|
||||
T* get() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The stored pointer.
|
||||
|
||||
### unique
|
||||
@ -201,7 +217,9 @@ Returns:: The stored pointer.
|
||||
```
|
||||
bool unique() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `true` if no other `shared_array` is sharing ownership of the
|
||||
stored pointer, `false` otherwise.
|
||||
|
||||
@ -210,7 +228,9 @@ stored pointer, `false` otherwise.
|
||||
```
|
||||
long use_count() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The number of `shared_array` objects sharing ownership of the
|
||||
stored pointer.
|
||||
|
||||
@ -219,7 +239,9 @@ stored pointer.
|
||||
```
|
||||
explicit operator bool() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `get() != 0`.
|
||||
Requires:: `T` is a complete type.
|
||||
|
||||
@ -228,7 +250,9 @@ Requires:: `T` is a complete type.
|
||||
```
|
||||
void swap(shared_array<T>& b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
## Free Functions
|
||||
@ -247,7 +271,9 @@ template<class T> bool
|
||||
template<class T> bool
|
||||
operator<(const shared_array<T>& a, const shared_array<T>& b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The result of comparing the stored pointers of the two smart
|
||||
pointers.
|
||||
|
||||
@ -265,6 +291,8 @@ mandates that relational operations on pointers are unspecified (5.9
|
||||
template<class T>
|
||||
void swap(shared_array<T>& a, shared_array<T>& b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.swap(b)`.
|
||||
Requires:: `T` is a complete type.
|
||||
|
@ -263,7 +263,9 @@ constexpr shared_ptr() noexcept;
|
||||
```
|
||||
constexpr shared_ptr(std::nullptr_t) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs an empty `shared_ptr`.
|
||||
Postconditions:: `use_count() == 0 && get() == 0`.
|
||||
|
||||
@ -271,7 +273,9 @@ Postconditions:: `use_count() == 0 && get() == 0`.
|
||||
```
|
||||
template<class Y> explicit shared_ptr(Y * p);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y` must be a complete type. The expression `delete[] p`, when `T` is an array type, or `delete p`, when `T` is not an array type,
|
||||
must be well-formed, well-defined, and not throw exceptions. When `T` is `U[N]`, `Y(\*)[N]` must be convertible to `T*`; when `T` is `U[]`, `Y(\*)[]`
|
||||
must be convertible to `T*`; otherwise, `Y\*` must be convertible to `T*`.
|
||||
@ -305,7 +309,9 @@ template<class D> shared_ptr(std::nullptr_t p, D d);
|
||||
```
|
||||
template<class D, class A> shared_ptr(std::nullptr_t p, D d, A a);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `D` must be `CopyConstructible`. The copy constructor and destructor of `D` must not throw. The expression `d(p)` must be well-formed, well-defined,
|
||||
and not throw exceptions. `A` must be an `Allocator`, as described in section Allocator Requirements [allocator.requirements] of the {cpp} Standard.
|
||||
When `T` is `U[N]`, `Y(\*)[N]` must be convertible to `T*`; when `T` is `U[]`, `Y(\*)[]` must be convertible to `T*`; otherwise, `Y\*` must be convertible to `T*`.
|
||||
@ -335,7 +341,9 @@ shared_ptr(shared_ptr const & r) noexcept;
|
||||
```
|
||||
template<class Y> shared_ptr(shared_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects:: If `r` is empty, constructs an empty `shared_ptr`; otherwise, constructs a `shared_ptr` that shares ownership with `r`.
|
||||
@ -349,7 +357,9 @@ shared_ptr(shared_ptr && r) noexcept;
|
||||
```
|
||||
template<class Y> shared_ptr(shared_ptr<Y> && r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects:: Move-constructs a `shared_ptr` from `r`.
|
||||
@ -360,7 +370,9 @@ Postconditions:: `*this` contains the old value of `r`. `r` is empty and `r.get(
|
||||
```
|
||||
template<class Y> shared_ptr(shared_ptr<Y> const & r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: constructs a `shared_ptr` that shares ownership with `r` and stores `p`.
|
||||
|
||||
Postconditions:: `get() == p && use_count() == r.use_count()`.
|
||||
@ -369,7 +381,9 @@ Postconditions:: `get() == p && use_count() == r.use_count()`.
|
||||
```
|
||||
template<class Y> shared_ptr(shared_ptr<Y> && r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Move-constructs a `shared_ptr` from `r`, while storing `p` instead.
|
||||
|
||||
Postconditions:: `get() == p` and `use_count()` equals the old count of `r`. `r` is empty and `r.get() == 0`.
|
||||
@ -378,7 +392,9 @@ Postconditions:: `get() == p` and `use_count()` equals the old count of `r`. `r`
|
||||
```
|
||||
template<class Y> explicit shared_ptr(weak_ptr<Y> const & r);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects:: Constructs a `shared_ptr` that shares ownership with `r` and stores a copy of the pointer stored in `r`.
|
||||
@ -396,7 +412,9 @@ template<class Y> shared_ptr(std::auto_ptr<Y> & r);
|
||||
```
|
||||
template<class Y> shared_ptr(std::auto_ptr<Y> && r);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects:: Constructs a `shared_ptr`, as if by storing a copy of `r.release()`.
|
||||
@ -411,7 +429,9 @@ Exception safety:: If an exception is thrown, the constructor has no effect.
|
||||
```
|
||||
template<class Y, class D> shared_ptr(std::unique_ptr<Y, D> && r);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects::
|
||||
@ -428,7 +448,9 @@ Exception safety:: If an exception is thrown, the constructor has no effect.
|
||||
```
|
||||
~shared_ptr() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects::
|
||||
- If `*this` is empty, or shares ownership with another `shared_ptr` instance (`use_count() > 1`), there are no side effects.
|
||||
- Otherwise, if `*this` owns a pointer `p` and a deleter `d`, `d(p)` is called.
|
||||
@ -444,7 +466,9 @@ template<class Y> shared_ptr & operator=(shared_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
template<class Y> shared_ptr & operator=(std::auto_ptr<Y> & r);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr(r).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@ -475,14 +499,18 @@ template<class Y> shared_ptr & operator=(std::auto_ptr<Y> && r);
|
||||
```
|
||||
template<class Y, class D> shared_ptr & operator=(std::unique_ptr<Y, D> && r);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr(std::move(r)).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
```
|
||||
shared_ptr & operator=(std::nullptr_t) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr().swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@ -490,58 +518,76 @@ Returns:: `*this`.
|
||||
```
|
||||
void reset() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr().swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(Y * p);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr(p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y, class D> void reset(Y * p, D d);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr(p, d).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y, class D, class A> void reset(Y * p, D d, A a);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr(p, d, a).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(shared_ptr<Y> const & r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr(r, p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(shared_ptr<Y> && r, element_type * p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `shared_ptr(std::move(r), p).swap(*this)`.
|
||||
|
||||
### indirection
|
||||
```
|
||||
T & operator*() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `T` should not be an array type. The stored pointer must not be 0.
|
||||
Returns:: `*get()`.
|
||||
|
||||
```
|
||||
T * operator->() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `T` should not be an array type. The stored pointer must not be 0.
|
||||
Returns:: `get()`.
|
||||
|
||||
```
|
||||
element_type & operator[](std::ptrdiff_t i) const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: `T` should be an array type. The stored pointer must not be 0. `i >= 0`. If `T` is `U[N]`, `i < N`.
|
||||
Returns:: `get()[i]`.
|
||||
|
||||
@ -550,28 +596,36 @@ Returns:: `get()[i]`.
|
||||
```
|
||||
element_type * get() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The stored pointer.
|
||||
|
||||
### unique
|
||||
```
|
||||
bool unique() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `use_count() == 1`.
|
||||
|
||||
### use_count
|
||||
```
|
||||
long use_count() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The number of `shared_ptr` objects, `*this` included, that share ownership with `*this`, or 0 when `*this` is empty.
|
||||
|
||||
### conversions
|
||||
```
|
||||
explicit operator bool() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `get() != 0`.
|
||||
|
||||
NOTE: This conversion operator allows `shared_ptr` objects to be used in boolean contexts, like `if(p && p\->valid()) {}`.
|
||||
@ -585,7 +639,9 @@ NOTE: On C++03 compilers, the return value is of an unspecified type.
|
||||
```
|
||||
void swap(shared_ptr & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
### owner_before
|
||||
@ -595,7 +651,9 @@ template<class Y> bool owner_before(shared_ptr<Y> const & rhs) const noexcept;
|
||||
```
|
||||
template<class Y> bool owner_before(weak_ptr<Y> const & rhs) const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: See the description of `operator<`.
|
||||
|
||||
## Free Functions
|
||||
@ -605,14 +663,18 @@ Effects:: See the description of `operator<`.
|
||||
template<class T, class U>
|
||||
bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() == b.get()`.
|
||||
|
||||
```
|
||||
template<class T, class U>
|
||||
bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `a.get() != b.get()`.
|
||||
|
||||
```
|
||||
@ -621,7 +683,9 @@ template<class T> bool operator==(shared_ptr<T> const & p, std::nullptr_t) noexc
|
||||
```
|
||||
template<class T> bool operator==(std::nullptr_t, shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `p.get() == 0`.
|
||||
|
||||
```
|
||||
@ -630,14 +694,18 @@ template<class T> bool operator!=(shared_ptr<T> const & p, std::nullptr_t) noexc
|
||||
```
|
||||
template<class T> bool operator!=(std::nullptr_t, shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `p.get() != 0`.
|
||||
|
||||
```
|
||||
template<class T, class U>
|
||||
bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: An unspecified value such that
|
||||
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
|
||||
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `shared_ptr` instances
|
||||
@ -651,7 +719,9 @@ NOTE: The rest of the comparison operators are omitted by design.
|
||||
```
|
||||
template<class T> void swap(shared_ptr<T> & a, shared_ptr<T> & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
### get_pointer
|
||||
@ -660,7 +730,9 @@ template<class T>
|
||||
typename shared_ptr<T>::element_type *
|
||||
get_pointer(shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `p.get()`.
|
||||
|
||||
NOTE: Provided as an aid to generic programming. Used by `mem_fn`.
|
||||
@ -670,7 +742,9 @@ NOTE: Provided as an aid to generic programming. Used by `mem_fn`.
|
||||
template<class T, class U>
|
||||
shared_ptr<T> static_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `static_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns:: `shared_ptr<T>( r, static_cast<typename shared_ptr<T>::element_type*>(r.get()) )`.
|
||||
|
||||
@ -682,7 +756,9 @@ result in undefined behavior, attempting to delete the same object twice.
|
||||
template<class T, class U>
|
||||
shared_ptr<T> const_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `const_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns:: `shared_ptr<T>( r, const_cast<typename shared_ptr<T>::element_type*>(r.get()) )`.
|
||||
|
||||
@ -691,7 +767,9 @@ Returns:: `shared_ptr<T>( r, const_cast<typename shared_ptr<T>::element_type*>(r
|
||||
template<class T, class U>
|
||||
shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `dynamic_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns::
|
||||
- When `dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())` returns a nonzero value `p`, `shared_ptr<T>(r, p)`;
|
||||
@ -702,7 +780,9 @@ Returns::
|
||||
template<class T, class U>
|
||||
shared_ptr<T> reinterpret_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires:: The expression `reinterpret_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns:: `shared_ptr<T>( r, reinterpret_cast<typename shared_ptr<T>::element_type*>(r.get()) )`.
|
||||
|
||||
@ -712,7 +792,9 @@ template<class E, class T, class Y>
|
||||
std::basic_ostream<E, T> &
|
||||
operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p);
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `os << p.get();`.
|
||||
Returns:: `os`.
|
||||
|
||||
@ -721,7 +803,9 @@ Returns:: `os`.
|
||||
template<class D, class T>
|
||||
D * get_deleter(shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: If `*this` owns a deleter `d` of type (cv-unqualified) `D`, returns `&d`; otherwise returns 0.
|
||||
|
||||
### Atomic Access
|
||||
@ -733,7 +817,9 @@ NOTE: The function in this section are atomic with respect to the first `shared_
|
||||
```
|
||||
template<class T> bool atomic_is_lock_free( shared_ptr<T> const * p ) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `false`.
|
||||
|
||||
NOTE: This implementation is not lock-free.
|
||||
@ -744,7 +830,9 @@ template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) noexcept;
|
||||
```
|
||||
template<class T> shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, int ) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `*p`.
|
||||
|
||||
NOTE: The `int` argument is the `memory_order`, but this implementation does not use it, as it's lock-based
|
||||
@ -758,7 +846,9 @@ template<class T>
|
||||
template<class T>
|
||||
void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, int ) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `p\->swap(r)`.
|
||||
|
||||
```
|
||||
@ -770,7 +860,9 @@ template<class T>
|
||||
shared_ptr<T> atomic_exchange_explicit(
|
||||
shared_ptr<T> * p, shared_ptr<T> r, int ) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `p\->swap(r)`.
|
||||
Returns:: The old value of `*p`.
|
||||
|
||||
@ -784,7 +876,9 @@ template<class T>
|
||||
bool atomic_compare_exchange_explicit(
|
||||
shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, int, int ) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: If `*p` is equivalent to `*v`, assigns `w` to `*p`, otherwise assigns `*p` to `*v`.
|
||||
Returns:: `true` if `*p` was equivalent to `*v`, `false` otherwise.
|
||||
Remarks:: Two `shared_ptr` instances are equivalent if they store the same pointer value and _share ownership_.
|
||||
|
@ -127,7 +127,9 @@ typedef ... element_type;
|
||||
```
|
||||
weak_ptr() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs an empty `weak_ptr`.
|
||||
Postconditions:: `use_count() == 0`.
|
||||
|
||||
@ -140,14 +142,18 @@ weak_ptr(weak_ptr const & r) noexcept;
|
||||
```
|
||||
template<class Y> weak_ptr(weak_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: If `r` is empty, constructs an empty `weak_ptr`; otherwise, constructs a `weak_ptr` that shares ownership with `r` as if by storing a copy of the pointer stored in `r`.
|
||||
Postconditions:: `use_count() == r.use_count()`.
|
||||
|
||||
```
|
||||
weak_ptr(weak_ptr && r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Constructs a `weak_ptr` that has the value `r` held.
|
||||
Postconditions:: `r` is empty.
|
||||
|
||||
@ -155,7 +161,9 @@ Postconditions:: `r` is empty.
|
||||
```
|
||||
~weak_ptr() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Destroys this `weak_ptr` but has no effect on the object its stored pointer points to.
|
||||
|
||||
### assignment
|
||||
@ -171,7 +179,9 @@ template<class Y> weak_ptr & operator=(weak_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
template<class Y> weak_ptr & operator=(shared_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `weak_ptr(r).swap(*this)`.
|
||||
|
||||
NOTE: The implementation is free to meet the effects (and the implied guarantees) via different means, without creating a temporary.
|
||||
@ -180,35 +190,45 @@ NOTE: The implementation is free to meet the effects (and the implied guarantees
|
||||
```
|
||||
long use_count() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: 0 if `*this` is empty; otherwise, the number of `shared_ptr` objects that share ownership with `*this`.
|
||||
|
||||
### expired
|
||||
```
|
||||
bool expired() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `use_count() == 0`.
|
||||
|
||||
### lock
|
||||
```
|
||||
shared_ptr<T> lock() const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: `expired()? shared_ptr<T>(): shared_ptr<T>(*this)`.
|
||||
|
||||
### reset
|
||||
```
|
||||
void reset() noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `weak_ptr().swap(*this)`.
|
||||
|
||||
### swap
|
||||
```
|
||||
void swap(weak_ptr & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
```
|
||||
@ -217,7 +237,9 @@ template<class Y> bool owner_before( weak_ptr<Y> const & r ) const noexcept;
|
||||
```
|
||||
template<class Y> bool owner_before( shared_ptr<Y> const & r ) const noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: See the description of `operator<`.
|
||||
|
||||
## Free Functions
|
||||
@ -227,7 +249,9 @@ Returns:: See the description of `operator<`.
|
||||
template<class T, class U>
|
||||
bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: An unspecified value such that
|
||||
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
|
||||
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `weak_ptr` instances
|
||||
@ -239,7 +263,9 @@ NOTE: Allows `weak_ptr` objects to be used as keys in associative containers.
|
||||
```
|
||||
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) noexcept;
|
||||
```
|
||||
[horizontal]
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
Reference in New Issue
Block a user