]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/metafunction.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / metaparse / doc / metafunction.qbk
1 [#metafunction]
2 [section Template metafunction]
3
4 A ['template metafunction] represents a function over types that is evaluated at
5 compile-time. It is implemented by a template class.
6
7 The template arguments of that class are expected to be types (`class` or
8 `typename` template arguments). They represent the arguments of the
9 metafunction.
10
11 Instances of the template class are expected to have a public nested type called
12 `type`. This type is the type the metafunction returns.
13
14 Template metafunction are expected to be called with
15 [link metaprogramming_value template metaprogramming values] as arguments only.
16
17 Template metafunctions are expected to return template metaprogramming values.
18
19 For example this is the identity template metafunction:
20
21 template <class T>
22 struct identity
23 {
24 using type = T;
25 };
26
27 This metafunction is called `identity`. It takes one argument, `T`. The result
28 of calling this metafunction is its argument, `T`.
29
30 To call this metafunction, one has to instantiate the template class. The
31 template arguments it is instantiated with are the arguments the metafunction is
32 called with. For example:
33
34 identity<std::integral_constant<int, 13>>::type
35
36 The above example calls the metafunction `identity` with
37 `std::integral_constant<int, 13>` as its argument.
38
39 [endsect]
40