]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpl/doc/src/refmanual/Metafunction.rst
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / Metafunction.rst
1 .. Metafunctions/Concepts//Metafunction |10
2
3 Metafunction
4 ============
5
6 Description
7 -----------
8
9 .. _`nullary-metafunction`:
10
11 A *metafunction* is a class or a class template that represents a
12 function invocable at compile-time. An non-nullary metafunction is
13 invoked by instantiating the class template with particular
14 template parameters (metafunction arguments); the result of the
15 metafunction application is accessible through the instantiation's
16 nested ``type`` typedef. All metafunction's arguments must be types
17 (i.e. only *type template parameters* are allowed). A metafunction
18 can have a variable number of parameters. A *nullary metafunction* is
19 represented as a (template) class with a nested ``type`` typename
20 member.
21
22 .. |nullary metafunction| replace:: `nullary-metafunction`_
23
24
25 Expression requirements
26 -----------------------
27
28 |In the following table...| ``f`` is a |Metafunction|.
29
30 +-------------------------------+-----------------------+---------------------------+
31 | Expression | Type | Complexity |
32 +===============================+=======================+===========================+
33 | ``f::type`` | Any type | Unspecified. |
34 +-------------------------------+-----------------------+---------------------------+
35 | ``f<>::type`` | Any type | Unspecified. |
36 +-------------------------------+-----------------------+---------------------------+
37 | ``f<a1,..,an>::type`` | Any type | Unspecified. |
38 +-------------------------------+-----------------------+---------------------------+
39
40
41 Expression semantics
42 --------------------
43
44 .. parsed-literal::
45
46 typedef f::type x;
47
48 :Precondition:
49 ``f`` is a nullary |Metafunction|; ``f::type`` is a *type-name*.
50
51 :Semantics:
52 ``x`` is the result of the metafunction invocation.
53
54
55 .. ...................................................................................
56
57 .. parsed-literal::
58
59 typedef f<>::type x;
60
61 :Precondition:
62 ``f`` is a nullary |Metafunction|; ``f<>::type`` is a *type-name*.
63
64 :Semantics:
65 ``x`` is the result of the metafunction invocation.
66
67
68 .. ...................................................................................
69
70 .. parsed-literal::
71
72 typedef f<a1,\ |...| \a\ *n*\>::type x;
73
74 :Precondition:
75 ``f`` is an *n*-ary |Metafunction|; |a1...an| are types;
76 ``f<a1,...an>::type`` is a *type-name*.
77
78 :Semantics:
79 ``x`` is the result of the metafunction invocation
80 with the actual arguments |a1...an|.
81
82
83 Models
84 ------
85
86 * |identity|
87 * |plus|
88 * |begin|
89 * |insert|
90 * |fold|
91
92
93 See also
94 --------
95
96 |Metafunctions|, |Metafunction Class|, |Lambda Expression|, |Invocation|, |apply|, |lambda|, |bind|
97
98
99 .. copyright:: Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams
100 Distributed under the Boost Software License, Version 1.0. (See accompanying
101 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)