74 lines
6.6 KiB
HTML
74 lines
6.6 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|||
|
<html>
|
|||
|
<head>
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|||
|
<title>Synopsis</title>
|
|||
|
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
|
|||
|
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
|||
|
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
|
|||
|
<link rel="up" href="../conversion.html" title="Chapter 11. The Conversion Library 1.7">
|
|||
|
<link rel="prev" href="polymorphic_casts.html" title="Polymorphic casts">
|
|||
|
<link rel="next" href="history.html" title="History">
|
|||
|
</head>
|
|||
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|||
|
<table cellpadding="2" width="100%"><tr>
|
|||
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
|
|||
|
<td align="center"><a href="../../../index.html">Home</a></td>
|
|||
|
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
|
|||
|
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
|||
|
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
|||
|
<td align="center"><a href="../../../more/index.htm">More</a></td>
|
|||
|
</tr></table>
|
|||
|
<hr>
|
|||
|
<div class="spirit-nav">
|
|||
|
<a accesskey="p" href="polymorphic_casts.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../conversion.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="history.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
|
|||
|
</div>
|
|||
|
<div class="section">
|
|||
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|||
|
<a name="conversion.synopsis"></a><a class="link" href="synopsis.html" title="Synopsis">Synopsis</a>
|
|||
|
</h2></div></div></div>
|
|||
|
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
|
|||
|
|
|||
|
<span class="comment">// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )</span>
|
|||
|
<span class="comment">// Returns: dynamic_cast<Derived>(x)</span>
|
|||
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Derived</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span><span class="special">></span>
|
|||
|
<span class="keyword">inline</span> <span class="identifier">Derived</span> <span class="identifier">polymorphic_cast</span><span class="special">(</span><span class="identifier">Base</span><span class="special">*</span> <span class="identifier">x</span><span class="special">);</span>
|
|||
|
|
|||
|
<span class="comment">// Effects: assert( dynamic_cast<Derived>(x) == x );</span>
|
|||
|
<span class="comment">// Returns: static_cast<Derived>(x)</span>
|
|||
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Derived</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span><span class="special">></span>
|
|||
|
<span class="keyword">inline</span> <span class="identifier">Derived</span> <span class="identifier">polymorphic_downcast</span><span class="special">(</span><span class="identifier">Base</span><span class="special">*</span> <span class="identifier">x</span><span class="special">);</span>
|
|||
|
|
|||
|
<span class="comment">// Effects: assert( dynamic_cast<Derived>(&x) == &x );</span>
|
|||
|
<span class="comment">// Returns: static_cast<Derived>(x)</span>
|
|||
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Derived</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span><span class="special">></span>
|
|||
|
<span class="keyword">inline</span> <span class="identifier">Derived</span> <span class="identifier">polymorphic_downcast</span><span class="special">(</span><span class="identifier">Base</span><span class="special">&</span> <span class="identifier">x</span><span class="special">);</span>
|
|||
|
|
|||
|
<span class="comment">// Throws: std::bad_cast if ( dynamic_pointer_cast<Derived>(x) == 0 )</span>
|
|||
|
<span class="comment">// Returns: dynamic_pointer_cast<Derived>(x)</span>
|
|||
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Derived</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span><span class="special">></span>
|
|||
|
<span class="keyword">inline</span> <span class="keyword">auto</span> <span class="identifier">polymorphic_pointer_cast</span><span class="special">(</span><span class="identifier">Base</span> <span class="identifier">x</span><span class="special">);</span>
|
|||
|
|
|||
|
<span class="comment">// Effects: assert( dynamic_pointer_cast<Derived>(x) == x );</span>
|
|||
|
<span class="comment">// Returns: static_pointer_cast<Derived>(x)</span>
|
|||
|
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Derived</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span><span class="special">></span>
|
|||
|
<span class="keyword">inline</span> <span class="keyword">auto</span> <span class="identifier">polymorphic_pointer_downcast</span><span class="special">(</span><span class="identifier">Base</span> <span class="identifier">x</span><span class="special">);</span>
|
|||
|
|
|||
|
<span class="special">}</span>
|
|||
|
</pre>
|
|||
|
</div>
|
|||
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|||
|
<td align="left"></td>
|
|||
|
<td align="right"><div class="copyright-footer">Copyright © 2001 Beman Dawes<br>Copyright © 2014-2021 Antony Polukhin<p>
|
|||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|||
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
|||
|
</p>
|
|||
|
</div></td>
|
|||
|
</tr></table>
|
|||
|
<hr>
|
|||
|
<div class="spirit-nav">
|
|||
|
<a accesskey="p" href="polymorphic_casts.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../conversion.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="history.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|