Front Page / Metafunctions / Miscellaneous / sizeof_ |
Returns the result of a sizeof(X) expression wrapped into an Integral Constant of the corresponding type, std::size_t.
#include <boost/mpl/sizeof.hpp>
Parameter | Requirement | Description |
---|---|---|
X | Any type | A type to compute the sizeof for. |
For an arbitrary type x:
typedef sizeof_<x>::type n;
Return type: | Integral Constant. |
---|---|
Precondition: | x is a complete type. |
Semantics: | Equivalent to typedef size_t< sizeof(x) > n; |
Constant time.
struct udt { char a[100]; }; BOOST_MPL_ASSERT_RELATION( sizeof_<char>::value, ==, sizeof(char) ); BOOST_MPL_ASSERT_RELATION( sizeof_<int>::value, ==, sizeof(int) ); BOOST_MPL_ASSERT_RELATION( sizeof_<double>::value, ==, sizeof(double) ); BOOST_MPL_ASSERT_RELATION( sizeof_<udt>::value, ==, sizeof(my) );