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

📄 value_type.rst

📁 C++的一个好库。。。现在很流行
💻 RST
字号:
.. Sequences/Intrinsic Metafunctions//value_type

value_type
==========

Synopsis
--------

.. parsed-literal::
    
    template<
          typename Sequence
        , typename X
        >
    struct value_type
    {
        typedef |unspecified| type;
    };



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

Returns the |value| that would be used for element ``X`` in ``Sequence``.


Header
------

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


Model of
--------

|Tag Dispatched Metafunction|


Parameters
----------

+---------------+---------------------------+-----------------------------------------------+
| Parameter     | Requirement               | Description                                   |
+===============+===========================+===============================================+
| ``Sequence``  | |Associative Sequence|    | A sequence to query.                          |
+---------------+---------------------------+-----------------------------------------------+
| ``X``         | Any type                  | The type to get the |value| for.              |
+---------------+---------------------------+-----------------------------------------------+


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

For any |Associative Sequence| ``s``, and an artibrary type ``x``:


.. parsed-literal::

    typedef value_type<s,x>::type v; 

:Return type:
    A type.
    
:Precondition:
    ``x`` can be put in ``s``.

:Semantics:
    ``v`` is the |value| that would be used for ``x`` in ``s``.

:Postcondition:
    If     
    .. parsed-literal::
       
       has_key< s,key_type<s,x>::type >::type
    
    then
    .. parsed-literal::
    
       at< s,key_type<s,x>::type >::type
    
    is identical to ``value_type<s,x>::type``.



Complexity
----------

Amortized constant time.


Example
-------

.. parsed-literal::
    
    typedef value_type< map<>,pair<int,unsigned> >::type v1;
    typedef value_type< set<>,pair<int,unsigned> >::type v2;

    BOOST_MPL_ASSERT(( is_same< v1,unsigned > ));
    BOOST_MPL_ASSERT(( is_same< v2,pair<int,unsigned> > ));


See also
--------

|Associative Sequence|, |key_type|, |at|, |set|, |map|

⌨️ 快捷键说明

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