]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/doc/src/refmanual/inherit_linearly.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / inherit_linearly.rst
1 .. Metafunctions/Miscellaneous//inherit_linearly |40
2
3 inherit_linearly
4 ================
5
6 Synopsis
7 --------
8
9 .. parsed-literal::
10
11 template<
12 typename Types
13 , typename Node
14 , typename Root = empty_base
15 >
16 struct inherit_linearly
17 : fold<Types,Root,Node>
18 {
19 };
20
21
22 Description
23 -----------
24
25 A convenience wrapper for ``fold`` to use in the context of sequence-driven
26 class composition. Returns the result the successive application of binary
27 ``Node`` to the result of the previous ``Node`` invocation (``Root`` if it's
28 the first call) and every type in the |Forward Sequence| ``Types`` in order.
29
30
31 Header
32 ------
33
34 .. parsed-literal::
35
36 #include <boost/mpl/inherit_linearly.hpp>
37
38
39 Model of
40 --------
41
42 |Metafunction|
43
44
45 Parameters
46 ----------
47
48 +---------------+-------------------------------+---------------------------------------------------+
49 | Parameter | Requirement | Description |
50 +===============+===============================+===================================================+
51 | ``Types`` | |Forward Sequence| | Types to inherit from. |
52 +---------------+-------------------------------+---------------------------------------------------+
53 | ``Node`` | Binary |Lambda Expression| | A derivation metafunction. |
54 +---------------+-------------------------------+---------------------------------------------------+
55 | ``Root`` | A class type | A type to be placed at the root of the class |
56 | | | hierarchy. |
57 +---------------+-------------------------------+---------------------------------------------------+
58
59
60 Expression semantics
61 --------------------
62
63 For any |Forward Sequence| ``types``, binary |Lambda Expression| ``node``, and arbitrary
64 class type ``root``:
65
66
67 .. parsed-literal::
68
69 typedef inherit_linearly<types,node,root>::type r;
70
71 :Return type:
72 A class type.
73
74 :Semantics:
75 Equivalent to
76
77 .. parsed-literal::
78
79 typedef fold<types,root,node>::type r;
80
81
82
83 Complexity
84 ----------
85
86 Linear. Exactly ``size<types>::value`` applications of ``node``.
87
88
89 Example
90 -------
91
92 .. parsed-literal::
93
94 template< typename T > struct tuple_field
95 {
96 T field;
97 };
98
99 template< typename T >
100 inline
101 T& field(tuple_field<T>& t)
102 {
103 return t.field;
104 }
105
106 typedef inherit_linearly<
107 vector<int,char const*,bool>
108 , inherit< _1, tuple_field<_2> >
109 >::type tuple;
110
111
112 int main()
113 {
114 tuple t;
115
116 field<int>(t) = -1;
117 field<char const*>(t) = "text";
118 field<bool>(t) = false;
119
120 std::cout
121 << field<int>(t) << '\n'
122 << field<char const*>(t) << '\n'
123 << field<bool>(t) << '\n'
124 ;
125 }
126
127
128 See also
129 --------
130
131 |Metafunctions|, |Algorithms|, |inherit|, |empty_base|, |fold|, |reverse_fold|
132
133
134 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
135 Distributed under the Boost Software License, Version 1.0. (See accompanying
136 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)