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