1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Macro BOOST_TTI_TRAIT_MEMBER_TYPE</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 1. The Type Traits Introspection Library"> 8<link rel="up" href="header/boost/tti/member_type_hpp.html" title="Header <boost/tti/member_type.hpp>"> 9<link rel="prev" href="boost/tti/valid_member_type.html" title="Struct template valid_member_type"> 10<link rel="next" href="BOOST_TTI_MEMBER_TYPE.html" title="Macro BOOST_TTI_MEMBER_TYPE"> 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="boost/tti/valid_member_type.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="header/boost/tti/member_type_hpp.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="BOOST_TTI_MEMBER_TYPE.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="refentry"> 26<a name="BOOST_TT_idm45731741041712"></a><div class="titlepage"></div> 27<div class="refnamediv"> 28<h2><span class="refentrytitle">Macro BOOST_TTI_TRAIT_MEMBER_TYPE</span></h2> 29<p>BOOST_TTI_TRAIT_MEMBER_TYPE — A macro expands to a metafunction whose typedef 'type' is either the named type or a marker type. </p> 30</div> 31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2> 32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="header/boost/tti/member_type_hpp.html" title="Header <boost/tti/member_type.hpp>">boost/tti/member_type.hpp</a>> 33 34</span>BOOST_TTI_TRAIT_MEMBER_TYPE(trait, name)</pre></div> 35<div class="refsect1"> 36<a name="idm45658021959952"></a><h2>Description</h2> 37<p>BOOST_TTI_TRAIT_MEMBER_TYPE is a macro which expands to a metafunction. The metafunction tests whether an inner type with a particular name exists by returning the inner type or a marker type. The macro takes the form of BOOST_TTI_TRAIT_MEMBER_TYPE(trait,name) where</p> 38<p>trait = the name of the metafunction <br> 39 name = the name of the inner type.</p> 40<p>BOOST_TTI_TRAIT_MEMBER_TYPE generates a metafunction called "trait" where 'trait' is the macro parameter.</p> 41<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">BOOST_TTI_TP_T</span><span class="special">,</span><span class="keyword">class</span> <span class="identifier">BOOST_TTI_TP_MARKER_TYPE</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tti</span><span class="special">::</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">notype</span><span class="special">></span> 42<span class="keyword">struct</span> <span class="identifier">trait</span> 43 <span class="special">{</span> 44 <span class="keyword">typedef</span> <span class="identifier">unspecified</span> <span class="identifier">type</span><span class="special">;</span> 45 <span class="keyword">typedef</span> <span class="identifier">BOOST_TTI_TP_MARKER_TYPE</span> <span class="identifier">boost_tti_marker_type</span><span class="special">;</span> 46 <span class="special">}</span><span class="special">;</span> 47 48<span class="identifier">The</span> <span class="identifier">metafunction</span> <span class="identifier">types</span> <span class="identifier">and</span> <span class="keyword">return</span><span class="special">:</span> 49 50 <span class="identifier">BOOST_TTI_TP_T</span> <span class="special">=</span> <span class="identifier">the</span> <span class="identifier">enclosing</span> <span class="identifier">type</span><span class="special">.</span> 51 <span class="identifier">The</span> <span class="identifier">enclosing</span> <span class="identifier">type</span> <span class="identifier">can</span> <span class="identifier">be</span> <span class="identifier">a</span> <span class="keyword">class</span><span class="special">,</span> <span class="keyword">struct</span><span class="special">,</span> <span class="identifier">or</span> <span class="keyword">union</span><span class="special">.</span> 52 53 <span class="identifier">BOOST_TTI_TP_MARKER_TYPE</span> <span class="special">=</span> <span class="special">(</span><span class="identifier">optional</span><span class="special">)</span> <span class="identifier">a</span> <span class="identifier">type</span> <span class="identifier">to</span> <span class="identifier">use</span> <span class="identifier">as</span> <span class="identifier">the</span> <span class="identifier">marker</span> <span class="identifier">type</span><span class="special">.</span> 54 <span class="identifier">defaults</span> <span class="identifier">to</span> <span class="identifier">the</span> <span class="identifier">internal</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tti</span><span class="special">::</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">notype</span><span class="special">.</span> 55 56 <span class="identifier">returns</span> <span class="special">=</span> <span class="char">'type'</span> <span class="identifier">is</span> <span class="identifier">the</span> <span class="identifier">inner</span> <span class="identifier">type</span> <span class="identifier">of</span> <span class="char">'name'</span> <span class="keyword">if</span> <span class="identifier">the</span> <span class="identifier">inner</span> <span class="identifier">type</span> <span class="identifier">exists</span> 57 <span class="identifier">within</span> <span class="identifier">the</span> <span class="identifier">enclosing</span> <span class="identifier">type</span><span class="special">,</span> <span class="keyword">else</span> <span class="char">'type'</span> <span class="identifier">is</span> <span class="identifier">a</span> <span class="identifier">marker</span> <span class="identifier">type</span><span class="special">.</span> 58 <span class="keyword">if</span> <span class="identifier">the</span> <span class="identifier">end</span><span class="special">-</span><span class="identifier">user</span> <span class="identifier">does</span> <span class="identifier">not</span> <span class="identifier">specify</span> <span class="identifier">a</span> <span class="identifier">marker</span> <span class="identifier">type</span> <span class="identifier">then</span> 59 <span class="identifier">an</span> <span class="identifier">internal</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tti</span><span class="special">::</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">notype</span> <span class="identifier">marker</span> <span class="identifier">type</span><span class="special">,</span> 60 <span class="identifier">which</span> <span class="identifier">is</span> <span class="identifier">empty</span><span class="special">,</span> <span class="identifier">is</span> <span class="identifier">used</span><span class="special">.</span> 61 62 <span class="identifier">The</span> <span class="identifier">metafunction</span> <span class="identifier">also</span> <span class="identifier">encapsulates</span> <span class="identifier">the</span> <span class="identifier">type</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">marker</span> <span class="identifier">type</span> <span class="identifier">as</span> 63 <span class="identifier">a</span> <span class="identifier">nested</span> <span class="char">'boost_tti_marker_type'</span><span class="special">.</span> 64</pre> 65<p>The purpose of this macro is to encapsulate the 'name' type as the typedef 'type' of a metafunction, but only if it exists within the enclosing type. This allows for an evaluation of inner type existence, without generating a compiler error, which can be used by other metafunctions in this library. </p> 66</div> 67</div> 68<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 69<td align="left"></td> 70<td align="right"><div class="copyright-footer">Copyright © 2011-2013 Tropic Software 71 East Inc<p> 72 Distributed under the Boost Software License, Version 1.0. (See accompanying 73 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>) 74 </p> 75</div></td> 76</tr></table> 77<hr> 78<div class="spirit-nav"> 79<a accesskey="p" href="boost/tti/valid_member_type.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="header/boost/tti/member_type_hpp.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="BOOST_TTI_MEMBER_TYPE.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 80</div> 81</body> 82</html> 83