key-type.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.7: http://docutils.sourceforge.net/" />
  7. <title>The MPL Reference Manual: key_type</title>
  8. <link rel="stylesheet" href="../style.css" type="text/css" />
  9. </head>
  10. <body class="docframe refmanual">
  11. <table class="header"><tr class="header"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./is-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./order.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./is-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./order.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  12. <td class="header-group page-location"><a href="../refmanual.html" class="navigation-link">Front Page</a> / <a href="./sequences.html" class="navigation-link">Sequences</a> / <a href="./intrinsic-metafunctions.html" class="navigation-link">Intrinsic Metafunctions</a> / <a href="./key-type.html" class="navigation-link">key_type</a></td>
  13. </tr></table><div class="header-separator"></div>
  14. <div class="section" id="key-type">
  15. <h1><a class="toc-backref" href="./intrinsic-metafunctions.html#id1439">key_type</a></h1>
  16. <div class="section" id="id300">
  17. <h3><a class="subsection-title" href="#synopsis" name="synopsis">Synopsis</a></h3>
  18. <pre class="literal-block">
  19. template&lt;
  20. typename Sequence
  21. , typename X
  22. &gt;
  23. struct <a href="./key-type.html" class="identifier">key_type</a>
  24. {
  25. typedef <em>unspecified</em> type;
  26. };
  27. </pre>
  28. </div>
  29. <div class="section" id="id301">
  30. <h3><a class="subsection-title" href="#description" name="description">Description</a></h3>
  31. <p>Returns the <a class="reference internal" href="./associative-sequence.html#key-part">key</a> that would be used to identify <tt class="literal"><span class="pre">X</span></tt> in <tt class="literal"><span class="pre">Sequence</span></tt>.</p>
  32. </div>
  33. <div class="section" id="id302">
  34. <h3><a class="subsection-title" href="#header" name="header">Header</a></h3>
  35. <pre class="literal-block">
  36. #include &lt;<a href="../../../../boost/mpl/key_type.hpp" class="header">boost/mpl/key_type.hpp</a>&gt;
  37. </pre>
  38. </div>
  39. <div class="section" id="id303">
  40. <h3><a class="subsection-title" href="#model-of" name="model-of">Model of</a></h3>
  41. <p><a class="reference internal" href="./tag-dispatched-metafunction.html">Tag Dispatched Metafunction</a></p>
  42. </div>
  43. <div class="section" id="id304">
  44. <h3><a class="subsection-title" href="#parameters" name="parameters">Parameters</a></h3>
  45. <table border="1" class="docutils table">
  46. <colgroup>
  47. <col width="17%" />
  48. <col width="30%" />
  49. <col width="53%" />
  50. </colgroup>
  51. <thead valign="bottom">
  52. <tr><th class="head">Parameter</th>
  53. <th class="head">Requirement</th>
  54. <th class="head">Description</th>
  55. </tr>
  56. </thead>
  57. <tbody valign="top">
  58. <tr><td><tt class="literal"><span class="pre">Sequence</span></tt></td>
  59. <td><a class="reference internal" href="./associative-sequence.html">Associative Sequence</a></td>
  60. <td>A sequence to query.</td>
  61. </tr>
  62. <tr><td><tt class="literal"><span class="pre">X</span></tt></td>
  63. <td>Any type</td>
  64. <td>The type to get the <a class="reference internal" href="./associative-sequence.html#key-part">key</a> for.</td>
  65. </tr>
  66. </tbody>
  67. </table>
  68. </div>
  69. <div class="section" id="id305">
  70. <h3><a class="subsection-title" href="#expression-semantics" name="expression-semantics">Expression semantics</a></h3>
  71. <p>For any <a class="reference internal" href="./associative-sequence.html">Associative Sequence</a> <tt class="literal"><span class="pre">s</span></tt>, iterators <tt class="literal"><span class="pre">pos1</span></tt> and <tt class="literal"><span class="pre">pos2</span></tt> in <tt class="literal"><span class="pre">s</span></tt>, and an
  72. artibrary type <tt class="literal"><span class="pre">x</span></tt>:</p>
  73. <pre class="literal-block">
  74. typedef <a href="./key-type.html" class="identifier">key_type</a>&lt;s,x&gt;::type k;
  75. </pre>
  76. <table class="docutils field-list" frame="void" rules="none">
  77. <col class="field-name" />
  78. <col class="field-body" />
  79. <tbody valign="top">
  80. <tr class="field"><th class="field-name">Return type:</th><td class="field-body">A type.</td>
  81. </tr>
  82. <tr class="field"><th class="field-name">Precondition:</th><td class="field-body"><tt class="literal"><span class="pre">x</span></tt> can be put in <tt class="literal"><span class="pre">s</span></tt>.</td>
  83. </tr>
  84. <tr class="field"><th class="field-name">Semantics:</th><td class="field-body"><tt class="literal"><span class="pre">k</span></tt> is the <a class="reference internal" href="./associative-sequence.html#key-part">key</a> that would be used to identify <tt class="literal"><span class="pre">x</span></tt> in <tt class="literal"><span class="pre">s</span></tt>.</td>
  85. </tr>
  86. <tr class="field"><th class="field-name">Postcondition:</th><td class="field-body">If <tt class="literal"><span class="pre"><a href="./key-type.html" class="identifier">key_type</a>&lt;</span> <span class="pre">s,<a href="./deref.html" class="identifier">deref</a>&lt;pos1&gt;::type</span> <span class="pre">&gt;::type</span></tt> is identical to
  87. <tt class="literal"><span class="pre"><a href="./key-type.html" class="identifier">key_type</a>&lt;</span> <span class="pre">s,<a href="./deref.html" class="identifier">deref</a>&lt;pos2&gt;::type</span> <span class="pre">&gt;::type</span></tt> then <tt class="literal"><span class="pre">pos1</span></tt> is identical to <tt class="literal"><span class="pre">pos2</span></tt>.</td>
  88. </tr>
  89. </tbody>
  90. </table>
  91. </div>
  92. <div class="section" id="id306">
  93. <h3><a class="subsection-title" href="#complexity" name="complexity">Complexity</a></h3>
  94. <p>Amortized constant time.</p>
  95. </div>
  96. <div class="section" id="id307">
  97. <h3><a class="subsection-title" href="#example" name="example">Example</a></h3>
  98. <pre class="literal-block">
  99. typedef <a href="./key-type.html" class="identifier">key_type</a>&lt; <a href="./map.html" class="identifier">map</a>&lt;&gt;,<a href="./pair.html" class="identifier">pair</a>&lt;int,unsigned&gt; &gt;::type k1;
  100. typedef <a href="./key-type.html" class="identifier">key_type</a>&lt; <a href="./set.html" class="identifier">set</a>&lt;&gt;,<a href="./pair.html" class="identifier">pair</a>&lt;int,unsigned&gt; &gt;::type k2;
  101. <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; k1,int &gt; ));
  102. <a href="./assert.html" class="identifier">BOOST_MPL_ASSERT</a>(( is_same&lt; k2,<a href="./pair.html" class="identifier">pair</a>&lt;int,unsigned&gt; > ));
  103. </pre>
  104. </div>
  105. <div class="section" id="id308">
  106. <h3><a class="subsection-title" href="#see-also" name="see-also">See also</a></h3>
  107. <p><a class="reference internal" href="./associative-sequence.html">Associative Sequence</a>, <a class="reference internal" href="./value-type.html">value_type</a>, <a class="reference internal" href="./has-key.html">has_key</a>, <a class="reference internal" href="./set.html">set</a>, <a class="reference internal" href="./map.html">map</a></p>
  108. <!-- Sequences/Intrinsic Metafunctions//order -->
  109. </div>
  110. </div>
  111. <div class="footer-separator"></div>
  112. <table class="footer"><tr class="footer"><td class="header-group navigation-bar"><span class="navigation-group"><a href="./is-sequence.html" class="navigation-link">Prev</a>&nbsp;<a href="./order.html" class="navigation-link">Next</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./is-sequence.html" class="navigation-link">Back</a>&nbsp;<a href="./order.html" class="navigation-link">Along</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./intrinsic-metafunctions.html" class="navigation-link">Up</a>&nbsp;<a href="../refmanual.html" class="navigation-link">Home</a></span><span class="navigation-group-separator">&nbsp;|&nbsp;</span><span class="navigation-group"><a href="./refmanual_toc.html" class="navigation-link">Full TOC</a></span></td>
  113. <td><div class="copyright-footer"><div class="copyright">Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams</div>
  114. Distributed under the Boost Software License, Version 1.0. (See accompanying
  115. file LICENSE_1_0.txt or copy at <a class="reference external" href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</div></td></tr></table></body>
  116. </html>