about_tag_types.html 7.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>About Tag Types</title>
  5. <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
  7. <link rel="home" href="../index.html" title="Chapter&#160;1.&#160;Boost.FunctionTypes 2.5">
  8. <link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.FunctionTypes 2.5">
  9. <link rel="prev" href="use_cases.html" title="Use Cases">
  10. <link rel="next" href="reference.html" title="Reference">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="use_cases.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h2 class="title" style="clear: both">
  27. <a name="boost_functiontypes.about_tag_types"></a><a class="link" href="about_tag_types.html" title="About Tag Types">About Tag Types</a>
  28. </h2></div></div></div>
  29. <p>
  30. Boost.FunctionTypes uses tag types to encode properties that are not types
  31. per se, such as calling convention or whether a function is variadic or cv-
  32. qualified.
  33. </p>
  34. <p>
  35. These tags can be used to determine whether one property of a type has a particular
  36. value.
  37. </p>
  38. <pre class="programlisting"><span class="identifier">is_function</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">(...),</span> <span class="identifier">variadic</span><span class="special">&gt;::</span><span class="identifier">value</span> <span class="comment">// == true</span>
  39. <span class="identifier">is_function</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">()</span> <span class="special">,</span> <span class="identifier">variadic</span><span class="special">&gt;::</span><span class="identifier">value</span> <span class="comment">// == false</span>
  40. </pre>
  41. <p>
  42. A compound property tag describes a combination of possible values of different
  43. properties. The type <code class="literal">components&lt;F&gt;</code>, where <code class="literal">F</code>
  44. is a callable builtin type, is a compound property tag that describes <code class="literal">F</code>.
  45. The <code class="literal">tag</code> class template can be used to combine property tags.
  46. </p>
  47. <pre class="programlisting"><span class="identifier">tag</span><span class="special">&lt;</span><span class="identifier">non_const</span><span class="special">,</span><span class="identifier">default_cc</span><span class="special">&gt;</span> <span class="comment">// combination of two properties</span>
  48. </pre>
  49. <p>
  50. When several values for the same property are specified in <code class="literal">tag</code>'s
  51. argument list, only the rightmost one is used; others are ignored.
  52. </p>
  53. <pre class="programlisting"><span class="identifier">tag</span><span class="special">&lt;</span><span class="identifier">components</span><span class="special">&lt;</span><span class="identifier">F</span><span class="special">&gt;,</span> <span class="identifier">default_cc</span><span class="special">&gt;</span> <span class="comment">// overrides F's calling convention property</span>
  54. </pre>
  55. <p>
  56. When compound property tag is specified to analyse a type, all of its component
  57. properties must match.
  58. </p>
  59. <pre class="programlisting"><span class="identifier">is_member_function_pointer</span><span class="special">&lt;</span> <span class="identifier">F</span><span class="special">,</span> <span class="identifier">tag</span><span class="special">&lt;</span><span class="identifier">const_qualified</span><span class="special">,</span><span class="identifier">default_cc</span><span class="special">&gt;</span> <span class="special">&gt;::</span><span class="identifier">value</span>
  60. <span class="comment">// true for </span>
  61. <span class="comment">// F = void(a_class::*)() const</span>
  62. <span class="comment">// false for</span>
  63. <span class="comment">// F = void(a_class::*)()</span>
  64. <span class="comment">// F = void(__fastcall a_class::*)() const</span>
  65. </pre>
  66. <p>
  67. Default values are selected for properties not specified by the tag in the
  68. context of type synthesis.
  69. </p>
  70. <pre class="programlisting"><span class="comment">// given S = mpl::vector&lt;int,a_class const &amp;&gt;</span>
  71. <span class="identifier">member_function_pointer</span><span class="special">&lt;</span><span class="identifier">S</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="comment">// is int (a_class::*)() const</span>
  72. <span class="comment">// note: the cv-qualification is picked based on the class type,</span>
  73. <span class="comment">// a nonvariadic signature and the default calling convention </span>
  74. <span class="comment">// are used</span>
  75. <span class="identifier">member_function_pointer</span><span class="special">&lt;</span><span class="identifier">S</span><span class="special">,</span><span class="identifier">non_const</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="comment">// is int (a_class::*)()</span>
  76. <span class="comment">// no const qualification, as explicitly specified by the tag type</span>
  77. </pre>
  78. </div>
  79. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  80. <td align="left"></td>
  81. <td align="right"><div class="copyright-footer">Copyright &#169; 2004-2007 Tobias
  82. Schwinger<p>
  83. Distributed under the Boost Software License, Version 1.0. (See accompanying
  84. file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
  85. </p>
  86. </div></td>
  87. </tr></table>
  88. <hr>
  89. <div class="spirit-nav">
  90. <a accesskey="p" href="use_cases.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
  91. </div>
  92. </body>
  93. </html>