forked from boostorg/smart_ptr
New casts for smart pointers.
[SVN r12743]
This commit is contained in:
+22
-2
@@ -71,6 +71,10 @@ pointed to. <b>T</b> must meet the smart pointer
|
||||
weak_ptr<T> <a href="#shared_static_cast">shared_static_cast</a>(weak_ptr<U> const & r); // never throws
|
||||
template<typename T, typename U>
|
||||
weak_ptr<T> <a href="#shared_dynamic_cast">shared_dynamic_cast</a>(weak_ptr<U> const & r);
|
||||
template<typename T, typename U>
|
||||
weak_ptr<T> <a href="#shared_polymorphic_cast">shared_polymorphic_cast</a>(weak_ptr<U> const & r);
|
||||
template<typename T, typename U>
|
||||
weak_ptr<T> <a href="#shared_polymorphic_downcast">shared_polymorphic_downcast</a>(weak_ptr<U> const & r); // never throws
|
||||
|
||||
}</pre>
|
||||
|
||||
@@ -192,19 +196,35 @@ Provided as an aid to generic programming.</p>
|
||||
|
||||
<h3><a name="shared_static_cast">shared_static_cast</a></h3>
|
||||
<pre>template<typename T, typename U>
|
||||
weak_ptr<T> <a href="#shared_static_cast">shared_static_cast</a>(weak_ptr<U> const & r); // never throws</pre>
|
||||
weak_ptr<T> shared_static_cast(weak_ptr<U> const & r); // never throws</pre>
|
||||
<p>Perform a <b>static_cast</b> on the stored pointer, returning another <b>weak_ptr</b>.
|
||||
The resulting smart pointer will share its use count with the original pointer.</p>
|
||||
|
||||
<h3><a name="shared_dynamic_cast">shared_dynamic_cast</a></h3>
|
||||
<pre>template<typename T, typename U>
|
||||
weak_ptr<T> <a href="#shared_dynamic_cast">shared_dynamic_cast</a>(weak_ptr<U> const & r);</pre>
|
||||
weak_ptr<T> shared_dynamic_cast(weak_ptr<U> const & r);</pre>
|
||||
<p>Perform a <b>dynamic_cast</b> on the stored pointer, returning another <b>weak_ptr</b>.
|
||||
The resulting smart pointer will share its use count with the original pointer unless the result of the
|
||||
cast is 0. The only exception which may be thrown is <b>std::bad_alloc</b>, which may be thrown during the
|
||||
construction of the new <b>weak_ptr</b> if the result of the cast is 0. If an exception is thrown, the
|
||||
cast has no effect.</p>
|
||||
|
||||
<h3><a name="shared_polymorphic_cast">shared_polymorphic_cast</a></h3>
|
||||
<pre>template<typename T, typename U>
|
||||
weak_ptr<T> shared_polymorphic_cast(weak_ptr<U> const & r);</pre>
|
||||
<p>Perform a <a href="../conversion/cast.htm#Polymorphic_cast"><b>polymorphic_cast</b><a> on the stored pointer,
|
||||
returning another <b>weak_ptr</b>.
|
||||
The resulting smart pointer will share its use count with the original pointer.
|
||||
The only exception which may be thrown is <b>std::bad_cast</b>, if the pointer type can not be converted.
|
||||
If an exception is thrown, the cast has no effect.</p>
|
||||
|
||||
<h3><a name="shared_polymorphic_downcast">shared_polymorphic_downcast</a></h3>
|
||||
<pre>template<typename T, typename U>
|
||||
weak_ptr<T> shared_polymorphic_downcast(weak_ptr<U> const & r); // never throws</pre>
|
||||
<p>Perform a <a href="../conversion/cast.htm#Polymorphic_cast"><b>polymorphic_downcast</b><a> on the stored pointer,
|
||||
returning another <b>weak_ptr</b>.
|
||||
The resulting smart pointer will share its use count with the original pointer.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>Revised <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B %Y" startspan -->1 February 2002<!--webbot bot="Timestamp" i-checksum="38439" endspan --></p>
|
||||
|
||||
Reference in New Issue
Block a user