2 [section Template metafunction]
4 A ['template metafunction] represents a function over types that is evaluated at
5 compile-time. It is implemented by a template class.
7 The template arguments of that class are expected to be types (`class` or
8 `typename` template arguments). They represent the arguments of the
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.
14 Template metafunction are expected to be called with
15 [link metaprogramming_value template metaprogramming values] as arguments only.
17 Template metafunctions are expected to return template metaprogramming values.
19 For example this is the identity template metafunction:
27 This metafunction is called `identity`. It takes one argument, `T`. The result
28 of calling this metafunction is its argument, `T`.
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:
34 identity<std::integral_constant<int, 13>>::type
36 The above example calls the metafunction `identity` with
37 `std::integral_constant<int, 13>` as its argument.