]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | .. Data Types/Concepts//Integral Constant |
2 | ||
3 | Integral Constant | |
4 | ================= | |
5 | ||
6 | Description | |
7 | ----------- | |
8 | ||
9 | An |Integral Constant| is a holder class for a compile-time value of an | |
10 | integral type. Every |Integral Constant| is also a nullary |Metafunction|, | |
11 | returning itself. An integral constant *object* is implicitly convertible to the | |
12 | corresponding run-time value of the wrapped integral type. | |
13 | ||
14 | Expression requirements | |
15 | ----------------------- | |
16 | ||
17 | |In the following table...| ``n`` is a model of |Integral Constant|. | |
18 | ||
19 | +-----------------------------------+---------------------------------------+---------------------------+ | |
20 | | Expression | Type | Complexity | | |
21 | +===================================+=======================================+===========================+ | |
22 | | ``n::tag`` | ``integral_c_tag`` | Constant time. | | |
23 | +-----------------------------------+---------------------------------------+---------------------------+ | |
24 | | ``n::value_type`` | An integral type | Constant time. | | |
25 | +-----------------------------------+---------------------------------------+---------------------------+ | |
26 | | ``n::value`` | An integral constant expression | Constant time. | | |
27 | +-----------------------------------+---------------------------------------+---------------------------+ | |
28 | | ``n::type`` | |Integral Constant| | Constant time. | | |
29 | +-----------------------------------+---------------------------------------+---------------------------+ | |
30 | | ``next<n>::type`` | |Integral Constant| | Constant time. | | |
31 | +-----------------------------------+---------------------------------------+---------------------------+ | |
32 | | ``prior<n>::type`` | |Integral Constant| | Constant time. | | |
33 | +-----------------------------------+---------------------------------------+---------------------------+ | |
34 | | ``n::value_type const c = n()`` | | Constant time. | | |
35 | +-----------------------------------+---------------------------------------+---------------------------+ | |
36 | ||
37 | ||
38 | Expression semantics | |
39 | -------------------- | |
40 | ||
41 | +---------------------------------------+-----------------------------------------------------------+ | |
42 | | Expression | Semantics | | |
43 | +=======================================+===========================================================+ | |
44 | | ``n::tag`` | ``n``\ 's tag type; ``n::tag::value`` is ``n``\ 's | | |
45 | | | *conversion rank*. | | |
46 | +---------------------------------------+-----------------------------------------------------------+ | |
47 | | ``n::value_type`` | A cv-unqualified type of ``n::value``. | | |
48 | +---------------------------------------+-----------------------------------------------------------+ | |
49 | | ``n::value`` | The value of the wrapped integral constant. | | |
50 | +---------------------------------------+-----------------------------------------------------------+ | |
51 | | ``n::type`` | ``is_same<n::type,n>::value == true``. | | |
52 | +---------------------------------------+-----------------------------------------------------------+ | |
53 | | ``next<n>::type`` | An |Integral Constant| ``c`` of type ``n::value_type`` | | |
54 | | | such that ``c::value == n::value + 1``. | | |
55 | +---------------------------------------+-----------------------------------------------------------+ | |
56 | | ``prior<n>::type`` | An |Integral Constant| ``c`` of type ``n::value_type`` | | |
57 | | | such that ``c::value == n::value - 1``. | | |
58 | +---------------------------------------+-----------------------------------------------------------+ | |
59 | | ``n::value_type const c = n()`` | ``c == n::value``. | | |
60 | +---------------------------------------+-----------------------------------------------------------+ | |
61 | ||
62 | ||
63 | Models | |
64 | ------ | |
65 | ||
66 | * |bool_| | |
67 | * |int_| | |
68 | * |long_| | |
69 | * |char_| | |
70 | * |integral_c| | |
71 | ||
72 | ||
73 | See also | |
74 | -------- | |
75 | ||
76 | |Data Types|, |Integral Sequence Wrapper|, |integral_c| | |
77 | ||
78 | ||
79 |