1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>conversion_traits<> traits class</title> 5<link rel="stylesheet" href="../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. Boost.NumericConversion"> 8<link rel="up" href="../index.html" title="Chapter 1. Boost.NumericConversion"> 9<link rel="prev" href="bounds___traits_class.html" title="bounds<> traits class"> 10<link rel="next" href="numeric_converter_policy_classes.html" title="Numeric Converter Policy Classes"> 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="bounds___traits_class.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="numeric_converter_policy_classes.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_numericconversion.conversion_traits___traits_class"></a><a class="link" href="conversion_traits___traits_class.html" title="conversion_traits<> traits class">conversion_traits<> 28 traits class</a> 29</h2></div></div></div> 30<div class="toc"><dl class="toc"> 31<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types">Types</a></span></dt> 32<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.examples">Examples</a></span></dt> 33</dl></div> 34<div class="section"> 35<div class="titlepage"><div><div><h3 class="title"> 36<a name="boost_numericconversion.conversion_traits___traits_class.types"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types" title="Types">Types</a> 37</h3></div></div></div> 38<div class="toc"><dl class="toc"> 39<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_int_float_mixture_enum">enumeration 40 int_float_mixture_enum</a></span></dt> 41<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_sign_mixture_enum">enumeration 42 sign_mixture_enum</a></span></dt> 43<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_udt_builtin_mixture_enum">enumeration 44 udt_builtin_mixture_enum</a></span></dt> 45<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_int_float_mixture__">template 46 class int_float_mixture<></a></span></dt> 47<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_sign_mixture__">template 48 class sign_mixture<></a></span></dt> 49<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_udt_builtin_mixture__">template 50 class udt_builtin_mixture<></a></span></dt> 51<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_is_subranged__">template 52 class is_subranged<></a></span></dt> 53<dt><span class="section"><a href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_conversion_traits__">template 54 class conversion_traits<></a></span></dt> 55</dl></div> 56<div class="section"> 57<div class="titlepage"><div><div><h4 class="title"> 58<a name="boost_numericconversion.conversion_traits___traits_class.types.enumeration_int_float_mixture_enum"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_int_float_mixture_enum" title="enumeration int_float_mixture_enum">enumeration 59 int_float_mixture_enum</a> 60</h4></div></div></div> 61<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 62 63 <span class="keyword">enum</span> <span class="identifier">int_float_mixture_enum</span> 64 <span class="special">{</span> 65 <span class="identifier">integral_to_integral</span> 66 <span class="special">,</span><span class="identifier">integral_to_float</span> 67 <span class="special">,</span><span class="identifier">float_to_integral</span> 68 <span class="special">,</span><span class="identifier">float_to_float</span> 69 <span class="special">}</span> <span class="special">;</span> 70 71<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace boost::numeric</span> 72</pre> 73</div> 74<div class="section"> 75<div class="titlepage"><div><div><h4 class="title"> 76<a name="boost_numericconversion.conversion_traits___traits_class.types.enumeration_sign_mixture_enum"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_sign_mixture_enum" title="enumeration sign_mixture_enum">enumeration 77 sign_mixture_enum</a> 78</h4></div></div></div> 79<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 80 81<span class="keyword">enum</span> <span class="identifier">sign_mixture_enum</span> 82<span class="special">{</span> 83 <span class="identifier">unsigned_to_unsigned</span> 84 <span class="special">,</span><span class="identifier">signed_to_signed</span> 85 <span class="special">,</span><span class="identifier">signed_to_unsigned</span> 86 <span class="special">,</span><span class="identifier">unsigned_to_signed</span> 87<span class="special">}</span> <span class="special">;</span> 88 89<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace boost::numeric</span> 90</pre> 91</div> 92<div class="section"> 93<div class="titlepage"><div><div><h4 class="title"> 94<a name="boost_numericconversion.conversion_traits___traits_class.types.enumeration_udt_builtin_mixture_enum"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_udt_builtin_mixture_enum" title="enumeration udt_builtin_mixture_enum">enumeration 95 udt_builtin_mixture_enum</a> 96</h4></div></div></div> 97<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 98 99 <span class="keyword">enum</span> <span class="identifier">udt_builtin_mixture_enum</span> 100 <span class="special">{</span> 101 <span class="identifier">builtin_to_builtin</span> 102 <span class="special">,</span><span class="identifier">builtin_to_udt</span> 103 <span class="special">,</span><span class="identifier">udt_to_builtin</span> 104 <span class="special">,</span><span class="identifier">udt_to_udt</span> 105 <span class="special">}</span> <span class="special">;</span> 106 107<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace boost::numeric</span> 108</pre> 109</div> 110<div class="section"> 111<div class="titlepage"><div><div><h4 class="title"> 112<a name="boost_numericconversion.conversion_traits___traits_class.types.template_class_int_float_mixture__"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_int_float_mixture__" title="template class int_float_mixture<>">template 113 class int_float_mixture<></a> 114</h4></div></div></div> 115<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 116 117 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">S</span><span class="special">></span> 118 <span class="keyword">struct</span> <span class="identifier">int_float_mixture</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">int_float_mixture_enum</span><span class="special">,</span> <span class="identifier">impl</span><span class="special">-</span><span class="identifier">def</span><span class="special">-</span><span class="identifier">value</span><span class="special">></span> <span class="special">{}</span> <span class="special">;</span> 119 120<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace boost::numeric</span> 121</pre> 122<p> 123 Classifying <code class="computeroutput"><span class="identifier">S</span></code> and <code class="computeroutput"><span class="identifier">T</span></code> as either integral or float, this 124 <a href="../../../../../mpl/doc/refmanual/integral-constant.html" target="_top">MPL's 125 Integral Constant</a> indicates the combination of these attributes. 126 </p> 127<p> 128 Its <code class="computeroutput"><span class="special">::</span><span class="identifier">value</span></code> 129 is of enumeration type <a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_int_float_mixture_enum" title="enumeration int_float_mixture_enum"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">int_float_mixture_enum</span></code></a> 130 </p> 131</div> 132<div class="section"> 133<div class="titlepage"><div><div><h4 class="title"> 134<a name="boost_numericconversion.conversion_traits___traits_class.types.template_class_sign_mixture__"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_sign_mixture__" title="template class sign_mixture<>">template 135 class sign_mixture<></a> 136</h4></div></div></div> 137<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 138 139 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">S</span><span class="special">></span> 140 <span class="keyword">struct</span> <span class="identifier">sign_mixture</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">sign_mixture_enum</span><span class="special">,</span> <span class="identifier">impl</span><span class="special">-</span><span class="identifier">def</span><span class="special">-</span><span class="identifier">value</span><span class="special">></span> <span class="special">{}</span> <span class="special">;</span> 141 142<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace boost::numeric</span> 143</pre> 144<p> 145 Classifying <code class="computeroutput"><span class="identifier">S</span></code> and <code class="computeroutput"><span class="identifier">T</span></code> as either signed or unsigned, this 146 <a href="../../../../../mpl/doc/refmanual/integral-constant.html" target="_top">MPL's 147 Integral Constant</a> indicates the combination of these attributes. 148 </p> 149<p> 150 Its <code class="computeroutput"><span class="special">::</span><span class="identifier">value</span></code> 151 is of enumeration type <a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_sign_mixture_enum" title="enumeration sign_mixture_enum"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">sign_mixture_enum</span></code></a> 152 </p> 153</div> 154<div class="section"> 155<div class="titlepage"><div><div><h4 class="title"> 156<a name="boost_numericconversion.conversion_traits___traits_class.types.template_class_udt_builtin_mixture__"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_udt_builtin_mixture__" title="template class udt_builtin_mixture<>">template 157 class udt_builtin_mixture<></a> 158</h4></div></div></div> 159<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 160 161 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">S</span><span class="special">></span> 162 <span class="keyword">struct</span> <span class="identifier">udt_builtin_mixture</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">udt_builtin__mixture_enum</span><span class="special">,</span> <span class="identifier">impl</span><span class="special">-</span><span class="identifier">def</span><span class="special">-</span><span class="identifier">value</span><span class="special">></span> <span class="special">{}</span> <span class="special">;</span> 163 164<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace boost::numeric</span> 165</pre> 166<p> 167 Classifying <code class="computeroutput"><span class="identifier">S</span></code> and <code class="computeroutput"><span class="identifier">T</span></code> as either user-defined or builtin, 168 this <a href="../../../../../mpl/doc/refmanual/integral-constant.html" target="_top">MPL's 169 Integral Constant</a> indicates the combination of these attributes. 170 </p> 171<p> 172 Its <code class="computeroutput"><span class="special">::</span><span class="identifier">value</span></code> 173 is of enumeration type <a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.enumeration_udt_builtin_mixture_enum" title="enumeration udt_builtin_mixture_enum"><code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">udt_builtin_mixture_enum</span></code></a> 174 </p> 175</div> 176<div class="section"> 177<div class="titlepage"><div><div><h4 class="title"> 178<a name="boost_numericconversion.conversion_traits___traits_class.types.template_class_is_subranged__"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_is_subranged__" title="template class is_subranged<>">template 179 class is_subranged<></a> 180</h4></div></div></div> 181<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 182 183 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">S</span><span class="special">></span> 184 <span class="keyword">struct</span> <span class="identifier">is_subranged</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">bool_</span><span class="special"><</span><span class="identifier">impl</span><span class="special">-</span><span class="identifier">def</span><span class="special">-</span><span class="identifier">value</span><span class="special">></span> <span class="special">{}</span> <span class="special">;</span> 185 186<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace boost::numeric</span> 187</pre> 188<p> 189 Indicates if the range of the target type <code class="computeroutput"><span class="identifier">T</span></code> 190 is a subset of the range of the source type <code class="computeroutput"><span class="identifier">S</span></code>. 191 That is: if there are some source values which fall out of the Target type's 192 range. 193 </p> 194<p> 195 It is a boolean <a href="../../../../../mpl/doc/refmanual/integral-constant.html" target="_top">MPL's 196 Integral Constant</a> . 197 </p> 198<p> 199 It does not indicate if a particular conversion is effectively out of range; 200 it indicates that some conversion might be out of range because not all 201 the source values are representable as Target type. 202 </p> 203</div> 204<div class="section"> 205<div class="titlepage"><div><div><h4 class="title"> 206<a name="boost_numericconversion.conversion_traits___traits_class.types.template_class_conversion_traits__"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_conversion_traits__" title="template class conversion_traits<>">template 207 class conversion_traits<></a> 208</h4></div></div></div> 209<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">numeric</span> <span class="special">{</span> 210 211 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">S</span><span class="special">></span> 212 <span class="keyword">struct</span> <span class="identifier">conversion_traits</span> 213 <span class="special">{</span> 214 <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">int_float_mixture_enum</span> <span class="special">,</span> <span class="special">...></span> <span class="identifier">int_float_mixture</span> <span class="special">;</span> 215 <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">sign_mixture_enum</span> <span class="special">,</span> <span class="special">...></span> <span class="identifier">sign_mixture</span><span class="special">;</span> 216 <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">udt_builtin_mixture_enum</span><span class="special">,</span> <span class="special">...></span> <span class="identifier">udt_builtin_mixture</span> <span class="special">;</span> 217 218 <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">bool_</span><span class="special"><...></span> <span class="identifier">subranged</span> <span class="special">;</span> 219 <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">bool_</span><span class="special"><...></span> <span class="identifier">trivial</span> <span class="special">;</span> 220 221 <span class="keyword">typedef</span> <span class="identifier">T</span> <span class="identifier">target_type</span> <span class="special">;</span> 222 <span class="keyword">typedef</span> <span class="identifier">S</span> <span class="identifier">source_type</span> <span class="special">;</span> 223 <span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">argument_type</span> <span class="special">;</span> 224 <span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">result_type</span> <span class="special">;</span> 225 <span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">supertype</span> <span class="special">;</span> 226 <span class="keyword">typedef</span> <span class="special">...</span> <span class="identifier">subtype</span> <span class="special">;</span> 227 <span class="special">}</span> <span class="special">;</span> 228 229<span class="special">}</span> <span class="special">}</span> <span class="comment">// namespace numeric, namespace boost</span> 230</pre> 231<p> 232 This traits class indicates some properties of a <span class="emphasis"><em>numeric conversion</em></span> 233 direction: from a source type <code class="computeroutput"><span class="identifier">S</span></code> 234 to a target type <code class="computeroutput"><span class="identifier">T</span></code>. It 235 does not indicate the properties of a <span class="emphasis"><em>specific</em></span> conversion, 236 but of the conversion direction. See <a class="link" href="definitions.html#boost_numericconversion.definitions.subranged_conversion_direction__subtype_and_supertype" title="Subranged Conversion Direction, Subtype and Supertype">Definitions</a> 237 for details. 238 </p> 239<p> 240 The traits class provides the following <a href="../../../../../mpl/doc/refmanual/integral-constant.html" target="_top">MPL's 241 Integral Constant</a> \s of enumeration type. They express the combination 242 of certain attributes of the Source and Target types (thus they are call 243 mixture): 244 </p> 245<div class="informaltable"><table class="table"> 246<colgroup> 247<col> 248<col> 249</colgroup> 250<thead><tr> 251<th> 252 </th> 253<th> 254 </th> 255</tr></thead> 256<tbody> 257<tr> 258<td> 259 <p> 260 <span class="bold"><strong>int_float_mixture </strong></span> 261 </p> 262 </td> 263<td> 264 <p> 265 Same as given by the traits class <a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_int_float_mixture__" title="template class int_float_mixture<>">int_float_mixture</a> 266 </p> 267 </td> 268</tr> 269<tr> 270<td> 271 <p> 272 <span class="bold"><strong>sign_mixture </strong></span> 273 </p> 274 </td> 275<td> 276 <p> 277 Same as given by the traits class <a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_sign_mixture__" title="template class sign_mixture<>">sign_mixture</a> 278 </p> 279 </td> 280</tr> 281<tr> 282<td> 283 <p> 284 <span class="bold"><strong>udt_builtin_mixture </strong></span> 285 </p> 286 </td> 287<td> 288 <p> 289 Same as given by the traits class <a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_udt_builtin_mixture__" title="template class udt_builtin_mixture<>">udt_builtin_mixture</a> 290 </p> 291 </td> 292</tr> 293</tbody> 294</table></div> 295<p> 296 The traits class provides the following <a href="../../../../../mpl/doc/refmanual/integral-constant.html" target="_top">MPL's 297 Integral Constant</a> \s of boolean type which indicates indirectly 298 the relation between the Source and Target ranges (see <a class="link" href="definitions.html#boost_numericconversion.definitions.range_and_precision" title="Range and Precision">Definitions</a> 299 for details). 300 </p> 301<div class="informaltable"><table class="table"> 302<colgroup> 303<col> 304<col> 305</colgroup> 306<thead><tr> 307<th> 308 </th> 309<th> 310 </th> 311</tr></thead> 312<tbody> 313<tr> 314<td> 315 <p> 316 subranged 317 </p> 318 </td> 319<td> 320 <p> 321 Same as given by <a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.types.template_class_is_subranged__" title="template class is_subranged<>">is_subranged</a> 322 </p> 323 </td> 324</tr> 325<tr> 326<td> 327 <p> 328 trivial 329 </p> 330 </td> 331<td> 332 <p> 333 Indicates if both Source and Target, <span class="underline">without 334 cv-qualifications</span>, are the same type. 335 </p> 336 <p> 337 Its <code class="computeroutput"><span class="special">::</span><span class="identifier">value</span></code> 338 is of boolean type. 339 </p> 340 </td> 341</tr> 342</tbody> 343</table></div> 344<p> 345 The traits class provides the following types. They are the Source and 346 Target types classified and qualified for different purposes. 347 </p> 348<div class="informaltable"><table class="table"> 349<colgroup> 350<col> 351<col> 352</colgroup> 353<thead><tr> 354<th> 355 </th> 356<th> 357 </th> 358</tr></thead> 359<tbody> 360<tr> 361<td> 362 <p> 363 <span class="bold"><strong>target_type</strong></span> 364 </p> 365 </td> 366<td> 367 <p> 368 The template parameter <code class="computeroutput"><span class="identifier">T</span></code> 369 without cv-qualifications 370 </p> 371 </td> 372</tr> 373<tr> 374<td> 375 <p> 376 <span class="bold"><strong>source_type</strong></span> 377 </p> 378 </td> 379<td> 380 <p> 381 The template parameter <code class="computeroutput"><span class="identifier">S</span></code> 382 without cv-qualifications 383 </p> 384 </td> 385</tr> 386<tr> 387<td> 388 <p> 389 <span class="bold"><strong>argument_type</strong></span> 390 </p> 391 </td> 392<td> 393 <p> 394 This type is either source_type or <code class="computeroutput"><span class="identifier">source_type</span> 395 <span class="keyword">const</span><span class="special">&</span></code>. 396 </p> 397 <p> 398 It represents the optimal argument type for the <a class="link" href="converter___function_object.html" title="converter<> function object">converter</a> 399 member functions. 400 </p> 401 <p> 402 If S is a built-in type, this is <code class="computeroutput"><span class="identifier">source_type</span></code>, 403 otherwise, this is <code class="computeroutput"><span class="identifier">source_type</span> 404 <span class="keyword">const</span><span class="special">&</span></code>. 405 </p> 406 </td> 407</tr> 408<tr> 409<td> 410 <p> 411 <span class="bold"><strong>result_type</strong></span> 412 </p> 413 </td> 414<td> 415 <p> 416 This type is either target_type or target_type const& 417 </p> 418 <p> 419 It represents the return type of the <a class="link" href="converter___function_object.html" title="converter<> function object">converter</a> 420 member functions. 421 </p> 422 <p> 423 If <code class="computeroutput"><span class="identifier">T</span><span class="special">==</span><span class="identifier">S</span></code>, it is <code class="computeroutput"><span class="identifier">target_type</span> 424 <span class="keyword">const</span><span class="special">&</span></code>, 425 otherwise, it is <code class="computeroutput"><span class="identifier">target_type</span></code>. 426 </p> 427 </td> 428</tr> 429<tr> 430<td> 431 <p> 432 <span class="bold"><strong>supertype</strong></span> 433 </p> 434 </td> 435<td> 436 <p> 437 If the conversion is subranged, it is <code class="computeroutput"><span class="identifier">source_type</span></code>, 438 otherwise, it is <code class="computeroutput"><span class="identifier">target_type</span></code> 439 </p> 440 </td> 441</tr> 442<tr> 443<td> 444 <p> 445 <span class="bold"><strong>subtype</strong></span> 446 </p> 447 </td> 448<td> 449 <p> 450 If the conversion is subranged, it is <code class="computeroutput"><span class="identifier">target_type</span></code>, 451 otherwise, it is <code class="computeroutput"><span class="identifier">source_type</span></code> 452 </p> 453 </td> 454</tr> 455</tbody> 456</table></div> 457</div> 458</div> 459<div class="section"> 460<div class="titlepage"><div><div><h3 class="title"> 461<a name="boost_numericconversion.conversion_traits___traits_class.examples"></a><a class="link" href="conversion_traits___traits_class.html#boost_numericconversion.conversion_traits___traits_class.examples" title="Examples">Examples</a> 462</h3></div></div></div> 463<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> 464<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">typeinfo</span><span class="special">></span> 465<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">numeric</span><span class="special">/</span><span class="identifier">conversion</span><span class="special">/</span><span class="identifier">conversion_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 466 467<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 468<span class="special">{</span> 469 470 <span class="comment">// A trivial conversion.</span> 471 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">conversion_traits</span><span class="special"><</span><span class="keyword">short</span><span class="special">,</span><span class="keyword">short</span><span class="special">></span> <span class="identifier">Short2Short_Traits</span> <span class="special">;</span> 472 <span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">Short2Short_Traits</span><span class="special">::</span><span class="identifier">trivial</span><span class="special">::</span><span class="identifier">value</span> <span class="special">)</span> <span class="special">;</span> 473 474 <span class="comment">// A subranged conversion.</span> 475 <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">conversion_traits</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">></span> <span class="identifier">UInt2Double_Traits</span> <span class="special">;</span> 476 <span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">UInt2Double_Traits</span><span class="special">::</span><span class="identifier">int_float_mixture</span><span class="special">::</span><span class="identifier">value</span> <span class="special">==</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">integral_to_float</span> <span class="special">)</span> <span class="special">;</span> 477 <span class="identifier">assert</span> <span class="special">(</span> <span class="identifier">UInt2Double_Traits</span><span class="special">::</span><span class="identifier">sign_mixture</span><span class="special">::</span><span class="identifier">value</span> <span class="special">==</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">unsigned_to_signed</span> <span class="special">)</span> <span class="special">;</span> 478 <span class="identifier">assert</span> <span class="special">(</span> <span class="special">!</span><span class="identifier">UInt2Double_Traits</span><span class="special">::</span><span class="identifier">subranged</span><span class="special">::</span><span class="identifier">value</span> <span class="special">)</span> <span class="special">;</span> 479 <span class="identifier">assert</span> <span class="special">(</span> <span class="keyword">typeid</span><span class="special">(</span><span class="identifier">UInt2Double_Traits</span><span class="special">::</span><span class="identifier">supertype</span><span class="special">)</span> <span class="special">==</span> <span class="keyword">typeid</span><span class="special">(</span><span class="keyword">double</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span> 480 <span class="identifier">assert</span> <span class="special">(</span> <span class="keyword">typeid</span><span class="special">(</span><span class="identifier">UInt2Double_Traits</span><span class="special">::</span><span class="identifier">subtype</span><span class="special">)</span> <span class="special">==</span> <span class="keyword">typeid</span><span class="special">(</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">)</span> <span class="special">)</span> <span class="special">;</span> 481 482 <span class="comment">// A doubly subranged conversion.</span> 483 <span class="identifier">assert</span> <span class="special">(</span> <span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">conversion_traits</span><span class="special"><</span><span class="keyword">short</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">short</span><span class="special">>::</span><span class="identifier">subranged</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span> <span class="special">);</span> 484 <span class="identifier">assert</span> <span class="special">(</span> <span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">numeric</span><span class="special">::</span><span class="identifier">conversion_traits</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">short</span><span class="special">,</span> <span class="keyword">short</span><span class="special">>::</span><span class="identifier">subranged</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span> <span class="special">);</span> 485 486 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 487<span class="special">}</span> 488</pre> 489</div> 490</div> 491<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 492<td align="left"></td> 493<td align="right"><div class="copyright-footer">Copyright © 2004-2007 Fernando 494 Luis Cacciola Carballal<p> 495 Distributed under the Boost Software License, Version 1.0. (See accompanying 496 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>) 497 </p> 498</div></td> 499</tr></table> 500<hr> 501<div class="spirit-nav"> 502<a accesskey="p" href="bounds___traits_class.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="numeric_converter_policy_classes.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 503</div> 504</body> 505</html> 506