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

📄 identity.rst

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

identity
========

Synopsis
--------

.. parsed-literal::
    
    template< 
          typename X
        >
    struct identity
    {
        typedef X type;
    };


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

The `identity`__ metafunction. Returns ``X`` unchanged.

__ http://mathworld.wolfram.com/IdentityFunction.html


Header
------

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


Model of
--------

|Metafunction|


Parameters
----------

+---------------+-------------------+-----------------------------------+
| Parameter     | Requirement       | Description                       |
+===============+===================+===================================+
| ``X``         | Any type          | An argument to be returned.       |
+---------------+-------------------+-----------------------------------+


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

For an arbitrary type ``x``:


.. parsed-literal::

    typedef identity<x>::type r;

:Return type:
    A type.

:Semantics:
    Equivalent to
    
    .. parsed-literal::
    
        typedef x r;


:Postcondition:
    ``is_same<r,x>::value == true``.
    
    

Example
-------

.. parsed-literal::
    
    typedef apply< identity<_1>, char >::type t1;
    typedef apply< identity<_2>, char,int >::type t2;
    
    BOOST_MPL_ASSERT(( is_same< t1, char > ));
    BOOST_MPL_ASSERT(( is_same< t2, int > ));


See also
--------

|Metafunctions|, |Placeholders|, |Trivial Metafunctions|, |always|, |apply|

⌨️ 快捷键说明

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