• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Metafunctions/Concepts//Trivial Metafunction |70
2
3Trivial Metafunction
4====================
5
6Description
7-----------
8
9A |Trivial Metafunction| accepts a single argument of a class type ``x`` and
10returns the ``x``\ 's nested type member ``x::name``, where ``name`` is
11a placeholder token for the actual member's name accessed by a specific
12metafunction's instance. By convention, all `trivial metafunctions`__ in MPL
13are named after the members they provide assess to. For instance, a |Trivial
14Metafunction| named ``first`` reaches for the ``x``\ 's nested member
15``::first``.
16
17__ `Trivial Metafunctions Summary`_
18
19
20Expression requirements
21-----------------------
22
23|In the following table...| ``name`` is placeholder token for the names of
24the |Trivial Metafunction| itself and the accessed member, and ``x`` is
25a 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
34Expression 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
48Models
49------
50
51* |first|
52* |second|
53* |base|
54
55
56See also
57--------
58
59|Metafunctions|, |Trivial Metafunctions|, |identity|
60
61
62.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
63   Distributed under the Boost Software License, Version 1.0. (See accompanying
64   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
65