• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Data Types/Concepts//Integral Constant
2
3Integral Constant
4=================
5
6Description
7-----------
8
9An |Integral Constant| is a holder class for a compile-time value of an
10integral type. Every |Integral Constant| is also a nullary |Metafunction|,
11returning itself. An integral constant *object* is implicitly convertible to the
12corresponding run-time value of the wrapped integral type.
13
14Expression 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
38Expression 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
63Models
64------
65
66* |bool_|
67* |int_|
68* |long_|
69* |char_|
70* |integral_c|
71
72
73See also
74--------
75
76|Data Types|, |Integral Sequence Wrapper|, |integral_c|
77
78
79.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
80   Distributed under the Boost Software License, Version 1.0. (See accompanying
81   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
82