⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sizeof_.rst

📁 C++的一个好库。。。现在很流行
💻 RST
字号:
.. Metafunctions/Miscellaneous//sizeof_ |100

sizeof\_
========

Synopsis
--------

.. parsed-literal::
    
    template<
          typename X
        >
    struct sizeof\_
    {
        typedef |unspecified| type;
    };



Description
-----------

Returns the result of a ``sizeof(X)`` expression wrapped into an 
|Integral Constant| of the corresponding type, ``std::size_t``.


Header
------

.. parsed-literal::
    
    #include <boost/mpl/sizeof.hpp>


Model of
--------

|Metafunction|


Parameters
----------

+---------------+-------------------+-------------------------------------------+
| Parameter     | Requirement       | Description                               |
+===============+===================+===========================================+
| ``X``         | Any type          | A type to compute the ``sizeof`` for.     |
+---------------+-------------------+-------------------------------------------+


Expression semantics
--------------------

For an arbitrary type ``x``:


.. parsed-literal::

    typedef sizeof_<x>::type n; 


:Return type:
    |Integral Constant|.

:Precondition:
    ``x`` is a complete type.

:Semantics:
    Equivalent to
        
    .. parsed-literal::
    
        typedef size_t< sizeof(x) > n;



Complexity
----------

Constant time. 


Example
-------

.. parsed-literal::
    
    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) );


See also
--------

|Metafunctions|, |Integral Constant|, |size_t|

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -