1 <?xml version=
"1.0" encoding=
"utf-8" ?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
6 <meta name=
"generator" content=
"Docutils 0.7: http://docutils.sourceforge.net/" />
7 <title>The MPL Reference Manual: inherit
</title>
8 <link rel=
"stylesheet" href=
"../style.css" type=
"text/css" />
10 <body class=
"docframe refmanual">
11 <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>
12 <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>
13 </tr></table><div class=
"header-separator"></div>
14 <div class=
"section" id=
"inherit">
15 <h1><a class=
"toc-backref" href=
"./miscellaneous.html#id1566">inherit
</a></h1>
16 <div class=
"section" id=
"id1163">
17 <h3><a class=
"subsection-title" href=
"#synopsis" name=
"synopsis">Synopsis
</a></h3>
18 <pre class=
"literal-block">
20 typename T1, typename T2
22 struct
<a href=
"./inherit.html" class=
"identifier">inherit
</a><tt class=
"literal"><span class=
"pre">2</span></tt>
24 typedef
<em>unspecified
</em> type;
30 typename T1, typename T2,
<em>...
</em> typename T
<em>n
</em>
32 struct
<a href=
"./inherit.html" class=
"identifier">inherit
</a><em>n
</em>
34 typedef
<em>unspecified
</em> type;
41 , typename T
<em>n
</em> =
<em>unspecified
</em>
43 struct
<a href=
"./inherit.html" class=
"identifier">inherit
</a>
45 typedef
<em>unspecified
</em> type;
49 <div class=
"section" id=
"id1164">
50 <h3><a class=
"subsection-title" href=
"#description" name=
"description">Description
</a></h3>
51 <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>.
52 Guarantees that derivation from
<a class=
"reference internal" href=
"./empty-base.html">empty_base
</a> is always a no-op,
53 regardless of the position and number of
<a class=
"reference internal" href=
"./empty-base.html">empty_base
</a> classes in
54 <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>
56 <div class=
"section" id=
"id1165">
57 <h3><a class=
"subsection-title" href=
"#header" name=
"header">Header
</a></h3>
58 <pre class=
"literal-block">
59 #include
<<a href=
"../../../../boost/mpl/inherit.hpp" class=
"header">boost/mpl/inherit.hpp
</a>>
62 <div class=
"section" id=
"id1166">
63 <h3><a class=
"subsection-title" href=
"#model-of" name=
"model-of">Model of
</a></h3>
64 <p><a class=
"reference internal" href=
"./metafunction.html">Metafunction
</a></p>
66 <div class=
"section" id=
"id1167">
67 <h3><a class=
"subsection-title" href=
"#parameters" name=
"parameters">Parameters
</a></h3>
68 <table border=
"1" class=
"docutils table">
74 <thead valign=
"bottom">
75 <tr><th class=
"head">Parameter
</th>
76 <th class=
"head">Requirement
</th>
77 <th class=
"head">Description
</th>
81 <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>
83 <td>Classes to derived from.
</td>
88 <div class=
"section" id=
"id1168">
89 <h3><a class=
"subsection-title" href=
"#expression-semantics" name=
"expression-semantics">Expression semantics
</a></h3>
90 <p>For artibrary class types
<em>t
</em><sub>1</sub>,
<em>t
</em><sub>2</sub>,...
<em>t
</em><sub>n
</sub>:
</p>
91 <pre class=
"literal-block">
92 typedef inherit2
<t1,t2
>::type r;
94 <table class=
"docutils field-list" frame=
"void" rules=
"none">
95 <col class=
"field-name" />
96 <col class=
"field-body" />
98 <tr class=
"field"><th class=
"field-name">Return type:
</th><td class=
"field-body"><p class=
"first">A class type.
</p>
101 <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>
104 <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>
105 <pre class=
"literal-block">
106 typedef
<a href=
"./empty-base.html" class=
"identifier">empty_base
</a> r;
108 <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>
109 <pre class=
"literal-block">
112 <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>
113 <pre class=
"literal-block">
116 <p>otherwise equivalent to
</p>
117 <pre class=
"last literal-block">
118 struct r : t1, t2 {};
124 <!-- ........................................................................... -->
125 <pre class=
"literal-block">
126 typedef
<a href=
"./inherit.html" class=
"identifier">inherit
</a><em>n
</em><t1,t2,
<em>...
</em>t
<em>n
</em>>::type r;
128 <table class=
"docutils field-list" frame=
"void" rules=
"none">
129 <col class=
"field-name" />
130 <col class=
"field-body" />
132 <tr class=
"field"><th class=
"field-name">Return type:
</th><td class=
"field-body"><p class=
"first">A class type.
</p>
135 <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>
138 <tr class=
"field"><th class=
"field-name">Semantics:
</th><td class=
"field-body"><p class=
"first">Equivalent to
</p>
139 <pre class=
"last literal-block">
141 :
<a href=
"./inherit.html" class=
"identifier">inherit
</a><tt class=
"literal"><span class=
"pre">2</span></tt><
142 <a href=
"./inherit.html" class=
"identifier">inherit
</a><em>n-
1</em><t1,t2,
<em>...
</em>t
<em>n-
1</em>>::type
152 <!-- ........................................................................... -->
153 <pre class=
"literal-block">
154 typedef
<a href=
"./inherit.html" class=
"identifier">inherit
</a><t1,t2,
<em>...
</em>t
<em>n
</em>>::type r;
156 <table class=
"docutils field-list" frame=
"void" rules=
"none">
157 <col class=
"field-name" />
158 <col class=
"field-body" />
160 <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>
163 <tr class=
"field"><th class=
"field-name">Return type:
</th><td class=
"field-body"><p class=
"first">A class type.
</p>
166 <tr class=
"field"><th class=
"field-name">Semantics:
</th><td class=
"field-body"><p class=
"first">Equivalent to
</p>
167 <pre class=
"last literal-block">
168 typedef
<a href=
"./inherit.html" class=
"identifier">inherit
</a><em>n
</em><t1,t2,
<em>...
</em>t
<em>n
</em>>::type r;
175 <div class=
"section" id=
"id1169">
176 <h3><a class=
"subsection-title" href=
"#complexity" name=
"complexity">Complexity
</a></h3>
177 <p>Amortized constant time.
</p>
179 <div class=
"section" id=
"id1170">
180 <h3><a class=
"subsection-title" href=
"#example" name=
"example">Example
</a></h3>
181 <pre class=
"literal-block">
182 struct udt1 { int n; };
185 typedef
<a href=
"./inherit.html" class=
"identifier">inherit
</a><udt1,udt2
>::type r1;
186 typedef
<a href=
"./inherit.html" class=
"identifier">inherit
</a><<a href=
"./empty-base.html" class=
"identifier">empty_base
</a>,udt1
>::type r2;
187 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;
188 typedef
<a href=
"./inherit.html" class=
"identifier">inherit
</a><udt1,
<a href=
"./empty-base.html" class=
"identifier">empty_base
</a>,udt2
>::type r4;
189 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;
191 <a href=
"./assert.html" class=
"identifier">BOOST_MPL_ASSERT
</a>(( is_base_and_derived
< udt1, r1
> ));
192 <a href=
"./assert.html" class=
"identifier">BOOST_MPL_ASSERT
</a>(( is_base_and_derived
< udt2, r1
> ));
193 <a href=
"./assert.html" class=
"identifier">BOOST_MPL_ASSERT
</a>(( is_same
< r2, udt1
> ));
194 <a href=
"./assert.html" class=
"identifier">BOOST_MPL_ASSERT
</a>(( is_same
< r3, udt1
> ));
195 <a href=
"./assert.html" class=
"identifier">BOOST_MPL_ASSERT
</a>(( is_base_and_derived
< udt1, r4
> ));
196 <a href=
"./assert.html" class=
"identifier">BOOST_MPL_ASSERT
</a>(( is_base_and_derived
< udt2, r4
> ));
197 <a href=
"./assert.html" class=
"identifier">BOOST_MPL_ASSERT
</a>(( is_same
< r5,
<a href=
"./empty-base.html" class=
"identifier">empty_base
</a> > ));
200 <div class=
"section" id=
"id1171">
201 <h3><a class=
"subsection-title" href=
"#see-also" name=
"see-also">See also
</a></h3>
202 <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>
203 <!-- Metafunctions/Miscellaneous//inherit_linearly |40 -->
207 <div class=
"footer-separator"></div>
208 <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>
209 <td><div class=
"copyright-footer"><div class=
"copyright">Copyright ©
2001-
2009 Aleksey Gurtovoy and David Abrahams
</div>
210 Distributed under the Boost Software License, Version
1.0. (See accompanying
211 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>