blob: c5a01bf56d8fa7fb247ee8dbb652a562c5912da9 [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Categorizing a Type</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
<link rel="home" href="../../../index.html" title="Chapter&#160;1.&#160;Boost.TypeTraits">
<link rel="up" href="../value_traits.html" title="Type Traits that Describe the Properties of a Type">
<link rel="prev" href="../value_traits.html" title="Type Traits that Describe the Properties of a Type">
<link rel="next" href="properties.html" title="General Type Properties">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../value_traits.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../value_traits.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="properties.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_typetraits.category.value_traits.primary"></a><a class="link" href="primary.html" title="Categorizing a Type"> Categorizing
a Type</a>
</h4></div></div></div>
<p>
These traits identify what "kind" of type some type <code class="computeroutput"><span class="identifier">T</span></code> is. These are split into two groups:
primary traits which are all mutually exclusive, and composite traits that
are compositions of one or more primary traits.
</p>
<p>
For any given type, exactly one primary type trait will inherit from <a class="link" href="../../reference/integral_constant.html" title="integral_constant">true_type</a>,
and all the others will inherit from <a class="link" href="../../reference/integral_constant.html" title="integral_constant">false_type</a>,
in other words these traits are mutually exclusive.
</p>
<p>
This means that <code class="computeroutput"><a class="link" href="../../reference/is_integral.html" title="is_integral">is_integral</a><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">value</span></code>
and <code class="computeroutput"><a class="link" href="../../reference/is_floating_point.html" title="is_floating_point">is_floating_point</a><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">value</span></code>
will only ever be true for built-in types; if you want to check for a user-defined
class type that behaves "as if" it is an integral or floating
point type, then use the <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span>
<span class="keyword">template</span></code> instead.
</p>
<p>
<span class="bold"><strong>Synopsis:</strong></span>
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_array.html" title="is_array">is_array</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_class.html" title="is_class">is_class</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_complex.html" title="is_complex">is_complex</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_enum.html" title="is_enum">is_enum</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_floating_point.html" title="is_floating_point">is_floating_point</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_function.html" title="is_function">is_function</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_integral.html" title="is_integral">is_integral</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_member_function_pointer.html" title="is_member_function_pointer">is_member_function_pointer</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_member_object_pointer.html" title="is_member_object_pointer">is_member_object_pointer</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_pointer.html" title="is_pointer">is_pointer</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_lvalue_reference.html" title="is_lvalue_reference">is_lvalue_reference</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_rvalue_reference.html" title="is_rvalue_reference">is_rvalue_reference</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_union.html" title="is_union">is_union</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_void.html" title="is_void">is_void</a><span class="special">;</span>
</pre>
<p>
The following traits are made up of the union of one or more type categorizations.
A type may belong to more than one of these categories, in addition to
one of the primary categories.
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_arithmetic.html" title="is_arithmetic">is_arithmetic</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_compound.html" title="is_compound">is_compound</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_fundamental.html" title="is_fundamental">is_fundamental</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_member_pointer.html" title="is_member_pointer">is_member_pointer</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_object.html" title="is_object">is_object</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_reference.html" title="is_reference">is_reference</a><span class="special">;</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <a class="link" href="../../reference/is_scalar.html" title="is_scalar">is_scalar</a><span class="special">;</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2000, 2006 Adobe Systems Inc, David Abrahams,
Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat
Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert
Ramey and Jeremy Siek<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../value_traits.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../value_traits.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="properties.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>