]>
Commit | Line | Data |
---|---|---|
1 | .. Metafunctions/Concepts//Metafunction Class |20 | |
2 | ||
3 | Metafunction Class | |
4 | ================== | |
5 | ||
6 | Summary | |
7 | ------- | |
8 | ||
9 | A *metafunction class* is a certain form of metafunction representation | |
10 | that enables higher-order metaprogramming. More precisely, it's a class | |
11 | with a publicly-accessible nested |metafunction| called ``apply``. | |
12 | Correspondingly, a metafunction class invocation is defined as invocation | |
13 | of its nested ``apply`` metafunction. | |
14 | ||
15 | ||
16 | Expression requirements | |
17 | ----------------------- | |
18 | ||
19 | |In the following table...| ``f`` is a |Metafunction Class|. | |
20 | ||
21 | +-------------------------------+---------------------------+---------------------------+ | |
22 | | Expression | Type | Complexity | | |
23 | +===============================+===========================+===========================+ | |
24 | | ``f::apply::type`` | Any type | Unspecified. | | |
25 | +-------------------------------+---------------------------+---------------------------+ | |
26 | | ``f::apply<>::type`` | Any type | Unspecified. | | |
27 | +-------------------------------+---------------------------+---------------------------+ | |
28 | | ``f::apply<a1,...an>::type`` | Any type | Unspecified. | | |
29 | +-------------------------------+---------------------------+---------------------------+ | |
30 | ||
31 | ||
32 | Expression semantics | |
33 | -------------------- | |
34 | ||
35 | .. parsed-literal:: | |
36 | ||
37 | typedef f::apply::type x; | |
38 | ||
39 | :Precondition: | |
40 | ``f`` is a nullary |Metafunction Class|; ``f::apply::type`` is a *type-name*. | |
41 | ||
42 | :Semantics: | |
43 | ``x`` is the result of the metafunction class invocation. | |
44 | ||
45 | ||
46 | .. ................................................................................... | |
47 | ||
48 | .. parsed-literal:: | |
49 | ||
50 | typedef f::apply<>::type x; | |
51 | ||
52 | :Precondition: | |
53 | ``f`` is a nullary |Metafunction Class|; ``f::apply<>::type`` is a *type-name*. | |
54 | ||
55 | :Semantics: | |
56 | ``x`` is the result of the metafunction class invocation. | |
57 | ||
58 | ||
59 | .. ................................................................................... | |
60 | ||
61 | .. parsed-literal:: | |
62 | ||
63 | typedef f::apply<a1,\ |...|\ a\ *n*\>::type x; | |
64 | ||
65 | :Precondition: | |
66 | ``f`` is an *n*-ary metafunction class; ``apply`` is a |Metafunction|. | |
67 | ||
68 | :Semantics: | |
69 | ``x`` is the result of the metafunction class | |
70 | invocation with the actual arguments |a1...an|. | |
71 | ||
72 | ||
73 | Models | |
74 | ------ | |
75 | ||
76 | * |always| | |
77 | * |arg| | |
78 | * |quote| | |
79 | * |numeric_cast| | |
80 | * |unpack_args| | |
81 | ||
82 | ||
83 | See also | |
84 | -------- | |
85 | ||
86 | |Metafunctions|, |Metafunction|, |Lambda Expression|, |Invocation|, |apply_wrap|, |bind|, |quote| | |
87 | ||
88 | ||
89 |