]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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.76.1"> | |
7 | <link rel="home" href="../index.html" title="Chapter 1. Boost.FunctionTypes 2.5"> | |
8 | <link rel="up" href="../index.html" title="Chapter 1. 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"><</span><span class="keyword">int</span><span class="special">(...),</span> <span class="identifier">variadic</span><span class="special">>::</span><span class="identifier">value</span> <span class="comment">// == true | |
39 | </span><span class="identifier">is_function</span><span class="special"><</span><span class="keyword">int</span><span class="special">()</span> <span class="special">,</span> <span class="identifier">variadic</span><span class="special">>::</span><span class="identifier">value</span> <span class="comment">// == false | |
40 | </span></pre> | |
41 | <p> | |
42 | A compound property tag describes a combination of possible values of different | |
43 | properties. The type <code class="literal">components<F></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"><</span><span class="identifier">non_const</span><span class="special">,</span><span class="identifier">default_cc</span><span class="special">></span> <span class="comment">// combination of two properties | |
48 | </span></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"><</span><span class="identifier">components</span><span class="special"><</span><span class="identifier">F</span><span class="special">>,</span> <span class="identifier">default_cc</span><span class="special">></span> <span class="comment">// overrides F's calling convention property | |
54 | </span></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"><</span> <span class="identifier">F</span><span class="special">,</span> <span class="identifier">tag</span><span class="special"><</span><span class="identifier">const_qualified</span><span class="special">,</span><span class="identifier">default_cc</span><span class="special">></span> <span class="special">>::</span><span class="identifier">value</span> | |
60 | <span class="comment">// true for | |
61 | </span><span class="comment">// F = void(a_class::*)() const | |
62 | </span><span class="comment">// false for | |
63 | </span><span class="comment">// F = void(a_class::*)() | |
64 | </span><span class="comment">// F = void(__fastcall a_class::*)() const | |
65 | </span></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<int,a_class const &> | |
71 | </span> | |
72 | <span class="identifier">member_function_pointer</span><span class="special"><</span><span class="identifier">S</span><span class="special">>::</span><span class="identifier">type</span> <span class="comment">// is int (a_class::*)() const | |
73 | </span><span class="comment">// note: the cv-qualification is picked based on the class type, | |
74 | </span><span class="comment">// a nonvariadic signature and the default calling convention | |
75 | </span><span class="comment">// are used | |
76 | </span> | |
77 | <span class="identifier">member_function_pointer</span><span class="special"><</span><span class="identifier">S</span><span class="special">,</span><span class="identifier">non_const</span><span class="special">>::</span><span class="identifier">type</span> <span class="comment">// is int (a_class::*)() | |
78 | </span><span class="comment">// no const qualification, as explicitly specified by the tag type | |
79 | </span></pre> | |
80 | </div> | |
81 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
82 | <td align="left"></td> | |
83 | <td align="right"><div class="copyright-footer">Copyright © 2004-2007 Tobias | |
84 | Schwinger<p> | |
85 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
86 | 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>) | |
87 | </p> | |
88 | </div></td> | |
89 | </tr></table> | |
90 | <hr> | |
91 | <div class="spirit-nav"> | |
92 | <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> | |
93 | </div> | |
94 | </body> | |
95 | </html> |