]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpl/doc/src/refmanual/sizeof_.rst
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / mpl / doc / src / refmanual / sizeof_.rst
CommitLineData
7c673cae
FG
1.. Metafunctions/Miscellaneous//sizeof_ |100
2
3sizeof\_
4========
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11 template<
12 typename X
13 >
14 struct sizeof\_
15 {
16 typedef |unspecified| type;
17 };
18
19
20
21Description
22-----------
23
24Returns the result of a ``sizeof(X)`` expression wrapped into an
25|Integral Constant| of the corresponding type, ``std::size_t``.
26
27
28Header
29------
30
31.. parsed-literal::
32
33 #include <boost/mpl/sizeof.hpp>
34
35
36Model of
37--------
38
39|Metafunction|
40
41
42Parameters
43----------
44
45+---------------+-------------------+-------------------------------------------+
46| Parameter | Requirement | Description |
47+===============+===================+===========================================+
48| ``X`` | Any type | A type to compute the ``sizeof`` for. |
49+---------------+-------------------+-------------------------------------------+
50
51
52Expression semantics
53--------------------
54
55For an arbitrary type ``x``:
56
57
58.. parsed-literal::
59
60 typedef sizeof_<x>::type n;
61
62
63:Return type:
64 |Integral Constant|.
65
66:Precondition:
67 ``x`` is a complete type.
68
69:Semantics:
70 Equivalent to
71
72 .. parsed-literal::
73
74 typedef size_t< sizeof(x) > n;
75
76
77
78Complexity
79----------
80
81Constant time.
82
83
84Example
85-------
86
87.. parsed-literal::
88
89 struct udt { char a[100]; };
90
91 BOOST_MPL_ASSERT_RELATION( sizeof_<char>::value, ==, sizeof(char) );
92 BOOST_MPL_ASSERT_RELATION( sizeof_<int>::value, ==, sizeof(int) );
93 BOOST_MPL_ASSERT_RELATION( sizeof_<double>::value, ==, sizeof(double) );
94 BOOST_MPL_ASSERT_RELATION( sizeof_<udt>::value, ==, sizeof(my) );
95
96
97See also
98--------
99
100|Metafunctions|, |Integral Constant|, |size_t|
101
102
103