]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/Placeholders.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / Placeholders.rst
CommitLineData
7c673cae
FG
1.. Metafunctions/Composition and Argument Binding//_1,_2,..._n |10
2
3Placeholders
4============
5.. _`placeholder`:
6
7
8Synopsis
9--------
10
11.. parsed-literal::
12
13 namespace placeholders {
14 typedef |unspecified| _;
15 typedef arg<1> _1;
16 typedef arg<2> _2;
17 |...|
18 typedef arg<\ *n*\ > _\ *n*\ ;
19 }
20
21 using placeholders::_;
22 using placeholders::_1;
23 using placeholders::_2;
24 |...|
25 using placeholders::_\ *n*\ ;
26
27
28Description
29-----------
30
31A placeholder in a form ``_``\ *n* is simply a synonym for the corresponding
32``arg<n>`` specialization. The unnamed placeholder ``_`` (underscore) carries
33`special meaning`__ in bind and lambda expressions, and does not have
34defined semantics outside of these contexts.
35
36Placeholder names can be made available in the user namespace through
37``using namespace mpl::placeholders;`` directive.
38
39__ `bind semantics`_
40
41Header
42------
43
44.. parsed-literal::
45
46 #include <boost/mpl/placeholders.hpp>
47
48|Note:| The include might be omitted when using placeholders to construct a |Lambda
49Expression| for passing it to MPL's own algorithm or metafunction: any library
50component that is documented to accept a lambda expression makes the placeholders
51implicitly available for the user code |-- end note|
52
53
54Parameters
55----------
56
57None.
58
59
60Expression semantics
61--------------------
62
63For any integral constant ``n`` in the range [1, |BOOST_MPL_LIMIT_METAFUNCTION_ARITY|\] and
64arbitrary types |a1...an|:
65
66
67.. parsed-literal::
68
69 typedef apply_wrap\ *n*\<_\ *n*\,a1,\ |...|\a\ *n*\ >::type x;
70
71:Return type:
72 A type.
73
74:Semantics:
75 Equivalent to
76
77 .. parsed-literal::
78
79 typedef apply_wrap\ *n*\< arg<\ *n*\ >,a1,\ |...|\a\ *n* >::type x;
80
81
82Example
83-------
84
85.. parsed-literal::
86
87 typedef apply_wrap\ ``5``\< _1,bool,char,short,int,long >::type t1;
88 typedef apply_wrap\ ``5``\< _3,bool,char,short,int,long >::type t3;
89
90 BOOST_MPL_ASSERT(( is_same< t1, bool > ));
91 BOOST_MPL_ASSERT(( is_same< t3, short > ));
92
93
94See also
95--------
96
97|Composition and Argument Binding|, |arg|, |lambda|, |bind|, |apply|, |apply_wrap|
98
99
100.. |placeholder| replace:: `placeholder`_
101
102.. |_1| replace:: `_1`_
103.. |_2| replace:: `_2`_
104.. |_3| replace:: `_3`_
105.. |_4| replace:: `_4`_
106.. |_5| replace:: `_5`_
107
108.. _`_1`: `Placeholders`_
109.. _`_2`: `Placeholders`_
110.. _`_3`: `Placeholders`_
111.. _`_4`: `Placeholders`_
112.. _`_5`: `Placeholders`_
113
114.. |_1,_2,..._n| replace:: |_1|, |_2|, |_3|,\ |...|
115
116
117