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;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Postconditions:: `get() == 0`.
|
||||
|
||||
```
|
||||
intrusive_ptr(T * p, bool add_ref = true);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `if(p != 0 && add_ref) intrusive_ptr_add_ref(p);`.
|
||||
Postconditions:: `get() == p`.
|
||||
|
||||
@@ -158,9 +154,7 @@ intrusive_ptr(intrusive_ptr const & r);
|
||||
template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `T * p = r.get(); if(p != 0) intrusive_ptr_add_ref(p);`.
|
||||
Postconditions:: `get() == r.get()`.
|
||||
|
||||
@@ -171,9 +165,7 @@ intrusive_ptr(intrusive_ptr && r);
|
||||
template<class Y> intrusive_ptr(intrusive_ptr<Y> && r);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Postconditions:: `get()` equals the old value of `r.get()`. `r.get() == 0`.
|
||||
|
||||
### destructor
|
||||
@@ -182,9 +174,7 @@ Postconditions:: `get()` equals the old value of `r.get()`. `r.get() == 0`.
|
||||
~intrusive_ptr();
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `if(get() != 0) intrusive_ptr_release(get());`.
|
||||
|
||||
### assignment
|
||||
@@ -199,9 +189,7 @@ template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> const & r);
|
||||
intrusive_ptr & operator=(T * r);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `intrusive_ptr(r).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@@ -212,9 +200,7 @@ intrusive_ptr & operator=(intrusive_ptr && r);
|
||||
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> && r);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `intrusive_ptr(std::move(r)).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@@ -224,27 +210,21 @@ Returns:: `*this`.
|
||||
void reset();
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `intrusive_ptr().swap(*this)`.
|
||||
|
||||
```
|
||||
void reset(T * r);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `intrusive_ptr(r).swap(*this)`.
|
||||
|
||||
```
|
||||
void reset(T * r, bool add_ref);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `intrusive_ptr(r, add_ref).swap(*this)`.
|
||||
|
||||
### indirection
|
||||
@@ -253,9 +233,7 @@ Effects:: Equivalent to `intrusive_ptr(r, add_ref).swap(*this)`.
|
||||
T & operator*() const noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requirements:: `get() != 0`.
|
||||
Returns:: `*get()`.
|
||||
|
||||
@@ -263,9 +241,7 @@ Returns:: `*get()`.
|
||||
T * operator->() const noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requirements:: `get() != 0`.
|
||||
Returns:: `get()`.
|
||||
|
||||
@@ -275,9 +251,7 @@ Returns:: `get()`.
|
||||
T * get() const noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: the stored pointer.
|
||||
|
||||
### detach
|
||||
@@ -286,9 +260,7 @@ Returns:: the stored pointer.
|
||||
T * detach() noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: the stored pointer.
|
||||
Postconditions:: `get() == 0`.
|
||||
|
||||
@@ -306,9 +278,7 @@ the implications are thoroughly understood.
|
||||
explicit operator bool () const noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `get() != 0`.
|
||||
|
||||
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;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
## Free Functions
|
||||
@@ -336,9 +304,7 @@ template<class T, class U>
|
||||
bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `a.get() != b.get()`.
|
||||
|
||||
```
|
||||
@@ -356,9 +320,7 @@ template<class T, class U>
|
||||
bool operator==(intrusive_ptr<T> const & a, U * b) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `a.get() == b`.
|
||||
|
||||
```
|
||||
@@ -366,9 +328,7 @@ template<class T, class U>
|
||||
bool operator!=(intrusive_ptr<T> const & a, U * b) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `a.get() != b`.
|
||||
|
||||
```
|
||||
@@ -376,9 +336,7 @@ template<class T, class U>
|
||||
bool operator==(T * a, intrusive_ptr<U> const & b) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `a == b.get()`.
|
||||
|
||||
```
|
||||
@@ -386,9 +344,7 @@ template<class T, class U>
|
||||
bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `a != b.get()`.
|
||||
|
||||
```
|
||||
@@ -396,9 +352,7 @@ template<class T>
|
||||
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `std::less<T *>()(a.get(), b.get())`.
|
||||
|
||||
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;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
### get_pointer
|
||||
@@ -420,9 +372,7 @@ Effects:: Equivalent to `a.swap(b)`.
|
||||
template<class T> T * get_pointer(intrusive_ptr<T> const & p) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `p.get()`.
|
||||
|
||||
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;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `intrusive_ptr<T>(static_cast<T*>(r.get()))`.
|
||||
|
||||
### const_pointer_cast
|
||||
@@ -446,9 +394,7 @@ template<class T, class U>
|
||||
intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & r) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `intrusive_ptr<T>(const_cast<T*>(r.get()))`.
|
||||
|
||||
### dynamic_pointer_cast
|
||||
@@ -458,9 +404,7 @@ template<class T, class U>
|
||||
intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & r) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `intrusive_ptr<T>(dynamic_cast<T*>(r.get()))`.
|
||||
|
||||
### operator<<
|
||||
@@ -471,8 +415,6 @@ template<class E, class T, class Y>
|
||||
intrusive_ptr<Y> const & p);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `os << p.get();`.
|
||||
Returns:: `os`.
|
||||
|
@@ -78,12 +78,11 @@ namespace boost {
|
||||
```
|
||||
intrusive_ref_counter() noexcept;
|
||||
```
|
||||
::
|
||||
```
|
||||
intrusive_ref_counter(const intrusive_ref_counter&) noexcept;
|
||||
```
|
||||
::
|
||||
Postconditions::: `use_count() == 0`.
|
||||
[horizontal]
|
||||
Postconditions:: `use_count() == 0`.
|
||||
|
||||
NOTE: The pointer to the constructed object is expected to be passed to
|
||||
`intrusive_ptr` constructor, assignment operator or `reset` method, which
|
||||
@@ -94,8 +93,8 @@ would increment the reference counter.
|
||||
```
|
||||
~intrusive_ref_counter();
|
||||
```
|
||||
::
|
||||
Effects::: Destroys the counter object.
|
||||
[horizontal]
|
||||
Effects:: Destroys the counter object.
|
||||
|
||||
NOTE: The destructor is protected so that the object can only be destroyed
|
||||
through the `Derived` class.
|
||||
@@ -105,16 +104,16 @@ through the `Derived` class.
|
||||
```
|
||||
intrusive_ref_counter& operator=(const intrusive_ref_counter& v) noexcept;
|
||||
```
|
||||
::
|
||||
Effects::: Does nothing, reference counter is not modified.
|
||||
[horizontal]
|
||||
Effects:: Does nothing, reference counter is not modified.
|
||||
|
||||
### use_count
|
||||
|
||||
```
|
||||
unsigned int use_count() const noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: The current value of the reference counter.
|
||||
[horizontal]
|
||||
Returns:: The current value of the reference counter.
|
||||
|
||||
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(
|
||||
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
|
||||
```
|
||||
::
|
||||
Effects::: Increments the reference counter.
|
||||
[horizontal]
|
||||
Effects:: Increments the reference counter.
|
||||
|
||||
### intrusive_ptr_release
|
||||
|
||||
@@ -137,6 +136,6 @@ template<class Derived, class CounterPolicy>
|
||||
void intrusive_ptr_release(
|
||||
const intrusive_ref_counter<Derived, CounterPolicy>* p) noexcept;
|
||||
```
|
||||
::
|
||||
Effects::: Decrements the reference counter. If the reference counter reaches
|
||||
[horizontal]
|
||||
Effects:: Decrements the reference counter. If the reference counter reaches
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs an empty `local_shared_ptr`.
|
||||
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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( 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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p, d )`.
|
||||
|
||||
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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `shared_ptr<T>( p, d, a )`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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`.
|
||||
@@ -300,9 +290,7 @@ local_shared_ptr(local_shared_ptr && r) noexcept;
|
||||
```
|
||||
template<class Y> local_shared_ptr(local_shared_ptr<Y> && r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
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 );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs a `local_shared_ptr` that owns `r`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: constructs a `local_shared_ptr` that shares ownership with `r` and stores `p`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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`.
|
||||
@@ -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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects::
|
||||
@@ -368,9 +348,7 @@ Exception safety:: If an exception is thrown, the constructor has no effect.
|
||||
```
|
||||
~local_shared_ptr() noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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`.
|
||||
@@ -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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `local_shared_ptr(r).swap(*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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `local_shared_ptr(std::move(r)).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
```
|
||||
local_shared_ptr & operator=(std::nullptr_t) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `local_shared_ptr().swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@@ -416,76 +388,58 @@ Returns:: `*this`.
|
||||
```
|
||||
void reset() noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `local_shared_ptr().swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(Y * p);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `local_shared_ptr(p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y, class D> void reset(Y * p, D d);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `local_shared_ptr(r, p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(local_shared_ptr<Y> && r, element_type * p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `local_shared_ptr(std::move(r), p).swap(*this)`.
|
||||
|
||||
### indirection
|
||||
```
|
||||
T & operator*() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `T` should not be an array type.
|
||||
Returns:: `*get()`.
|
||||
|
||||
```
|
||||
T * operator->() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `T` should not be an array type.
|
||||
Returns:: `get()`.
|
||||
|
||||
```
|
||||
element_type & operator[](std::ptrdiff_t i) const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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]`.
|
||||
|
||||
@@ -494,27 +448,21 @@ Returns:: `get()[i]`.
|
||||
```
|
||||
element_type * get() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: The stored pointer.
|
||||
|
||||
### local_use_count
|
||||
```
|
||||
long local_use_count() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: The number of `local_shared_ptr` objects, `*this` included, that share ownership with `*this`, or 0 when `*this` is empty.
|
||||
|
||||
### conversions
|
||||
```
|
||||
explicit operator bool() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `get() != 0`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `T*` should be convertible to `Y*`.
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
### owner_before
|
||||
```
|
||||
template<class Y> bool owner_before(local_shared_ptr<Y> const & rhs) const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: See the description of `operator<`.
|
||||
|
||||
## Free Functions
|
||||
@@ -564,9 +506,7 @@ template<class T, class U>
|
||||
template<class T, class U>
|
||||
bool operator==(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `a.get() == b.get()`.
|
||||
|
||||
```
|
||||
@@ -581,9 +521,7 @@ template<class T, class U>
|
||||
template<class T, class U>
|
||||
bool operator!=(shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `p.get() != 0`.
|
||||
|
||||
```
|
||||
template<class T, class U>
|
||||
bool operator<(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: An unspecified value such that
|
||||
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
|
||||
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `local_shared_ptr` instances
|
||||
@@ -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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
### get_pointer
|
||||
@@ -639,9 +569,7 @@ template<class T>
|
||||
typename local_shared_ptr<T>::element_type *
|
||||
get_pointer(local_shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `p.get()`.
|
||||
|
||||
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>
|
||||
local_shared_ptr<T> static_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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()) )`.
|
||||
|
||||
@@ -665,9 +591,7 @@ result in undefined behavior, attempting to delete the same object twice.
|
||||
template<class T, class U>
|
||||
local_shared_ptr<T> const_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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()) )`.
|
||||
|
||||
@@ -676,9 +600,7 @@ Returns:: `local_shared_ptr<T>( r, const_cast<typename local_shared_ptr<T>::elem
|
||||
template<class T, class U>
|
||||
local_shared_ptr<T> dynamic_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: The expression `dynamic_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns::
|
||||
- When `dynamic_cast<typename local_shared_ptr<T>::element_type*>(r.get())` returns a nonzero value `p`, `local_shared_ptr<T>(r, p)`;
|
||||
@@ -689,9 +611,7 @@ Returns::
|
||||
template<class T, class U>
|
||||
local_shared_ptr<T> reinterpret_pointer_cast(local_shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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()) )`.
|
||||
|
||||
@@ -701,9 +621,7 @@ template<class E, class T, class Y>
|
||||
std::basic_ostream<E, T> &
|
||||
operator<< (std::basic_ostream<E, T> & os, local_shared_ptr<Y> const & p);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `os << p.get();`.
|
||||
Returns:: `os`.
|
||||
|
||||
@@ -712,8 +630,6 @@ Returns:: `os`.
|
||||
template<class D, class T>
|
||||
D * get_deleter(local_shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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>
|
||||
shared_ptr<T> make_shared(Args&&... args);
|
||||
```
|
||||
::
|
||||
```
|
||||
template<class T, class A, class... Args>
|
||||
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns::: A `shared_ptr` to an object of type `T`, constructed from
|
||||
Returns:: A `shared_ptr` to an object of type `T`, constructed from
|
||||
`args\...`.
|
||||
Examples:::
|
||||
Examples::
|
||||
* `auto p = make_shared<int>();`
|
||||
* `auto p = make_shared<std::vector<int> >(16, 1);`
|
||||
|
||||
@@ -192,17 +191,16 @@ Examples:::
|
||||
template<class T>
|
||||
shared_ptr<T> make_shared(std::size_t n);
|
||||
```
|
||||
::
|
||||
```
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared(const A& a, std::size_t n);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns::: A `shared_ptr` to a sequence of `n` value-initialized objects of
|
||||
Returns:: A `shared_ptr` to a sequence of `n` value-initialized objects of
|
||||
type `U`.
|
||||
Examples:::
|
||||
Examples::
|
||||
* `auto p = make_shared<double[]>(1024);`
|
||||
* `auto p = make_shared<double[][2][2]>(6);`
|
||||
|
||||
@@ -210,17 +208,16 @@ Examples:::
|
||||
template<class T>
|
||||
shared_ptr<T> make_shared();
|
||||
```
|
||||
::
|
||||
```
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared(const A& a);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[N]`.
|
||||
Returns::: A `shared_ptr` to a sequence of `N` value-initialized objects of
|
||||
Returns:: A `shared_ptr` to a sequence of `N` value-initialized objects of
|
||||
type `U`.
|
||||
Examples:::
|
||||
Examples::
|
||||
* `auto p = make_shared<double[1024]>();`
|
||||
* `auto p = make_shared<double[6][2][2]>();`
|
||||
|
||||
@@ -228,17 +225,16 @@ Examples:::
|
||||
template<class T> shared_ptr<T>
|
||||
make_shared(std::size_t n, const remove_extent_t<T>& v);
|
||||
```
|
||||
::
|
||||
```
|
||||
template<class T, class A> shared_ptr<T>
|
||||
allocate_shared(const A& a, std::size_t n, const remove_extent_t<T>& v);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns::: A `shared_ptr` to a sequence of `n` objects of type `U`, each
|
||||
Returns:: A `shared_ptr` to a sequence of `n` objects of type `U`, each
|
||||
initialized to `v`.
|
||||
Examples:::
|
||||
Examples::
|
||||
* `auto p = make_shared<double[]>(1024, 1.0);`
|
||||
* `auto p = make_shared<double[][2]>(6, {1.0, 0.0});`
|
||||
* `auto p = make_shared<std::vector<int>[]>(4, {1, 2});`
|
||||
@@ -247,17 +243,16 @@ Examples:::
|
||||
template<class T>
|
||||
shared_ptr<T> make_shared(const remove_extent_t<T>& v);
|
||||
```
|
||||
::
|
||||
```
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& v);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[N]`.
|
||||
Returns::: A `shared_ptr` to a sequence of `N` objects of type `U`, each
|
||||
Returns:: A `shared_ptr` to a sequence of `N` objects of type `U`, each
|
||||
initialized to `v`.
|
||||
Examples:::
|
||||
Examples::
|
||||
* `auto p = make_shared<double[1024]>(1.0);`
|
||||
* `auto p = make_shared<double[6][2]>({1.0, 0.0});`
|
||||
* `auto p = make_shared<std::vector<int>[4]>({1, 2});`
|
||||
@@ -266,30 +261,28 @@ Examples:::
|
||||
template<class T>
|
||||
shared_ptr<T> make_shared_noinit();
|
||||
```
|
||||
::
|
||||
```
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared_noinit(const A& a);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type, or an array type of the `U[N]`.
|
||||
Returns::: A `shared_ptr` to a default-initialized object of type `T`, or a
|
||||
Returns:: A `shared_ptr` to a default-initialized object of type `T`, or a
|
||||
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>
|
||||
shared_ptr<T> make_shared_noinit(std::size_t n);
|
||||
```
|
||||
::
|
||||
```
|
||||
template<class T, class A>
|
||||
shared_ptr<T> allocate_shared_noinit(const A& a, std::size_t n);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns::: A `shared_ptr` to a sequence of `_n_` default-initialized objects
|
||||
Returns:: A `shared_ptr` to a sequence of `_n_` default-initialized objects
|
||||
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>
|
||||
std::unique_ptr<T> make_unique(Args&&... args);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns::: `std::unique_ptr<T>(new T(std::forward<Args>(args)\...)`.
|
||||
Example::: `auto p = make_unique<int>();`
|
||||
Returns:: `std::unique_ptr<T>(new T(std::forward<Args>(args)\...)`.
|
||||
Example:: `auto p = make_unique<int>();`
|
||||
|
||||
```
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique(remove_reference_t<T>&& v);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns::: `std::unique_ptr<T>(new T(std::move(v))`.
|
||||
Example::: `auto p = make_unique<std::vector<int> >({1, 2});`
|
||||
Returns:: `std::unique_ptr<T>(new T(std::move(v))`.
|
||||
Example:: `auto p = make_unique<std::vector<int> >({1, 2});`
|
||||
|
||||
```
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique(std::size_t n);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns::: `std::unique_ptr<U[]>(new U[n]())`.
|
||||
Example::: `auto p = make_unique<double[]>(1024);`
|
||||
Returns:: `std::unique_ptr<U[]>(new U[n]())`.
|
||||
Example:: `auto p = make_unique<double[]>(1024);`
|
||||
|
||||
```
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique_noinit();
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is not an array type.
|
||||
Returns::: `std::unique_ptr<T>(new T)`.
|
||||
Example::: `auto p = make_unique_noinit<double[1024]>();`
|
||||
Returns:: `std::unique_ptr<T>(new T)`.
|
||||
Example:: `auto p = make_unique_noinit<double[1024]>();`
|
||||
|
||||
```
|
||||
template<class T>
|
||||
std::unique_ptr<T> make_unique_noinit(std::size_t n);
|
||||
```
|
||||
::
|
||||
Remarks::: These overloads shall only participate in overload resolution when
|
||||
[horizontal]
|
||||
Remarks:: These overloads shall only participate in overload resolution when
|
||||
`T` is an array type of the form `U[]`.
|
||||
Returns::: `std::unique_ptr<U[]>(new U[n])`.
|
||||
Example::: `auto p = make_unique_noinit<double[]>(1024);`
|
||||
Returns:: `std::unique_ptr<U[]>(new U[n])`.
|
||||
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;
|
||||
```
|
||||
::
|
||||
Returns::: `static_cast<T*>(p)`
|
||||
[horizontal]
|
||||
Returns:: `static_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
static_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: `std::static_pointer_cast<T>(p)`
|
||||
[horizontal]
|
||||
Returns:: `std::static_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
static_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
::
|
||||
Requires::: The expression `static_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns::: `std::unique_ptr<T>(static_cast<typename
|
||||
[horizontal]
|
||||
Requires:: The expression `static_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns:: `std::unique_ptr<T>(static_cast<typename
|
||||
std::unique_ptr<T>::element_type*>(p.release()))`.
|
||||
|
||||
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;
|
||||
```
|
||||
::
|
||||
Returns::: `dynamic_cast<T*>(p)`
|
||||
[horizontal]
|
||||
Returns:: `dynamic_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
dynamic_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: `std::dynamic_pointer_cast<T>(p)`
|
||||
[horizontal]
|
||||
Returns:: `std::dynamic_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
dynamic_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
::
|
||||
Requires:::
|
||||
[horizontal]
|
||||
Requires::
|
||||
* The expression `static_cast<T*>((U*)0)` must be well-formed.
|
||||
* `T` must have a virtual destructor.
|
||||
Returns:::
|
||||
Returns::
|
||||
* When `dynamic_cast<typename std::unique_ptr<T>::element_type*>(p.get())`
|
||||
returns a non-zero value, `std::unique_ptr<T>(dynamic_cast<typename
|
||||
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;
|
||||
```
|
||||
::
|
||||
Returns::: `const_cast<T*>(p)`
|
||||
[horizontal]
|
||||
Returns:: `const_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
const_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: `std::const_pointer_cast<T>(p)`
|
||||
[horizontal]
|
||||
Returns:: `std::const_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
const_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
::
|
||||
Requires::: The expression `const_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns::: `std::unique_ptr<T>(const_cast<typename
|
||||
[horizontal]
|
||||
Requires:: The expression `const_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns:: `std::unique_ptr<T>(const_cast<typename
|
||||
std::unique_ptr<T>::element_type*>(p.release()))`.
|
||||
|
||||
### 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;
|
||||
```
|
||||
::
|
||||
Returns::: `reinterpret_cast<T*>(p)`
|
||||
[horizontal]
|
||||
Returns:: `reinterpret_cast<T*>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::shared_ptr<T>
|
||||
reinterpret_pointer_cast(const std::shared_ptr<U>& p) noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: `std::reinterpret_pointer_cast<T>(p)`
|
||||
[horizontal]
|
||||
Returns:: `std::reinterpret_pointer_cast<T>(p)`
|
||||
|
||||
```
|
||||
template<class T, class U> std::unique_ptr<T>
|
||||
reinterpret_pointer_cast(std::unique_ptr<U>&& p) noexcept;
|
||||
```
|
||||
::
|
||||
Requires::: The expression `reinterpret_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns::: `std::unique_ptr<T>(reinterpret_cast<typename
|
||||
[horizontal]
|
||||
Requires:: The expression `reinterpret_cast<T*>((U*)0)` must be well-formed.
|
||||
Returns:: `std::unique_ptr<T>(reinterpret_cast<typename
|
||||
std::unique_ptr<T>::element_type*>(p.release()))`.
|
||||
|
||||
## Example
|
||||
|
@@ -105,42 +105,42 @@ Type:: Provides the type of the stored pointer.
|
||||
```
|
||||
explicit shared_array(T* p = 0);
|
||||
```
|
||||
::
|
||||
Effects::: Constructs a `shared_array`, storing a copy of `p`, which must be a
|
||||
[horizontal]
|
||||
Effects:: Constructs a `shared_array`, storing a copy of `p`, which must be a
|
||||
pointer to an array that was allocated via a C++ `new[]` expression or be 0.
|
||||
Afterwards, the use count is 1 (even if `p == 0`; see `~shared_array`).
|
||||
Requires::: `T` is a complete type.
|
||||
Throws::: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
|
||||
Requires:: `T` is a complete type.
|
||||
Throws:: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
|
||||
|
||||
```
|
||||
template<class D> shared_array(T* p, D d);
|
||||
```
|
||||
::
|
||||
Effects::: Constructs a `shared_array`, storing a copy of `p` and of `d`.
|
||||
[horizontal]
|
||||
Effects:: Constructs a `shared_array`, storing a copy of `p` and of `d`.
|
||||
Afterwards, the use count is 1. When the the time comes to delete the array
|
||||
pointed to by `p`, the object `d` is used in the statement `d(p)`.
|
||||
Requires:::
|
||||
Requires[horizontal]
|
||||
* `T` is a complete type.
|
||||
* The copy constructor and destructor of `D` must not throw.
|
||||
* Invoking the object `d` with parameter `p` must not throw.
|
||||
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;
|
||||
```
|
||||
::
|
||||
Effects::: Constructs a `shared_array`, as if by storing a copy of the pointer
|
||||
[horizontal]
|
||||
Effects:: Constructs a `shared_array`, as if by storing a copy of the pointer
|
||||
stored in `v`. Afterwards, the use count for all copies is 1 more than the
|
||||
initial use count.
|
||||
Requires::: `T` is a complete type.
|
||||
Requires:: `T` is a complete type.
|
||||
|
||||
### Destructor
|
||||
|
||||
```
|
||||
~shared_array() noexcept;
|
||||
```
|
||||
::
|
||||
Effects::: Decrements the use count. Then, if the use count is 0, deletes the
|
||||
[horizontal]
|
||||
Effects:: Decrements the use count. Then, if the use count is 0, deletes the
|
||||
array pointed to by the stored pointer. Note that `delete[]` on a pointer with
|
||||
a value of 0 is harmless.
|
||||
|
||||
@@ -149,60 +149,60 @@ a value of 0 is harmless.
|
||||
```
|
||||
shared_array& operator=(const shared_array& v) noexcept;
|
||||
```
|
||||
::
|
||||
Effects::: Constructs a new `shared_array` as described above, then replaces
|
||||
[horizontal]
|
||||
Effects:: Constructs a new `shared_array` as described above, then replaces
|
||||
this `shared_array` with the new one, destroying the replaced object.
|
||||
Requires::: `T` is a complete type.
|
||||
Returns::: `*this`.
|
||||
Requires:: `T` is a complete type.
|
||||
Returns:: `*this`.
|
||||
|
||||
### reset
|
||||
|
||||
```
|
||||
void reset(T* p = 0);
|
||||
```
|
||||
::
|
||||
Effects::: Constructs a new `shared_array` as described above, then replaces
|
||||
[horizontal]
|
||||
Effects:: Constructs a new `shared_array` as described above, then replaces
|
||||
this `shared_array` with the new one, destroying the replaced object.
|
||||
Requires::: `T` is a complete type.
|
||||
Throws::: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
|
||||
Requires:: `T` is a complete type.
|
||||
Throws:: `std::bad_alloc`. If an exception is thrown, `delete[] p` is called.
|
||||
|
||||
```
|
||||
template<class D> void reset(T* p, D d);
|
||||
```
|
||||
::
|
||||
Effects::: Constructs a new `shared_array` as described above, then replaces
|
||||
[horizontal]
|
||||
Effects:: Constructs a new `shared_array` as described above, then replaces
|
||||
this `shared_array` with the new one, destroying the replaced object.
|
||||
Requires:::
|
||||
Requires[horizontal]
|
||||
* `T` is a complete type.
|
||||
* The copy constructor of `D` must not throw.
|
||||
Throws::: `std::bad_alloc`. If an exception is thrown, `d(p)` is called.
|
||||
Throws:: `std::bad_alloc`. If an exception is thrown, `d(p)` is called.
|
||||
|
||||
### Indexing
|
||||
|
||||
```
|
||||
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 is 0, or if `n` is less than 0 or is greater than or equal to the
|
||||
number of elements in the array.
|
||||
Requires::: `T` is a complete type.
|
||||
Requires:: `T` is a complete type.
|
||||
|
||||
### get
|
||||
|
||||
```
|
||||
T* get() const noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: The stored pointer.
|
||||
[horizontal]
|
||||
Returns:: The stored pointer.
|
||||
|
||||
### unique
|
||||
|
||||
```
|
||||
bool unique() const noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: `true` if no other `shared_array` is sharing ownership of the
|
||||
[horizontal]
|
||||
Returns:: `true` if no other `shared_array` is sharing ownership of the
|
||||
stored pointer, `false` otherwise.
|
||||
|
||||
### use_count
|
||||
@@ -210,8 +210,8 @@ stored pointer, `false` otherwise.
|
||||
```
|
||||
long use_count() const noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: The number of `shared_array` objects sharing ownership of the
|
||||
[horizontal]
|
||||
Returns:: The number of `shared_array` objects sharing ownership of the
|
||||
stored pointer.
|
||||
|
||||
### Conversions
|
||||
@@ -219,17 +219,17 @@ stored pointer.
|
||||
```
|
||||
explicit operator bool() const noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: `get() != 0`.
|
||||
Requires::: `T` is a complete type.
|
||||
[horizontal]
|
||||
Returns:: `get() != 0`.
|
||||
Requires:: `T` is a complete type.
|
||||
|
||||
### swap
|
||||
|
||||
```
|
||||
void swap(shared_array<T>& b) noexcept;
|
||||
```
|
||||
::
|
||||
Effects::: Exchanges the contents of the two smart pointers.
|
||||
[horizontal]
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
## Free Functions
|
||||
|
||||
@@ -247,8 +247,8 @@ template<class T> bool
|
||||
template<class T> bool
|
||||
operator<(const shared_array<T>& a, const shared_array<T>& b) noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: The result of comparing the stored pointers of the two smart
|
||||
[horizontal]
|
||||
Returns:: The result of comparing the stored pointers of the two smart
|
||||
pointers.
|
||||
|
||||
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>
|
||||
void swap(shared_array<T>& a, shared_array<T>& b) noexcept;
|
||||
```
|
||||
::
|
||||
Returns::: `a.swap(b)`.
|
||||
Requires::: `T` is a complete type.
|
||||
[horizontal]
|
||||
Returns:: `a.swap(b)`.
|
||||
Requires:: `T` is a complete type.
|
||||
|
@@ -263,9 +263,7 @@ constexpr shared_ptr() noexcept;
|
||||
```
|
||||
constexpr shared_ptr(std::nullptr_t) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs an empty `shared_ptr`.
|
||||
Postconditions:: `use_count() == 0 && get() == 0`.
|
||||
|
||||
@@ -273,9 +271,7 @@ Postconditions:: `use_count() == 0 && get() == 0`.
|
||||
```
|
||||
template<class Y> explicit shared_ptr(Y * p);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `Y` must be a complete type. The expression `delete[] p`, when `T` is an array type, or `delete p`, when `T` is not an array type,
|
||||
must be well-formed, well-defined, and not throw exceptions. When `T` is `U[N]`, `Y(\*)[N]` must be convertible to `T*`; when `T` is `U[]`, `Y(\*)[]`
|
||||
must be convertible to `T*`; otherwise, `Y\*` must be convertible to `T*`.
|
||||
@@ -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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `D` must be `CopyConstructible`. The copy constructor and destructor of `D` must not throw. The expression `d(p)` must be well-formed, well-defined,
|
||||
and not throw exceptions. `A` must be an `Allocator`, as described in section Allocator Requirements [allocator.requirements] of the {cpp} Standard.
|
||||
When `T` is `U[N]`, `Y(\*)[N]` must be convertible to `T*`; when `T` is `U[]`, `Y(\*)[]` must be convertible to `T*`; otherwise, `Y\*` must be convertible to `T*`.
|
||||
@@ -341,9 +335,7 @@ shared_ptr(shared_ptr const & r) noexcept;
|
||||
```
|
||||
template<class Y> shared_ptr(shared_ptr<Y> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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`.
|
||||
@@ -357,9 +349,7 @@ shared_ptr(shared_ptr && r) noexcept;
|
||||
```
|
||||
template<class Y> shared_ptr(shared_ptr<Y> && r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: constructs a `shared_ptr` that shares ownership with `r` and stores `p`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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`.
|
||||
@@ -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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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`.
|
||||
@@ -412,9 +396,7 @@ template<class Y> shared_ptr(std::auto_ptr<Y> & r);
|
||||
```
|
||||
template<class Y> shared_ptr(std::auto_ptr<Y> && r);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `Y*` should be convertible to `T*`.
|
||||
|
||||
Effects::
|
||||
@@ -448,9 +428,7 @@ Exception safety:: If an exception is thrown, the constructor has no effect.
|
||||
```
|
||||
~shared_ptr() noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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.
|
||||
@@ -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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr(r).swap(*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);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr(std::move(r)).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
```
|
||||
shared_ptr & operator=(std::nullptr_t) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr().swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
@@ -518,76 +490,58 @@ Returns:: `*this`.
|
||||
```
|
||||
void reset() noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr().swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(Y * p);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr(p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y, class D> void reset(Y * p, D d);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr(p, d).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y, class D, class A> void reset(Y * p, D d, A a);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr(p, d, a).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(shared_ptr<Y> const & r, element_type * p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr(r, p).swap(*this)`.
|
||||
|
||||
```
|
||||
template<class Y> void reset(shared_ptr<Y> && r, element_type * p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `shared_ptr(std::move(r), p).swap(*this)`.
|
||||
|
||||
### indirection
|
||||
```
|
||||
T & operator*() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `T` should not be an array type. The stored pointer must not be 0.
|
||||
Returns:: `*get()`.
|
||||
|
||||
```
|
||||
T * operator->() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: `T` should not be an array type. The stored pointer must not be 0.
|
||||
Returns:: `get()`.
|
||||
|
||||
```
|
||||
element_type & operator[](std::ptrdiff_t i) const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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]`.
|
||||
|
||||
@@ -596,36 +550,28 @@ Returns:: `get()[i]`.
|
||||
```
|
||||
element_type * get() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: The stored pointer.
|
||||
|
||||
### unique
|
||||
```
|
||||
bool unique() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `use_count() == 1`.
|
||||
|
||||
### use_count
|
||||
```
|
||||
long use_count() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: The number of `shared_ptr` objects, `*this` included, that share ownership with `*this`, or 0 when `*this` is empty.
|
||||
|
||||
### conversions
|
||||
```
|
||||
explicit operator bool() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `get() != 0`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Exchanges the contents of the two smart pointers.
|
||||
|
||||
### 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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: See the description of `operator<`.
|
||||
|
||||
## Free Functions
|
||||
@@ -663,18 +605,14 @@ Effects:: See the description of `operator<`.
|
||||
template<class T, class U>
|
||||
bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `a.get() == b.get()`.
|
||||
|
||||
```
|
||||
template<class T, class U>
|
||||
bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `p.get() != 0`.
|
||||
|
||||
```
|
||||
template<class T, class U>
|
||||
bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: An unspecified value such that
|
||||
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
|
||||
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `shared_ptr` instances
|
||||
@@ -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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
### get_pointer
|
||||
@@ -730,9 +660,7 @@ template<class T>
|
||||
typename shared_ptr<T>::element_type *
|
||||
get_pointer(shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `p.get()`.
|
||||
|
||||
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>
|
||||
shared_ptr<T> static_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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()) )`.
|
||||
|
||||
@@ -756,9 +682,7 @@ result in undefined behavior, attempting to delete the same object twice.
|
||||
template<class T, class U>
|
||||
shared_ptr<T> const_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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()) )`.
|
||||
|
||||
@@ -767,9 +691,7 @@ Returns:: `shared_ptr<T>( r, const_cast<typename shared_ptr<T>::element_type*>(r
|
||||
template<class T, class U>
|
||||
shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Requires:: The expression `dynamic_cast<T*>( (U*)0 )` must be well-formed.
|
||||
Returns::
|
||||
- When `dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())` returns a nonzero value `p`, `shared_ptr<T>(r, p)`;
|
||||
@@ -780,9 +702,7 @@ Returns::
|
||||
template<class T, class U>
|
||||
shared_ptr<T> reinterpret_pointer_cast(shared_ptr<U> const & r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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()) )`.
|
||||
|
||||
@@ -792,9 +712,7 @@ template<class E, class T, class Y>
|
||||
std::basic_ostream<E, T> &
|
||||
operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p);
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `os << p.get();`.
|
||||
Returns:: `os`.
|
||||
|
||||
@@ -803,9 +721,7 @@ Returns:: `os`.
|
||||
template<class D, class T>
|
||||
D * get_deleter(shared_ptr<T> const & p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: If `*this` owns a deleter `d` of type (cv-unqualified) `D`, returns `&d`; otherwise returns 0.
|
||||
|
||||
### 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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `false`.
|
||||
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `*p`.
|
||||
|
||||
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>
|
||||
void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, int ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `p\->swap(r)`.
|
||||
|
||||
```
|
||||
@@ -860,9 +770,7 @@ template<class T>
|
||||
shared_ptr<T> atomic_exchange_explicit(
|
||||
shared_ptr<T> * p, shared_ptr<T> r, int ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: `p\->swap(r)`.
|
||||
Returns:: The old value of `*p`.
|
||||
|
||||
@@ -876,9 +784,7 @@ template<class T>
|
||||
bool atomic_compare_exchange_explicit(
|
||||
shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, int, int ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: If `*p` is equivalent to `*v`, assigns `w` to `*p`, otherwise assigns `*p` to `*v`.
|
||||
Returns:: `true` if `*p` was equivalent to `*v`, `false` otherwise.
|
||||
Remarks:: Two `shared_ptr` instances are equivalent if they store the same pointer value and _share ownership_.
|
||||
|
@@ -127,9 +127,7 @@ typedef ... element_type;
|
||||
```
|
||||
weak_ptr() noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs an empty `weak_ptr`.
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: If `r` is empty, constructs an empty `weak_ptr`; otherwise, constructs a `weak_ptr` that shares ownership with `r` as if by storing a copy of the pointer stored in `r`.
|
||||
Postconditions:: `use_count() == r.use_count()`.
|
||||
|
||||
```
|
||||
weak_ptr(weak_ptr && r) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Constructs a `weak_ptr` that has the value `r` held.
|
||||
Postconditions:: `r` is empty.
|
||||
|
||||
@@ -161,9 +155,7 @@ Postconditions:: `r` is empty.
|
||||
```
|
||||
~weak_ptr() noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Destroys this `weak_ptr` but has no effect on the object its stored pointer points to.
|
||||
|
||||
### 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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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.
|
||||
@@ -190,45 +180,35 @@ NOTE: The implementation is free to meet the effects (and the implied guarantees
|
||||
```
|
||||
long use_count() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: 0 if `*this` is empty; otherwise, the number of `shared_ptr` objects that share ownership with `*this`.
|
||||
|
||||
### expired
|
||||
```
|
||||
bool expired() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `use_count() == 0`.
|
||||
|
||||
### lock
|
||||
```
|
||||
shared_ptr<T> lock() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: `expired()? shared_ptr<T>(): shared_ptr<T>(*this)`.
|
||||
|
||||
### reset
|
||||
```
|
||||
void reset() noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `weak_ptr().swap(*this)`.
|
||||
|
||||
### swap
|
||||
```
|
||||
void swap(weak_ptr & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: See the description of `operator<`.
|
||||
|
||||
## Free Functions
|
||||
@@ -249,9 +227,7 @@ Returns:: See the description of `operator<`.
|
||||
template<class T, class U>
|
||||
bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Returns:: An unspecified value such that
|
||||
- `operator<` is a strict weak ordering as described in section [lib.alg.sorting] of the {cpp} standard;
|
||||
- under the equivalence relation defined by `operator<`, `!(a < b) && !(b < a)`, two `weak_ptr` instances
|
||||
@@ -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;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
[horizontal]
|
||||
Effects:: Equivalent to `a.swap(b)`.
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
Reference in New Issue
Block a user