]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/apply_wrap.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / apply_wrap.rst
CommitLineData
7c673cae
FG
1.. Metafunctions/Invocation//apply_wrap |20
2
3apply_wrap
4==========
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename F
13 >
14 struct apply_wrap0
15 {
16 typedef |unspecified| type;
17 };
18
19 template<
20 typename F, typename A1
21 >
22 struct apply_wrap1
23 {
24 typedef |unspecified| type;
25 };
26
27 |...|
28
29 template<
30 typename F, typename A1,\ |...| typename An
31 >
32 struct apply_wrap\ *n*
33 {
34 typedef |unspecified| type;
35 };
36
37
38
39Description
40-----------
41
42Invokes a |Metafunction Class| ``F`` with arguments ``A1``,... ``An``.
43
44In essence, ``apply_wrap`` forms are nothing more than syntactic wrappers around
45``F::apply<A1,... An>::type`` / ``F::apply::type`` expressions (hence the name).
46They provide a more concise notation and higher portability than their
47underlaying constructs at the cost of an extra template instantiation.
48
49
50Header
51------
52
53.. parsed-literal::
54
55 #include <boost/mpl/apply_wrap.hpp>
56
57
58Parameters
59----------
60
61+---------------+-----------------------------------+-----------------------------------------------+
62| Parameter | Requirement | Description |
63+===============+===================================+===============================================+
64| ``F`` | |Metafunction Class| | A metafunction class to invoke. |
65+---------------+-----------------------------------+-----------------------------------------------+
66| |A1...An| | Any type | Invocation arguments. |
67+---------------+-----------------------------------+-----------------------------------------------+
68
69
70Expression semantics
71--------------------
72
73For any |Metafunction Class| ``f`` and arbitrary types |a1...an|:
74
75
76.. parsed-literal::
77
78 typedef apply_wrap\ *n*\ <f,a1,\ |...|\ an>::type t;
79
80:Return type:
81 Any type.
82
83:Semantics:
84 If ``n > 0``, equivalent to ``typedef f::apply<a1,... an>::type t;``,
85 otherwise equivalent to either ``typedef f::apply::type t;`` or
86 ``typedef f::apply<>::type t;`` depending on whether ``f::apply`` is
87 a class or a class template.
88
89
90Example
91-------
92
93.. parsed-literal::
94
95 struct f0
96 {
97 template< typename T = int > struct apply
98 {
99 typedef char type;
100 };
101 };
102
103 struct g0
104 {
105 struct apply { typedef char type; };
106 };
107
108 struct f2
109 {
110 template< typename T1, typename T2 > struct apply
111 {
112 typedef T2 type;
113 };
114 };
115
116
117 typedef apply_wrap\ ``0``\ < f0 >::type r1;
118 typedef apply_wrap\ ``0``\ < g0 >::type r2;
119 typedef apply_wrap\ ``2``\ < f2,int,char >::type r3;
120
121 BOOST_MPL_ASSERT(( is_same<r1,char> ));
122 BOOST_MPL_ASSERT(( is_same<r2,char> ));
123 BOOST_MPL_ASSERT(( is_same<r3,char> ));
124
125
126See also
127--------
128
129|Metafunctions|, |Invocation|, |apply|, |lambda|, |quote|, |bind|, |protect|
130
131
132