6f63e9d0c6
[SVN r64705]
213 lines
12 KiB
HTML
213 lines
12 KiB
HTML
<?xml version="1.0" encoding="utf-8" ?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
|
|
<title>The MPL Reference Manual: inherit</title>
|
|
<link rel="stylesheet" href="../style.css" type="text/css" />
|
|
</head>
|
|
<body class="docframe refmanual">
|
|
<table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./always.html" class="navigation-link">Prev</a> <a href="./inherit-linearly.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./always.html" class="navigation-link">Back</a> <a href="./inherit-linearly.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./miscellaneous.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
|
|
<td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./metafunctions.html" class="navigation-link">Metafunctions</a> / <a href="./miscellaneous.html" class="navigation-link">Miscellaneous</a> / <a href="./inherit.html" class="navigation-link">inherit</a></td>
|
|
</tr></table><div class="header-separator"></div>
|
|
<div class="section" id="inherit">
|
|
<h1><a class="toc-backref" href="./miscellaneous.html#id1566">inherit</a></h1>
|
|
<div class="section" id="id1163">
|
|
<h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
|
|
<pre class="literal-block">
|
|
template<
|
|
typename T1, typename T2
|
|
>
|
|
struct <a href="./inherit.html" class="identifier">inherit</a><tt class="literal"><span class="pre">2</span></tt>
|
|
{
|
|
typedef <em>unspecified</em> type;
|
|
};
|
|
|
|
<em>...</em>
|
|
|
|
template<
|
|
typename T1, typename T2,<em>...</em> typename T<em>n</em>
|
|
>
|
|
struct <a href="./inherit.html" class="identifier">inherit</a><em>n</em>
|
|
{
|
|
typedef <em>unspecified</em> type;
|
|
};
|
|
|
|
template<
|
|
typename T1
|
|
, typename T2
|
|
<em>...</em>
|
|
, typename T<em>n</em> = <em>unspecified</em>
|
|
>
|
|
struct <a href="./inherit.html" class="identifier">inherit</a>
|
|
{
|
|
typedef <em>unspecified</em> type;
|
|
};
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="id1164">
|
|
<h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
|
|
<p>Returns an unspecified class type publically derived from <tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt>.
|
|
Guarantees that derivation from <a class="reference internal" href="./empty-base.html">empty_base</a> is always a no-op,
|
|
regardless of the position and number of <a class="reference internal" href="./empty-base.html">empty_base</a> classes in
|
|
<tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt>.</p>
|
|
</div>
|
|
<div class="section" id="id1165">
|
|
<h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
|
|
<pre class="literal-block">
|
|
#include <<a href="../../../../boost/mpl/inherit.hpp" class="header">boost/mpl/inherit.hpp</a>>
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="id1166">
|
|
<h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
|
|
<p><a class="reference internal" href="./metafunction.html">Metafunction</a></p>
|
|
</div>
|
|
<div class="section" id="id1167">
|
|
<h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
|
|
<table border="1" class="docutils table">
|
|
<colgroup>
|
|
<col width="22%" />
|
|
<col width="28%" />
|
|
<col width="51%" />
|
|
</colgroup>
|
|
<thead valign="bottom">
|
|
<tr><th class="head">Parameter</th>
|
|
<th class="head">Requirement</th>
|
|
<th class="head">Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody valign="top">
|
|
<tr><td><tt class="literal"><span class="pre">T1</span></tt>, <tt class="literal"><span class="pre">T2</span></tt>,... <tt class="literal"><span class="pre">Tn</span></tt></td>
|
|
<td>A class type</td>
|
|
<td>Classes to derived from.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="section" id="id1168">
|
|
<h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
|
|
<p>For artibrary class types <em>t</em><sub>1</sub>,<em>t</em><sub>2</sub>,... <em>t</em><sub>n</sub>:</p>
|
|
<pre class="literal-block">
|
|
typedef inherit2<t1,t2>::type r;
|
|
</pre>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">A class type.</p>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><p class="first"><tt class="literal"><span class="pre">t1</span></tt> and <tt class="literal"><span class="pre">t2</span></tt> are complete types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">If both <tt class="literal"><span class="pre">t1</span></tt> and <tt class="literal"><span class="pre">t2</span></tt> are identical to <tt class="literal"><span class="pre"><a href="./empty-base.html" class="identifier">empty_base</a></span></tt>, equivalent to</p>
|
|
<pre class="literal-block">
|
|
typedef <a href="./empty-base.html" class="identifier">empty_base</a> r;
|
|
</pre>
|
|
<p>otherwise, if <tt class="literal"><span class="pre">t1</span></tt> is identical to <tt class="literal"><span class="pre"><a href="./empty-base.html" class="identifier">empty_base</a></span></tt>, equivalent to</p>
|
|
<pre class="literal-block">
|
|
typedef t2 r;
|
|
</pre>
|
|
<p>otherwise, if <tt class="literal"><span class="pre">t2</span></tt> is identical to <tt class="literal"><span class="pre"><a href="./empty-base.html" class="identifier">empty_base</a></span></tt>, equivalent to</p>
|
|
<pre class="literal-block">
|
|
typedef t1 r;
|
|
</pre>
|
|
<p>otherwise equivalent to</p>
|
|
<pre class="last literal-block">
|
|
struct r : t1, t2 {};
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<!-- ........................................................................... -->
|
|
<pre class="literal-block">
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><em>n</em><t1,t2,<em>...</em>t<em>n</em>>::type r;
|
|
</pre>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">A class type.</p>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><p class="first"><em>t</em><sub>1</sub>,<em>t</em><sub>2</sub>,... <em>t</em><sub>n</sub> are complete types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
|
|
<pre class="last literal-block">
|
|
struct r
|
|
: <a href="./inherit.html" class="identifier">inherit</a><tt class="literal"><span class="pre">2</span></tt><
|
|
<a href="./inherit.html" class="identifier">inherit</a><em>n-1</em><t1,t2,<em>...</em>t<em>n-1</em>>::type
|
|
, t<em>n</em>
|
|
>
|
|
{
|
|
};
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<!-- ........................................................................... -->
|
|
<pre class="literal-block">
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><t1,t2,<em>...</em>t<em>n</em>>::type r;
|
|
</pre>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><p class="first"><em>t</em><sub>1</sub>,<em>t</em><sub>2</sub>,... <em>t</em><sub>n</sub> are complete types.</p>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Return type:</th><td class="field-body"><p class="first">A class type.</p>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><p class="first">Equivalent to</p>
|
|
<pre class="last literal-block">
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><em>n</em><t1,t2,<em>...</em>t<em>n</em>>::type r;
|
|
</pre>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="section" id="id1169">
|
|
<h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
|
|
<p>Amortized constant time.</p>
|
|
</div>
|
|
<div class="section" id="id1170">
|
|
<h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
|
|
<pre class="literal-block">
|
|
struct udt1 { int n; };
|
|
struct udt2 {};
|
|
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><udt1,udt2>::type r1;
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><<a href="./empty-base.html" class="identifier">empty_base</a>,udt1>::type r2;
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><<a href="./empty-base.html" class="identifier">empty_base</a>,udt1,<a href="./empty-base.html" class="identifier">empty_base</a>,<a href="./empty-base.html" class="identifier">empty_base</a>>::type r3;
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><udt1,<a href="./empty-base.html" class="identifier">empty_base</a>,udt2>::type r4;
|
|
typedef <a href="./inherit.html" class="identifier">inherit</a><<a href="./empty-base.html" class="identifier">empty_base</a>,<a href="./empty-base.html" class="identifier">empty_base</a>>::type r5;
|
|
|
|
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_base_and_derived< udt1, r1> ));
|
|
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_base_and_derived< udt2, r1> ));
|
|
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same< r2, udt1> ));
|
|
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same< r3, udt1 > ));
|
|
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_base_and_derived< udt1, r4 > ));
|
|
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_base_and_derived< udt2, r4 > ));
|
|
<a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same< r5, <a href="./empty-base.html" class="identifier">empty_base</a> > ));
|
|
</pre>
|
|
</div>
|
|
<div class="section" id="id1171">
|
|
<h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
|
|
<p><a class="reference internal" href="./metafunctions.html">Metafunctions</a>, <a class="reference internal" href="./empty-base.html">empty_base</a>, <a class="reference internal" href="./inherit-linearly.html">inherit_linearly</a>, <a class="reference internal" href="./identity.html">identity</a></p>
|
|
<!-- Metafunctions/Miscellaneous//inherit_linearly |40 -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer-separator"></div>
|
|
<table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./always.html" class="navigation-link">Prev</a> <a href="./inherit-linearly.html" class="navigation-link">Next</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./always.html" class="navigation-link">Back</a> <a href="./inherit-linearly.html" class="navigation-link">Along</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./miscellaneous.html" class="navigation-link">Up</a> <a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator"> | </span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
|
|
<td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
|
|
</html>
|