]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Metafunctions/Concepts//Trivial Metafunction |70 |
2 | ||
3 | Trivial Metafunction | |
4 | ==================== | |
5 | ||
6 | Description | |
7 | ----------- | |
8 | ||
9 | A |Trivial Metafunction| accepts a single argument of a class type ``x`` and | |
10 | returns the ``x``\ 's nested type member ``x::name``, where ``name`` is | |
11 | a placeholder token for the actual member's name accessed by a specific | |
12 | metafunction's instance. By convention, all `trivial metafunctions`__ in MPL | |
13 | are named after the members they provide assess to. For instance, a |Trivial | |
14 | Metafunction| named ``first`` reaches for the ``x``\ 's nested member | |
15 | ``::first``. | |
16 | ||
17 | __ `Trivial Metafunctions Summary`_ | |
18 | ||
19 | ||
20 | Expression requirements | |
21 | ----------------------- | |
22 | ||
23 | |In the following table...| ``name`` is placeholder token for the names of | |
24 | the |Trivial Metafunction| itself and the accessed member, and ``x`` is | |
25 | a class type such that ``x::name`` is a valid *type-name*. | |
26 | ||
27 | +---------------------------+-------------------+---------------------------+ | |
28 | | Expression | Type | Complexity | | |
29 | +===========================+===================+===========================+ | |
30 | | ``name<x>::type`` | Any type | Constant time. | | |
31 | +---------------------------+-------------------+---------------------------+ | |
32 | ||
33 | ||
34 | Expression semantics | |
35 | -------------------- | |
36 | ||
37 | .. parsed-literal:: | |
38 | ||
39 | typedef name<x>::type r; | |
40 | ||
41 | :Precondition: | |
42 | ``x::name`` is a valid *type-name*. | |
43 | ||
44 | :Semantics: | |
45 | ``is_same<r,x::name>::value == true``. | |
46 | ||
47 | ||
48 | Models | |
49 | ------ | |
50 | ||
51 | * |first| | |
52 | * |second| | |
53 | * |base| | |
54 | ||
55 | ||
56 | See also | |
57 | -------- | |
58 | ||
59 | |Metafunctions|, |Trivial Metafunctions|, |identity| | |
60 | ||
61 | ||
62 |