mirror of
https://github.com/boostorg/auto_index.git
synced 2025-05-09 15:14:03 +00:00
6671 lines
520 KiB
XML
6671 lines
520 KiB
XML
<?xml version="1.0"?>
|
|
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
|
<!--
|
|
|
|
This file is based upon the type traits docs, but has had additional XML elements added to it
|
|
to ensure complete testing.
|
|
|
|
-->
|
|
|
|
<chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="boost_typetraits" rev:last-revision="$Date: 2008-11-28 12:41:45 +0000 (Fri, 28 Nov 2008) $">
|
|
<chapterinfo><author>
|
|
<firstname>various</firstname> <surname>authors</surname>
|
|
</author><copyright>
|
|
<year>2000</year> <year>2006</year> <holder>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</holder>
|
|
</copyright><legalnotice>
|
|
<para>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>)
|
|
</para>
|
|
</legalnotice></chapterinfo>
|
|
<title>Boost.TypeTraits</title>
|
|
<para>
|
|
A printer-friendly <ulink url="http://svn.boost.org/svn/boost/sandbox/pdf/type_traits/release/type_traits.pdf">PDF
|
|
version of this manual is also available</ulink>.
|
|
</para>
|
|
<section id="boost_typetraits.intro"><indexterm type="test_index_1"><primary>type-traits</primary><secondary>Introduction</secondary></indexterm><indexterm><primary>Introduction</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_1"><primary>type-traits</primary><secondary>Introduction</secondary></indexterm><indexterm><primary>Introduction</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_1"><primary>type-traits</primary><secondary>Introduction</secondary></indexterm><indexterm><primary>Introduction</primary><secondary>type-traits</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.intro"> Introduction</link></title>
|
|
<para>
|
|
The Boost type-traits library contains a set of very specific traits classes,
|
|
each of which encapsulate a single trait from the C++ type system; for example,
|
|
is a type a pointer or a reference type? Or does a type have a trivial constructor,
|
|
or a const-qualifier?
|
|
</para>
|
|
<para>
|
|
The type-traits classes share a unified design: each class inherits from a
|
|
the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link>
|
|
if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>
|
|
otherwise.
|
|
</para>
|
|
<para>
|
|
The type-traits library also contains a set of classes that perform a specific
|
|
transformation on a type; for example, they can remove a top-level const or
|
|
volatile qualifier from a type. Each class that performs a transformation defines
|
|
a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
that is the result of the transformation.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.background"><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="class_name"><primary>remove_extent</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>remove_extent</secondary></indexterm><indexterm type="class_name"><primary>is_pointer</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>is_pointer</secondary></indexterm><indexterm type="class_name"><primary>is_void</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>is_void</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.background"> Background and Tutorial</link></title>
|
|
<para>
|
|
The following is an updated version of the article "C++ Type traits"
|
|
by John Maddock and Steve Cleary that appeared in the October 2000 issue of
|
|
<ulink url="http://www.ddj.com">Dr Dobb's Journal</ulink>.
|
|
</para>
|
|
<para>
|
|
Generic programming (writing code which works with any data type meeting a
|
|
set of requirements) has become the method of choice for providing reusable
|
|
code. However, there are times in generic programming when "generic"
|
|
just isn't good enough - sometimes the differences between types are too large
|
|
for an efficient generic implementation. This is when the traits technique
|
|
becomes important - by encapsulating those properties that need to be considered
|
|
on a type by type basis inside a traits class, we can minimize the amount of
|
|
code that has to differ from one type to another, and maximize the amount of
|
|
generic code.
|
|
</para>
|
|
<?dbfo keep-together="auto" ?>
|
|
<para>
|
|
<indexterm>
|
|
<primary>Foo1</primary>
|
|
</indexterm>
|
|
Consider an example: when working with character strings, one common operation
|
|
is to determine the length of a null terminated string. Clearly it's possible
|
|
to write generic code that can do this, but it turns out that there are much
|
|
more efficient methods available: for example, the C library functions <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">strlen</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">wcslen</phrase></computeroutput>
|
|
are usually written in assembler, and with suitable hardware support can be
|
|
considerably faster than a generic version written in C++. The authors of the
|
|
C++ standard library realized this, and abstracted the properties of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">wchar_t</phrase></computeroutput>
|
|
into the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput>.
|
|
Generic code that works with character strings can simply use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase><phrase role="special"><>::</phrase><phrase role="identifier">length</phrase></computeroutput> to determine the length of a null
|
|
terminated string, safe in the knowledge that specializations of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> will use the most appropriate
|
|
method available to them.
|
|
</para>
|
|
<anchor id="boost_typetraits.background.type_traits"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.type_traits">Type Traits</link>
|
|
</bridgehead>
|
|
<para>
|
|
Class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> is a classic
|
|
example of a collection of type specific properties wrapped up in a single
|
|
class - what Nathan Myers termed a <emphasis>baggage class</emphasis><link linkend="background.references">[1]</link>. In the Boost type-traits library,
|
|
we<link linkend="background.references">[2]</link> have written a set of very
|
|
specific traits classes, each of which encapsulate a single trait from the
|
|
C++ type system; for example, is a type a pointer or a reference type? Or does
|
|
a type have a trivial constructor, or a const-qualifier? The type-traits classes
|
|
share a unified design: each class inherits from a the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link>
|
|
if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>
|
|
otherwise. As we will show, these classes can be used in generic programming
|
|
to determine the properties of a given type and introduce optimizations that
|
|
are appropriate for that case.
|
|
</para>
|
|
<para>
|
|
The type-traits library also contains a set of classes that perform a specific
|
|
transformation on a type; for example, they can remove a top-level const or
|
|
volatile qualifier from a type. Each class that performs a transformation defines
|
|
a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
that is the result of the transformation. All of the type-traits classes are
|
|
defined inside namespace <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase></computeroutput>;
|
|
for brevity, namespace-qualification is omitted in most of the code samples
|
|
given.
|
|
</para>
|
|
<anchor id="boost_typetraits.background.implementation"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.implementation">Implementation</link>
|
|
</bridgehead>
|
|
<para>
|
|
There are far too many separate classes contained in the type-traits library
|
|
to give a full implementation here - see the source code in the Boost library
|
|
for the full details - however, most of the implementation is fairly repetitive
|
|
anyway, so here we will just give you a flavor for how some of the classes
|
|
are implemented. Beginning with possibly the simplest class in the library,
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput> inherits
|
|
from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>
|
|
only if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>.
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
Here we define a primary version of the template class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_void">is_void</link></computeroutput>,
|
|
and provide a full-specialization when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. While full specialization
|
|
of a template class is an important technique, sometimes we need a solution
|
|
that is halfway between a fully generic solution, and a full specialization.
|
|
This is exactly the situation for which the standards committee defined partial
|
|
template-class specialization. As an example, consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>:
|
|
here we needed a primary version that handles all the cases where T is not
|
|
a pointer, and a partial specialization to handle all the cases where T is
|
|
a pointer:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">*></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
The syntax for partial specialization is somewhat arcane and could easily occupy
|
|
an article in its own right; like full specialization, in order to write a
|
|
partial specialization for a class, you must first declare the primary template.
|
|
The partial specialization contains an extra <...> after the class name
|
|
that contains the partial specialization parameters; these define the types
|
|
that will bind to that partial specialization rather than the default template.
|
|
The rules for what can appear in a partial specialization are somewhat convoluted,
|
|
but as a rule of thumb if you can legally write two function overloads of the
|
|
form:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">);</phrase>
|
|
<phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">U</phrase><phrase role="special">);</phrase>
|
|
</programlisting>
|
|
<para>
|
|
Then you can also write a partial specialization of the form:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special">{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
This rule is by no means foolproof, but it is reasonably simple to remember
|
|
and close enough to the actual rule to be useful for everyday use.
|
|
</para>
|
|
<para>
|
|
As a more complex example of partial specialization consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>. This
|
|
class defines a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
that is the same type as T but with any top-level array bounds removed; this
|
|
is an example of a traits class that performs a transformation on a type:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link>
|
|
<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">N</phrase><phrase role="special">]></phrase>
|
|
<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
The aim of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput>
|
|
is this: imagine a generic algorithm that is passed an array type as a template
|
|
parameter, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput>
|
|
provides a means of determining the underlying type of the array. For example
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">][</phrase><phrase role="number">5</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> would evaluate to the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">5</phrase><phrase role="special">]</phrase></computeroutput>. This example also shows that the number of
|
|
template parameters in a partial specialization does not have to match the
|
|
number in the default template. However, the number of parameters that appear
|
|
after the class name do have to match the number and type of the parameters
|
|
in the default template.
|
|
</para>
|
|
<anchor id="boost_typetraits.background.optimized_copy"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.optimized_copy">Optimized copy</link>
|
|
</bridgehead>
|
|
<para>
|
|
As an example of how the type traits classes can be used, consider the standard
|
|
library algorithm copy:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Iter2</phrase><phrase role="special">></phrase>
|
|
<phrase role="identifier">Iter2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter2</phrase> <phrase role="identifier">out</phrase><phrase role="special">);</phrase>
|
|
</programlisting>
|
|
<para>
|
|
Obviously, there's no problem writing a generic version of copy that works
|
|
for all iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput>
|
|
and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput>; however, there are
|
|
some circumstances when the copy operation can best be performed by a call
|
|
to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. In order to implement
|
|
copy in terms of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> all
|
|
of the following conditions need to be met:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
Both of the iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput>
|
|
and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must be pointers.
|
|
</listitem>
|
|
<listitem>
|
|
Both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must point to the same type - excluding
|
|
const and volatile-qualifiers.
|
|
</listitem>
|
|
<listitem>
|
|
The type pointed to by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput>
|
|
must have a trivial assignment operator.
|
|
</listitem>
|
|
</itemizedlist>
|
|
<para>
|
|
By trivial assignment operator we mean that the type is either a scalar type<link linkend="background.references">[3]</link> or:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
The type has no user defined assignment operator.
|
|
</listitem>
|
|
<listitem>
|
|
The type does not have any data members that are references.
|
|
</listitem>
|
|
<listitem>
|
|
All base classes, and all data member objects must have trivial assignment
|
|
operators.
|
|
</listitem>
|
|
</itemizedlist>
|
|
<para>
|
|
If all these conditions are met then a type can be copied using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> rather than using a compiler generated
|
|
assignment operator. The type-traits library provides a class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput>,
|
|
such that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is true only if T has a trivial assignment
|
|
operator. This class "just works" for scalar types, but has to be
|
|
explicitly specialised for class/struct types that also happen to have a trivial
|
|
assignment operator. In other words if <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link>
|
|
gives the wrong answer, it will give the "safe" wrong answer - that
|
|
trivial assignment is not allowable.
|
|
</para>
|
|
<para>
|
|
The code for an optimized version of copy that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>
|
|
where appropriate is given in <link linkend="boost_typetraits.examples.copy">the
|
|
examples</link>. The code begins by defining a template function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">do_copy</phrase></computeroutput> that performs a "slow but safe"
|
|
copy. The last parameter passed to this function may be either a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>
|
|
or a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput>.
|
|
Following that there is an overload of do<emphasis role="underline">copy that
|
|
uses `memcpy`: this time the iterators are required to actually be pointers
|
|
to the same type, and the final parameter must be a `</emphasis>_true_type<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase> <phrase role="identifier">Finally</phrase><phrase role="special">,</phrase> <phrase role="identifier">the</phrase> <phrase role="identifier">version</phrase>
|
|
<phrase role="identifier">of</phrase> </computeroutput>copy<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="identifier">calls</phrase>
|
|
</computeroutput>do<emphasis role="underline">copy`, passing `</emphasis>_has_trivial_assign<value_type>()`
|
|
as the final parameter: this will dispatch to the optimized version where appropriate,
|
|
otherwise it will call the "slow but safe version".
|
|
</para>
|
|
<anchor id="boost_typetraits.background.was_it_worth_it_"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.was_it_worth_it_">Was it worth it?</link>
|
|
</bridgehead>
|
|
<para>
|
|
It has often been repeated in these columns that "premature optimization
|
|
is the root of all evil" <link linkend="background.references">[4]</link>.
|
|
So the question must be asked: was our optimization premature? To put this
|
|
in perspective the timings for our version of copy compared a conventional
|
|
generic copy<link linkend="background.references">[5]</link> are shown in table
|
|
1.
|
|
</para>
|
|
<para>
|
|
Clearly the optimization makes a difference in this case; but, to be fair,
|
|
the timings are loaded to exclude cache miss effects - without this accurate
|
|
comparison between algorithms becomes difficult. However, perhaps we can add
|
|
a couple of caveats to the premature optimization rule:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
If you use the right algorithm for the job in the first place then optimization
|
|
will not be required; in some cases, memcpy is the right algorithm.
|
|
</listitem>
|
|
<listitem>
|
|
If a component is going to be reused in many places by many people then optimizations
|
|
may well be worthwhile where they would not be so for a single case - in
|
|
other words, the likelihood that the optimization will be absolutely necessary
|
|
somewhere, sometime is that much higher. Just as importantly the perceived
|
|
value of the stock implementation will be higher: there is no point standardizing
|
|
an algorithm if users reject it on the grounds that there are better, more
|
|
heavily optimized versions available.
|
|
</listitem>
|
|
</itemizedlist>
|
|
<table frame="all"> <title>Time taken to copy 1000 elements using `copy<const
|
|
T*, T*>` (times in micro-seconds)</title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Version
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
T
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Time
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
"Optimized" copy
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
char
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
0.99
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Conventional copy
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
char
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
8.07
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
"Optimized" copy
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
int
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
2.52
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Conventional copy
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
int
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
8.02
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table> <anchor id="boost_typetraits.background.pair_of_references"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.pair_of_references">Pair of References</link>
|
|
</bridgehead>
|
|
<para>
|
|
The optimized copy example shows how type traits may be used to perform optimization
|
|
decisions at compile-time. Another important usage of type traits is to allow
|
|
code to compile that otherwise would not do so unless excessive partial specialization
|
|
is used. This is possible by delegating partial specialization to the type
|
|
traits classes. Our example for this form of usage is a pair that can hold
|
|
references <link linkend="background.references">[6]</link>.
|
|
</para>
|
|
<para>
|
|
First, let us examine the definition of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput>, omitting
|
|
the comparison operators, default constructor, and template copy constructor
|
|
for simplicity:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
Now, this "pair" cannot hold references as it currently stands, because
|
|
the constructor would require taking a reference to a reference, which is currently
|
|
illegal <link linkend="background.references">[7]</link>. Let us consider what
|
|
the constructor's parameters would have to be in order to allow "pair"
|
|
to hold non-reference types, references, and constant references:
|
|
</para>
|
|
<table frame="all"> <title>Required Constructor Argument Types</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Type of parameter to initializing constructor
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
T
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
const T &
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
T &
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
T &
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
const T &
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
const T &
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
<para>
|
|
A little familiarity with the type traits classes allows us to construct a
|
|
single mapping that allows us to determine the type of parameter from the type
|
|
of the contained class. The type traits classes provide a transformation <link linkend="boost_typetraits.reference.add_reference">add_reference</link>, which
|
|
adds a reference to its type, unless it is already a reference.
|
|
</para>
|
|
<table frame="all"> <title>Using add_reference to synthesize the correct constructor
|
|
type</title>
|
|
<tgroup cols="3">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
T
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
const T
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
const T &
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
T &
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
T & [8]
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
T &
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
const T &
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
const T &
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
const T &
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
<para>
|
|
This allows us to build a primary template definition for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput>
|
|
that can contain non-reference types, reference types, and constant reference
|
|
types:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase>
|
|
<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
Add back in the standard comparison operators, default constructor, and template
|
|
copy constructor (which are all the same), and you have a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput> that
|
|
can hold reference types!
|
|
</para>
|
|
<para>
|
|
This same extension could have been done using partial template specialization
|
|
of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput>, but to specialize
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> in this way would require
|
|
three partial specializations, plus the primary template. Type traits allows
|
|
us to define a single primary template that adjusts itself auto-magically to
|
|
any of these partial specializations, instead of a brute-force partial specialization
|
|
approach. Using type traits in this fashion allows programmers to delegate
|
|
partial specialization to the type traits classes, resulting in code that is
|
|
easier to maintain and easier to understand.
|
|
</para>
|
|
<anchor id="boost_typetraits.background.conclusion"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.conclusion">Conclusion</link>
|
|
</bridgehead>
|
|
<para>
|
|
We hope that in this article we have been able to give you some idea of what
|
|
type-traits are all about. A more complete listing of the available classes
|
|
are in the boost documentation, along with further examples using type traits.
|
|
Templates have enabled C++ uses to take the advantage of the code reuse that
|
|
generic programming brings; hopefully this article has shown that generic programming
|
|
does not have to sink to the lowest common denominator, and that templates
|
|
can be optimal as well as generic.
|
|
</para>
|
|
<anchor id="boost_typetraits.background.acknowledgements"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.acknowledgements">Acknowledgements</link>
|
|
</bridgehead>
|
|
<para>
|
|
The authors would like to thank Beman Dawes and Howard Hinnant for their helpful
|
|
comments when preparing this article.
|
|
</para>
|
|
<anchor id="background.references"/> <anchor id="boost_typetraits.background.references"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.background.references">References</link>
|
|
</bridgehead>
|
|
<orderedlist inheritnum="ignore" continuation="restarts">
|
|
<listitem>
|
|
Nathan C. Myers, C++ Report, June 1995.
|
|
</listitem>
|
|
<listitem>
|
|
The type traits library is based upon contributions by Steve Cleary, Beman
|
|
Dawes, Howard Hinnant and John Maddock: it can be found at www.boost.org.
|
|
</listitem>
|
|
<listitem>
|
|
A scalar type is an arithmetic type (i.e. a built-in integer or floating
|
|
point type), an enumeration type, a pointer, a pointer to member, or a const-
|
|
or volatile-qualified version of one of these types.
|
|
</listitem>
|
|
<listitem>
|
|
This quote is from Donald Knuth, ACM Computing Surveys, December 1974, pg
|
|
268.
|
|
</listitem>
|
|
<listitem>
|
|
The test code is available as part of the boost utility library (see algo_opt_examples.cpp),
|
|
the code was compiled with gcc 2.95 with all optimisations turned on, tests
|
|
were conducted on a 400MHz Pentium II machine running Microsoft Windows 98.
|
|
</listitem>
|
|
<listitem>
|
|
John Maddock and Howard Hinnant have submitted a "compressed_pair"
|
|
library to Boost, which uses a technique similar to the one described here
|
|
to hold references. Their pair also uses type traits to determine if any
|
|
of the types are empty, and will derive instead of contain to conserve space
|
|
-- hence the name "compressed".
|
|
</listitem>
|
|
<listitem>
|
|
This is actually an issue with the C++ Core Language Working Group (issue
|
|
#106), submitted by Bjarne Stroustrup. The tentative resolution is to allow
|
|
a "reference to a reference to T" to mean the same thing as a "reference
|
|
to T", but only in template instantiation, in a method similar to multiple
|
|
cv-qualifiers.
|
|
</listitem>
|
|
<listitem>
|
|
For those of you who are wondering why this shouldn't be const-qualified,
|
|
remember that references are always implicitly constant (for example, you
|
|
can't re-assign a reference). Remember also that "const T &"
|
|
is something completely different. For this reason, cv-qualifiers on template
|
|
type arguments that are references are ignored.
|
|
</listitem>
|
|
</orderedlist>
|
|
</section>
|
|
<section id="boost_typetraits.category">
|
|
<title><link linkend="boost_typetraits.category"> Type Traits by Category</link></title>
|
|
<section id="boost_typetraits.category.value_traits">
|
|
<title><link linkend="boost_typetraits.category.value_traits"> Type Traits
|
|
that Describe the Properties of a Type</link></title>
|
|
<para>
|
|
<indexterm>
|
|
<primary>Foo2</primary>
|
|
<secondary>Bar2</secondary>
|
|
</indexterm>
|
|
These traits are all <emphasis>value traits</emphasis>, which is to say the
|
|
traits classes all inherit from <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link>,
|
|
and are used to access some numerical property of a type. Often this is a
|
|
simple true or false Boolean value, but in a few cases may be some other
|
|
integer value (for example when dealing with type alignments, or array bounds:
|
|
see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.alignment_of">alignment_of</link></computeroutput>,
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.rank">rank</link></computeroutput>
|
|
and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.extent">extent</link></computeroutput>).
|
|
</para>
|
|
<section id="boost_typetraits.category.value_traits.primary">
|
|
<title><link linkend="boost_typetraits.category.value_traits.primary"> Categorizing
|
|
a Type</link></title>
|
|
<para>
|
|
These traits identify what "kind" of type some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> 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.
|
|
</para>
|
|
<para>
|
|
For any given type, exactly one primary type trait will inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
and all the others will inherit from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>,
|
|
in other words these traits are mutually exclusive.
|
|
</para>
|
|
<para>
|
|
This means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
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 <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase>
|
|
<phrase role="keyword">template</phrase></computeroutput> instead.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Synopsis:</emphasis>
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_array">is_array</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_complex">is_complex</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_enum">is_enum</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
<para>
|
|
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.
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_arithmetic">is_arithmetic</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_compound">is_compound</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_object">is_object</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_scalar">is_scalar</link><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.category.value_traits.properties">
|
|
<title><link linkend="boost_typetraits.category.value_traits.properties">
|
|
General Type Properties</link></title>
|
|
<para>
|
|
The following templates describe the general properties of a type.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Synopsis:</emphasis>
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.alignment_of">alignment_of</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_default_constructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy_constructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_default_constructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy_constructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_abstract">is_abstract</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_const">is_const</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_empty">is_empty</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_signed">is_signed</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_unsigned">is_unsigned</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_volatile">is_volatile</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.extent">extent</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.category.value_traits.relate">
|
|
<title><link linkend="boost_typetraits.category.value_traits.relate"> Relationships
|
|
Between Two Types</link></title>
|
|
<para>
|
|
These templates determine the whether there is a relationship between two
|
|
types:
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Synopsis:</emphasis>
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_base_of">is_base_of</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
</section>
|
|
</section>
|
|
<section id="boost_typetraits.category.transform"><indexterm type="macro_name"><primary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</primary><secondary>Type Traits that Transform One Type to Another</secondary></indexterm><indexterm><primary>Type Traits that Transform One Type to Another</primary><secondary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</primary><secondary>Type Traits that Transform One Type to Another</secondary></indexterm><indexterm><primary>Type Traits that Transform One Type to Another</primary><secondary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.category.transform"> Type Traits that
|
|
Transform One Type to Another</link></title>
|
|
<para>
|
|
The following templates transform one type to another, based upon some well-defined
|
|
rule. Each template has a single member called <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
that is the result of applying the transformation to the template argument
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Synopsis:</emphasis>
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_const">add_const</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_cv">add_cv</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_pointer">add_pointer</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_volatile">add_volatile</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.decay">decay</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_signed">make_signed</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_unsigned">make_unsigned</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.promote">promote</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_all_extents">remove_all_extents</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_const">remove_const</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_cv">remove_cv</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_reference">remove_reference</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_volatile">remove_volatile</link><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
<anchor id="boost_typetraits.category.transform.broken_compiler_workarounds_"/>
|
|
<bridgehead renderas="sect4">
|
|
<link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">Broken
|
|
Compiler Workarounds:</link>
|
|
</bridgehead>
|
|
<para>
|
|
For all of these templates support for partial specialization of class templates
|
|
is required to correctly implement the transformation. On the other hand,
|
|
practice shows that many of the templates from this category are very useful,
|
|
and often essential for implementing some generic libraries. Lack of these
|
|
templates is often one of the major limiting factors in porting those libraries
|
|
to compilers that do not yet support this language feature. As some of these
|
|
compilers are going to be around for a while, and at least one of them is
|
|
very wide-spread, it was decided that the library should provide workarounds
|
|
where possible.
|
|
</para>
|
|
<para>
|
|
The basic idea behind the workaround is to manually define full specializations
|
|
of all type transformation templates for all fundamental types, and all their
|
|
1st and 2nd rank cv-[un]qualified derivative pointer types, and to provide
|
|
a user-level macro that will define all the explicit specializations needed
|
|
for any user-defined type T.
|
|
</para>
|
|
<para>
|
|
The first part guarantees the successful compilation of something like this:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="special">...</phrase>
|
|
<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
</programlisting>
|
|
<para>
|
|
and the second part provides the library's users with a mechanism to make
|
|
the above code work not only for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>,
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> or other built-in type,
|
|
but for their own types as well:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">myspace</phrase><phrase role="special">{</phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">MyClass</phrase> <phrase role="special">{};</phrase>
|
|
<phrase role="special">}</phrase>
|
|
<phrase role="comment">// declare this at global scope:
|
|
</phrase><phrase role="identifier">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase><phrase role="special">(</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">)</phrase>
|
|
<phrase role="comment">// transformations on myspace::MyClass now work:
|
|
</phrase><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase>
|
|
<phrase role="comment">// etc.
|
|
</phrase></programlisting>
|
|
<para>
|
|
Note that the macro BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION evaluates
|
|
to nothing on those compilers that <emphasis role="bold">do</emphasis> support
|
|
partial specialization.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.category.alignment">
|
|
<title><link linkend="boost_typetraits.category.alignment"> Synthesizing Types
|
|
with Specific Alignments</link></title>
|
|
<para>
|
|
Some low level memory management routines need to synthesize a POD type with
|
|
specific alignment properties. The template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link></computeroutput>
|
|
finds the smallest type with a specified alignment, while template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link></computeroutput>
|
|
creates a type with a specific size and alignment.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Synopsis</emphasis>
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.category.function">
|
|
<title><link linkend="boost_typetraits.category.function"> Decomposing Function
|
|
Types</link></title>
|
|
<para>
|
|
The class template <link linkend="boost_typetraits.reference.function_traits">function_traits</link>
|
|
extracts information from function types (see also <link linkend="boost_typetraits.reference.is_function">is_function</link>).
|
|
This traits class allows you to tell how many arguments a function takes,
|
|
what those argument types are, and what the return type is.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Synopsis</emphasis>
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.function_traits">function_traits</link><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
</section>
|
|
</section>
|
|
<section id="boost_typetraits.user_defined"><indexterm type="class_name"><primary>is_union</primary><secondary>User Defined Specializations</secondary></indexterm><indexterm><primary>User Defined Specializations</primary><secondary>is_union</secondary></indexterm><indexterm type="class_name"><primary>is_class</primary><secondary>User Defined Specializations</secondary></indexterm><indexterm><primary>User Defined Specializations</primary><secondary>is_class</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.user_defined"> User Defined Specializations</link></title>
|
|
<para>
|
|
Occationally the end user may need to provide their own specialization for
|
|
one of the type traits - typically where intrinsic compiler support is required
|
|
to implement a specific trait fully. These specializations should derive from
|
|
boost::<link linkend="boost_typetraits.reference.integral_constant">true_type</link>
|
|
or boost::<link linkend="boost_typetraits.reference.integral_constant">false_type</link>
|
|
as appropriate:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase>
|
|
<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase>
|
|
<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase>
|
|
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">my_pod</phrase><phrase role="special">{};</phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">my_union</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">char</phrase> <phrase role="identifier">c</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
|
|
<phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">template</phrase><phrase role="special"><></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_pod</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase><phrase role="special"><></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase><phrase role="special"><></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase><phrase role="special"><></phrase>
|
|
<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase>
|
|
<phrase role="special">}</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.intrinsics"><indexterm type="macro_name"><primary>BOOST_IS_UNION</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_UNION</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_POLYMORPHIC</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_POLYMORPHIC</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_POD</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_POD</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_ENUM</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_ENUM</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_EMPTY</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_EMPTY</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_CONVERTIBLE</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_CONVERTIBLE</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_CLASS</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_CLASS</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_BASE_OF</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_BASE_OF</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_ABSTRACT</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_ABSTRACT</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_VIRTUAL_DESTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_VIRTUAL_DESTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_DESTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_DESTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_COPY</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_COPY</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_CONSTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_CONSTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_ASSIGN</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_ASSIGN</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_NOTHROW_COPY</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_NOTHROW_COPY</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_NOTHROW_CONSTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_NOTHROW_CONSTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_NOTHROW_ASSIGN</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_NOTHROW_ASSIGN</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_ALIGNMENT_OF</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_ALIGNMENT_OF</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.intrinsics"> Support for Compiler Intrinsics</link></title>
|
|
<para>
|
|
There are some traits that can not be implemented within the current C++ language:
|
|
to make these traits "just work" with user defined types, some kind
|
|
of additional help from the compiler is required. Currently (April 2008) Visual
|
|
C++ 8 and 9, GNU GCC 4.3 and MWCW 9 provide the necessary intrinsics, and other
|
|
compilers will no doubt follow in due course.
|
|
</para>
|
|
<para>
|
|
The Following traits classes always need compiler support to do the right thing
|
|
for all types (but all have safe fallback positions if this support is unavailable):
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.is_union">is_union</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.is_pod">is_pod</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link>
|
|
</listitem>
|
|
</itemizedlist>
|
|
<para>
|
|
The following traits classes can't be portably implemented in the C++ language,
|
|
although in practice, the implementations do in fact do the right thing on
|
|
all the compilers we know about:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.is_empty">is_empty</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link>
|
|
</listitem>
|
|
</itemizedlist>
|
|
<para>
|
|
The following traits classes are dependent on one or more of the above:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.is_class">is_class</link>
|
|
</listitem>
|
|
<listitem>
|
|
<link linkend="boost_typetraits.reference.is_stateless">is_stateless</link>
|
|
</listitem>
|
|
</itemizedlist>
|
|
<para>
|
|
The hooks for compiler-intrinsic support are defined in <ulink url="../../../../boost/type_traits/intrinsics.hpp">boost/type_traits/intrinsics.hpp</ulink>,
|
|
adding support for new compilers is simply a matter of defining one of more
|
|
of the following macros:
|
|
</para>
|
|
<table frame="all"> <title>Macros for Compiler Intrinsics</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_UNION(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is a union type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_POD(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is a POD type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_EMPTY(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is an empty struct or union
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if the default constructor for T is trivial (i.e.
|
|
has no effect)
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_TRIVIAL_COPY(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T has a trivial copy constructor (and can
|
|
therefore be replaced by a call to memcpy)
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_TRIVIAL_ASSIGN(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T has a trivial assignment operator (and can
|
|
therefore be replaced by a call to memcpy)
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_TRIVIAL_DESTRUCTOR(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T has a trivial destructor (i.e. ~T() has
|
|
no effect)
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_NOTHROW_CONSTRUCTOR(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase>
|
|
<phrase role="identifier">x</phrase><phrase role="special">;</phrase></computeroutput>
|
|
can not throw
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_NOTHROW_COPY(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">(</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput> can not throw
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_NOTHROW_ASSIGN(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase>
|
|
<phrase role="identifier">t</phrase><phrase role="special">,</phrase>
|
|
<phrase role="identifier">u</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">t</phrase> <phrase role="special">=</phrase>
|
|
<phrase role="identifier">u</phrase></computeroutput> can not throw
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_HAS_VIRTUAL_DESTRUCTOR(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true T has a virtual destructor
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_ABSTRACT(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is an abstract type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_BASE_OF(T,U)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is a base class of U
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_CLASS(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is a class type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_CONVERTIBLE(T,U)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is convertible to U
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_ENUM(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true is T is an enum
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_IS_POLYMORPHIC(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to true if T is a polymorphic type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
BOOST_ALIGNMENT_OF(T)
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Should evaluate to the alignment requirements of type T.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.mpl">
|
|
<title><link linkend="boost_typetraits.mpl"> MPL Interoperability</link></title>
|
|
<para>
|
|
All the value based traits in this library conform to MPL's requirements for
|
|
an <ulink url="../../../../libs/mpl/doc/refmanual/integral-constant.html">Integral
|
|
Constant type</ulink>: that includes a number of rather intrusive workarounds
|
|
for broken compilers.
|
|
</para>
|
|
<para>
|
|
Purely as an implementation detail, this means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>
|
|
inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">true_</phrase></computeroutput></ulink>,
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput>
|
|
inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">false_</phrase></computeroutput></ulink>,
|
|
and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase>
|
|
<phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <ulink url="../../../../libs/mpl/doc/refmanual/integral-c.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">integral_c</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput></ulink>
|
|
(provided <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>)
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.examples">
|
|
<title><link linkend="boost_typetraits.examples"> Examples</link></title>
|
|
<section id="boost_typetraits.examples.copy"><indexterm type="typedef_name"><primary>value_type</primary><secondary>An Optimized Version of std::copy</secondary></indexterm><indexterm><primary>Optimized Version of std::copy</primary><secondary>value_type</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.examples.copy"> An Optimized Version
|
|
of std::copy</link></title>
|
|
<para>
|
|
Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">copy</phrase></computeroutput>
|
|
that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput>
|
|
to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>
|
|
to optimise the copy operation (see <ulink url="../../examples/copy_example.cpp">copy_example.cpp</ulink>):
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">//
|
|
</phrase><phrase role="comment">// opt::copy
|
|
</phrase><phrase role="comment">// same semantics as std::copy
|
|
</phrase><phrase role="comment">// calls memcpy where appropriate.
|
|
</phrase><phrase role="comment">//
|
|
</phrase>
|
|
<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase>
|
|
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase>
|
|
<phrase role="identifier">I2</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="special">*</phrase><phrase role="identifier">out</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">++</phrase><phrase role="identifier">out</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">}</phrase>
|
|
<phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="identifier">memcpy</phrase><phrase role="special">(</phrase><phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">)*</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">));</phrase>
|
|
<phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">+(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase>
|
|
<phrase role="special">}</phrase>
|
|
|
|
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">inline</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="comment">//
|
|
</phrase> <phrase role="comment">// We can copy with memcpy if T has a trivial assignment operator,
|
|
</phrase> <phrase role="comment">// and if the iterator arguments are actually pointers (this last
|
|
</phrase> <phrase role="comment">// requirement we detect with overload resolution):
|
|
</phrase> <phrase role="comment">//
|
|
</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">return</phrase> <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">value_type</phrase><phrase role="special">>());</phrase>
|
|
<phrase role="special">}</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.examples.fill">
|
|
<title><link linkend="boost_typetraits.examples.fill"> An Optimised Version
|
|
of std::fill</link></title>
|
|
<para>
|
|
Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">fill</phrase></computeroutput>
|
|
that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput>
|
|
to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memset</phrase></computeroutput>
|
|
to optimise the fill operation (see <ulink url="../../examples/fill_example.cpp">fill_example.cpp</ulink>):
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">//
|
|
</phrase><phrase role="comment">// fill
|
|
</phrase><phrase role="comment">// same as std::fill, but uses memset where appropriate
|
|
</phrase><phrase role="comment">//
|
|
</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="special">*</phrase><phrase role="identifier">first</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">}</phrase>
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memset</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase>
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="comment">//
|
|
</phrase> <phrase role="comment">// We can do an optimised fill if T has a trivial assignment
|
|
</phrase> <phrase role="comment">// operator and if it's size is one:
|
|
</phrase> <phrase role="comment">//
|
|
</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase>
|
|
<phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> <phrase role="special">&&</phrase> <phrase role="special">(</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">)></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase>
|
|
<phrase role="special">}</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.examples.destruct">
|
|
<title><link linkend="boost_typetraits.examples.destruct"> An Example that
|
|
Omits Destructor Calls For Types with Trivial Destructors</link></title>
|
|
<para>
|
|
Demonstrates a simple algorithm that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__has_trivial_destruct</phrase></computeroutput>
|
|
to determine whether to destructors need to be called (see <ulink url="../../examples/trivial_destructor_example.cpp">trivial_destructor_example.cpp</ulink>):
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">//
|
|
</phrase><phrase role="comment">// algorithm destroy_array:
|
|
</phrase><phrase role="comment">// The reverse of std::unitialized_copy, takes a block of
|
|
</phrase><phrase role="comment">// initialized memory and calls destructors on all objects therein.
|
|
</phrase><phrase role="comment">//
|
|
</phrase>
|
|
<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="identifier">first</phrase><phrase role="special">->~</phrase><phrase role="identifier">T</phrase><phrase role="special">();</phrase>
|
|
<phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">}</phrase>
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="special">}</phrase> <phrase role="comment">// namespace detail
|
|
</phrase>
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p2</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">p2</phrase><phrase role="special">,</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>());</phrase>
|
|
<phrase role="special">}</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.examples.iter">
|
|
<title><link linkend="boost_typetraits.examples.iter"> An improved Version
|
|
of std::iter_swap</link></title>
|
|
<para>
|
|
Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput>
|
|
that use type traits to determine whether an it's arguments are proxying
|
|
iterators or not, if they're not then it just does a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase></computeroutput>
|
|
of it's dereferenced arguments (the same as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput>
|
|
does), however if they are proxying iterators then takes special care over
|
|
the swap to ensure that the algorithm works correctly for both proxying iterators,
|
|
and even iterators of different types (see <ulink url="../../examples/iter_swap_example.cpp">iter_swap_example.cpp</ulink>):
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">//
|
|
</phrase><phrase role="comment">// iter_swap:
|
|
</phrase><phrase role="comment">// tests whether iterator is a proxying iterator or not, and
|
|
</phrase><phrase role="comment">// uses optimal form accordingly:
|
|
</phrase><phrase role="comment">//
|
|
</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">v_t</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">v_t</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">one</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">*</phrase><phrase role="identifier">one</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">*</phrase><phrase role="identifier">two</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">}</phrase>
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">using</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase><phrase role="special">;</phrase>
|
|
<phrase role="identifier">swap</phrase><phrase role="special">(*</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">);</phrase>
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="special">}</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">iter_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">two</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="comment">//
|
|
</phrase> <phrase role="comment">// See is both arguments are non-proxying iterators,
|
|
</phrase> <phrase role="comment">// and if both iterator the same type:
|
|
</phrase> <phrase role="comment">//
|
|
</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r1_t</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I2</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase>
|
|
<phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase>
|
|
|
|
<phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase>
|
|
<phrase role="special">}</phrase>
|
|
</programlisting>
|
|
</section>
|
|
<section id="boost_typetraits.examples.to_double">
|
|
<title><link linkend="boost_typetraits.examples.to_double"> Convert Numeric
|
|
Types and Enums to double</link></title>
|
|
<para>
|
|
Demonstrates a conversion of <ulink url="../../../../libs/numeric/conversion/doc/html/boost_numericconversion/definitions.html#boost_numericconversion.definitions.numeric_types">Numeric
|
|
Types</ulink> and enum types to double:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">inline</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">to_double</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">promoted</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric</phrase><phrase role="special">::</phrase><phrase role="identifier">converter</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase><phrase role="identifier">promoted</phrase><phrase role="special">>::</phrase><phrase role="identifier">convert</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase>
|
|
<phrase role="special">}</phrase>
|
|
</programlisting>
|
|
</section>
|
|
</section>
|
|
<section id="boost_typetraits.reference">
|
|
<title><link linkend="boost_typetraits.reference"> Alphabetical Reference</link></title>
|
|
<section id="boost_typetraits.reference.add_const"><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm><indexterm type="class_name"><primary>add_const</primary><secondary>add_const</secondary></indexterm><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.add_const"> add_const</link></title>
|
|
<indexterm type="class_name">
|
|
<primary>one</primary>
|
|
<secondary>two</secondary>
|
|
</indexterm>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase>
|
|
<phrase role="keyword">const</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase>
|
|
<phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.add_cv"><indexterm type="class_name"><primary>add_cv</primary><secondary>add_cv</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.add_cv"> add_cv</link></title>
|
|
<indexterm type="class_name">
|
|
<primary>one</primary>
|
|
<secondary>two</secondary>
|
|
<tertiary>three</tertiary>
|
|
</indexterm>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_cv</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase>
|
|
<phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
|
|
for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase>
|
|
<phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase>
|
|
<phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase>
|
|
<phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.add_pointer"><indexterm type="class_name"><primary>add_pointer</primary><secondary>add_pointer</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.add_pointer"> add_pointer</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_pointer</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">*</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
The rationale for this template is that it produces the same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">TYPEOF</phrase><phrase role="special">(&</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput>, where
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t</phrase></computeroutput> is an object of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.add_reference"><indexterm type="class_name"><primary>add_reference</primary><secondary>add_reference</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.add_reference"> add_reference</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_reference</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
is not a reference type then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">&</phrase></computeroutput>, otherwise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.add_volatile"><indexterm type="class_name"><primary>add_volatile</primary><secondary>add_volatile</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.add_volatile"> add_volatile</link></title>
|
|
<indexterm type="class_name">
|
|
<primary>one</primary>
|
|
</indexterm>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase>
|
|
<phrase role="keyword">volatile</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase>
|
|
<phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase>
|
|
<phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.aligned_storage"><indexterm type="class_name"><primary>aligned_storage</primary><secondary>aligned_storage</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.aligned_storage"> aligned_storage</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">aligned_storage</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> a built-in or POD type with size
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Size</phrase></computeroutput> and an alignment that
|
|
is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">aligned_storage</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.alignment_of"><indexterm type="class_name"><primary>integral_constant</primary><secondary>alignment_of</secondary></indexterm><indexterm><primary>alignment_of</primary><secondary>integral_constant</secondary></indexterm><indexterm type="class_name"><primary>alignment_of</primary><secondary>alignment_of</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.alignment_of"> alignment_of</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">alignment_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> Class template alignment<emphasis role="underline">of inherits from `</emphasis>_integral_constant<std::size_t,
|
|
ALIGNOF(T)><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">,</phrase> <phrase role="identifier">where</phrase>
|
|
</computeroutput>ALIGNOF(T)` is the alignment of type T.
|
|
</para>
|
|
<para>
|
|
<emphasis>Note: strictly speaking you should only rely on the value of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> being
|
|
a multiple of the true alignment of T, although in practice it does compute
|
|
the correct value in all the cases we know about.</emphasis>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">alignment_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase><phrase role="special">)></phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
with value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.decay"><indexterm type="class_name"><primary>decay</primary><secondary>decay</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.decay"> decay</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">decay</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> Let <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>
|
|
be the result of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>, then if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>
|
|
is an array type, the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>*</phrase></computeroutput>,
|
|
otherwise if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> is a function
|
|
type then the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase><phrase role="special">*</phrase></computeroutput>, otherwise the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">decay</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.extent"><indexterm type="class_name"><primary>integral_constant</primary><secondary>extent</secondary></indexterm><indexterm><primary>extent</primary><secondary>integral_constant</secondary></indexterm><indexterm type="class_name"><primary>extent</primary><secondary>extent</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.extent"> extent</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">extent</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> Class template extent inherits
|
|
from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase></computeroutput>,
|
|
where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is the number of elements in the N'th array
|
|
dimention of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type,
|
|
or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">N</phrase> <phrase role="special">></phrase>
|
|
<link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>, or if the N'th array bound is incomplete,
|
|
then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is zero.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">],</phrase>
|
|
<phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>4</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>0</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">],</phrase> <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>2</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>0</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.floating_point_promotion"><indexterm type="class_name"><primary>floating_point_promotion</primary><secondary>floating_point_promotion</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.floating_point_promotion">
|
|
floating_point_promotion</link></title>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">floating_point_promotion</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If floating point promotion can be
|
|
applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
then applies floating point promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 4.6.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">floating_point_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase>
|
|
<phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">float</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.function_traits"><indexterm type="typedef_name"><primary>result_type</primary><secondary>function_traits</secondary></indexterm><indexterm><primary>function_traits</primary><secondary>result_type</secondary></indexterm><indexterm type="class_name"><primary>function_traits</primary><secondary>function_traits</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.function_traits"> function_traits</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">F</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">function_traits</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">arity</phrase> <phrase role="special">=</phrase> <replaceable>see-below</replaceable><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">result_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> arg<replaceable>N</replaceable>_type<phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
The class template function_traits will only compile if:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
The compiler supports partial specialization of class templates.
|
|
</listitem>
|
|
<listitem>
|
|
The template argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>
|
|
is a <emphasis>function type</emphasis>, note that this <emphasis><emphasis role="bold">is not</emphasis></emphasis> the same thing as a <emphasis>pointer
|
|
to a function</emphasis>.
|
|
</listitem>
|
|
</itemizedlist>
|
|
<tip>
|
|
<para>
|
|
function_traits is intended to introspect only C++ functions of the form
|
|
R (), R( A1 ), R ( A1, ... etc. ) and not function pointers or class member
|
|
functions. To convert a function pointer type to a suitable type use <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link>.
|
|
</para>
|
|
</tip>
|
|
<table frame="all"> <title>Function Traits Members</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Member
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Description
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">arity</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
An integral constant expression that gives the number of arguments
|
|
accepted by the function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">result_type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
The type returned by function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase>arg<replaceable>N</replaceable>_type</computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
The <replaceable>N</replaceable>th argument type of function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>,
|
|
where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase> <phrase role="special"><=</phrase>
|
|
<phrase role="identifier">N</phrase> <phrase role="special"><=</phrase>
|
|
<phrase role="identifier">arity</phrase></computeroutput> of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table> <table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
An integral constant expression that has the value 0.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
An integral constant expression that has the value 1.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arity</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
An integral constant expression that has the value 4.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">long</phrase></computeroutput>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arg1_type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg4_type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase><phrase role="special">*</phrase></computeroutput>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg5_type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
A compiler error: there is no <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">arg5_type</phrase></computeroutput>
|
|
since there are only four arguments.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
A compiler error: argument type is a <emphasis>function pointer</emphasis>,
|
|
and not a <emphasis>function type</emphasis>.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_nothrow_assign"><indexterm type="class_name"><primary>has_nothrow_assign</primary><secondary>has_nothrow_assign</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_nothrow_assign"> has_nothrow_assign</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a non-throwing assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete
|
|
type.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_assign</phrase></computeroutput>
|
|
will never report that a class or struct has a non-throwing assignment-operator;
|
|
this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual
|
|
C++ 8 has the necessary compiler support to ensure that this trait "just
|
|
works".
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_nothrow_constructor"><indexterm type="class_name"><primary>has_nothrow_default_constructor</primary><secondary>has_nothrow_constructor</secondary></indexterm><indexterm><primary>has_nothrow_constructor</primary><secondary>has_nothrow_default_constructor</secondary></indexterm><indexterm type="class_name"><primary>has_nothrow_constructor</primary><secondary>has_nothrow_constructor</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_nothrow_constructor">
|
|
has_nothrow_constructor</link></title>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a non-throwing default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete
|
|
type.
|
|
</para>
|
|
<para>
|
|
These two traits are synonyms for each other.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_constructor</phrase></computeroutput>
|
|
will never report that a class or struct has a non-throwing default-constructor;
|
|
this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual
|
|
C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to ensure that this trait "just works".
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_nothrow_copy"><indexterm type="class_name"><primary>has_nothrow_copy_constructor</primary><secondary>has_nothrow_copy</secondary></indexterm><indexterm><primary>has_nothrow_copy</primary><secondary>has_nothrow_copy_constructor</secondary></indexterm><indexterm type="class_name"><primary>has_nothrow_copy</primary><secondary>has_nothrow_copy</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_nothrow_copy"> has_nothrow_copy</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a non-throwing copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete
|
|
type.
|
|
</para>
|
|
<para>
|
|
These two traits are synonyms for each other.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_copy</phrase></computeroutput>
|
|
will never report that a class or struct has a non-throwing copy-constructor;
|
|
this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual
|
|
C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to ensure that this trait "just works".
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_nothrow_cp_cons">
|
|
<title><link linkend="boost_typetraits.reference.has_nothrow_cp_cons"> has_nothrow_copy_constructor</link></title>
|
|
<para>
|
|
See <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link>.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_no_throw_def_cons">
|
|
<title><link linkend="boost_typetraits.reference.has_no_throw_def_cons"> has_nothrow_default_constructor</link></title>
|
|
<para>
|
|
See <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link>.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_trivial_assign"><indexterm type="class_name"><primary>has_trivial_assign</primary><secondary>has_trivial_assign</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_trivial_assign"> has_trivial_assign</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a trivial assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
If a type has a trivial assignment-operator then the operator has the same
|
|
effect as copying the bits of one object to the other: calls to the operator
|
|
can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, has_trivial_assign
|
|
will never report that a user-defined class or struct has a trivial constructor;
|
|
this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW
|
|
9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to detect user-defined classes with trivial constructors.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p11.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_trivial_constructor"><indexterm type="class_name"><primary>has_trivial_default_constructor</primary><secondary>has_trivial_constructor</secondary></indexterm><indexterm><primary>has_trivial_constructor</primary><secondary>has_trivial_default_constructor</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_trivial_constructor">
|
|
has_trivial_constructor</link></title>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a trivial default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
These two traits are synonyms for each other.
|
|
</para>
|
|
<para>
|
|
If a type has a trivial default-constructor then the constructor have no
|
|
effect: calls to the constructor can be safely omitted. Note that using meta-programming
|
|
to omit a call to a single trivial-constructor call is of no benefit whatsoever.
|
|
However, if loops and/or exception handling code can also be omitted, then
|
|
some benefit in terms of code size and speed can be obtained.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, has_trivial_constructor
|
|
will never report that a user-defined class or struct has a trivial constructor;
|
|
this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW
|
|
9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to detect user-defined classes with trivial constructors.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 12.1p6.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_trivial_copy"><indexterm type="class_name"><primary>has_trivial_copy_constructor</primary><secondary>has_trivial_copy</secondary></indexterm><indexterm><primary>has_trivial_copy</primary><secondary>has_trivial_copy_constructor</secondary></indexterm><indexterm type="class_name"><primary>has_trivial_copy</primary><secondary>has_trivial_copy</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_trivial_copy"> has_trivial_copy</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
|
|
<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a trivial copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
These two traits are synonyms for each other.
|
|
</para>
|
|
<para>
|
|
If a type has a trivial copy-constructor then the constructor has the same
|
|
effect as copying the bits of one object to the other: calls to the constructor
|
|
can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, has_trivial_copy
|
|
will never report that a user-defined class or struct has a trivial constructor;
|
|
this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW
|
|
9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to detect user-defined classes with trivial constructors.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p6.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_trivial_cp_cons">
|
|
<title><link linkend="boost_typetraits.reference.has_trivial_cp_cons"> has_trivial_copy_constructor</link></title>
|
|
<para>
|
|
See <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link>.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_trivial_def_cons">
|
|
<title><link linkend="boost_typetraits.reference.has_trivial_def_cons"> has_trivial_default_constructor</link></title>
|
|
<para>
|
|
See <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link>.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_trivial_destructor"><indexterm type="class_name"><primary>has_trivial_destructor</primary><secondary>has_trivial_destructor</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_trivial_destructor"> has_trivial_destructor</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a trivial destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
If a type has a trivial destructor then the destructor has no effect: calls
|
|
to the destructor can be safely omitted. Note that using meta-programming
|
|
to omit a call to a single trivial-constructor call is of no benefit whatsoever.
|
|
However, if loops and/or exception handling code can also be omitted, then
|
|
some benefit in terms of code size and speed can be obtained.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, has_trivial_destructor
|
|
will never report that a user-defined class or struct has a trivial destructor;
|
|
this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW
|
|
9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to detect user-defined classes with trivial constructors.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 12.4p3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.has_virtual_destructor"><indexterm type="class_name"><primary>has_virtual_destructor</primary><secondary>has_virtual_destructor</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.has_virtual_destructor"> has_virtual_destructor</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">has_virtual_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
type with a virtual destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> This trait is provided
|
|
for completeness, since it's part of the Technical Report on C++ Library
|
|
Extensions. However, there is currently no way to portably implement this
|
|
trait. The default version provided always inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>,
|
|
and has to be explicitly specialized for types with virtual destructors unless
|
|
the compiler used has compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
that enable the trait to do the right thing: currently (May 2005) only Visual
|
|
C++ 8 and GCC-4.3 have the necessary <link linkend="boost_typetraits.intrinsics">intrinsics</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 12.4.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_virtual_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.integral_constant"><indexterm type="typedef_name"><primary>value_type</primary><secondary>integral_constant</secondary></indexterm><indexterm><primary>integral_constant</primary><secondary>value_type</secondary></indexterm><indexterm type="typedef_name"><primary>true_type</primary><secondary>integral_constant</secondary></indexterm><indexterm><primary>integral_constant</primary><secondary>true_type</secondary></indexterm><indexterm type="class_name"><primary>integral_constant</primary><secondary>integral_constant</secondary></indexterm><indexterm type="typedef_name"><primary>false_type</primary><secondary>integral_constant</secondary></indexterm><indexterm><primary>integral_constant</primary><secondary>false_type</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.integral_constant"> integral_constant</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_constant</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">></phrase> <phrase role="identifier">true_type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">false</phrase><phrase role="special">></phrase> <phrase role="identifier">false_type</phrase><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
<para>
|
|
Class template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_constant</phrase></computeroutput>
|
|
is the common base class for all the value-based type traits. The two typedef's
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">true_type</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">false_type</phrase></computeroutput> are provided for convenience:
|
|
most of the value traits are Boolean properties and so will inherit from
|
|
one of these.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.integral_promotion"><indexterm type="class_name"><primary>integral_promotion</primary><secondary>integral_promotion</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.integral_promotion"> integral_promotion</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_promotion</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If integral promotion can be applied
|
|
to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, then
|
|
applies integral promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3
|
|
(integral bit-field).
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">integral_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase>
|
|
<phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">enum</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">float_round_style</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_abstract"><indexterm type="class_name"><primary>is_abstract</primary><secondary>is_abstract</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_abstract"> is_abstract</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_abstract</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
abstract type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 10.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_abstract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> The compiler must
|
|
support DR337 (as of April 2005: GCC 3.4, VC++ 7.1 (and later), Intel C++
|
|
7 (and later), and Comeau 4.3.2). Otherwise behaves the same as <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link>;
|
|
this is the "safe fallback position" for which polymorphic types
|
|
are always regarded as potentially abstract. The macro BOOST_NO_IS_ABSTRACT
|
|
is used to signify that the implementation is buggy, users should check for
|
|
this in their own code if the "safe fallback" is not suitable for
|
|
their particular use-case.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">abc</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">abc</phrase><phrase role="special">()</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase></computeroutput>
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_arithmetic"><indexterm type="class_name"><primary>is_arithmetic</primary><secondary>is_arithmetic</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_arithmetic"> is_arithmetic</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_arithmetic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
arithmetic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Arithmetic types include integral and floating point types (see also <link linkend="boost_typetraits.reference.is_integral">is_integral</link> and
|
|
<link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link>).
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_arithmetic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_array"><indexterm type="class_name"><primary>is_array</primary><secondary>is_array</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_array"> is_array</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_array</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
array type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.4.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_array</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can give the wrong result with function types.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_base_of"><indexterm type="class_name"><primary>is_base_of</primary><secondary>is_base_of</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_base_of"> is_base_of</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_base_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If Base is base class of type
|
|
Derived or if both types are the same then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
This template will detect non-public base classes, and ambiguous base classes.
|
|
</para>
|
|
<para>
|
|
Note that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">X</phrase><phrase role="special">,</phrase><phrase role="identifier">X</phrase><phrase role="special">></phrase></computeroutput> will always inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>.
|
|
<emphasis role="bold">This is the case even if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">X</phrase></computeroutput>
|
|
is not a class type</emphasis>. This is a change in behaviour from Boost-1.33
|
|
in order to track the Technical Report on C++ Library Extensions.
|
|
</para>
|
|
<para>
|
|
Types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput> must not be incomplete types.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 10.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_base_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types. There are some older compilers which
|
|
will produce compiler errors if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput>
|
|
is a private base class of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>,
|
|
or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> is an ambiguous
|
|
base of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>. These compilers
|
|
include Borland C++, older versions of Sun Forte C++, Digital Mars C++, and
|
|
older versions of EDG based compilers.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase> <phrase role="special">:</phrase>
|
|
<phrase role="keyword">public</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase></computeroutput>
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Base</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>: a class is regarded as it's
|
|
own base.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_class"><indexterm type="class_name"><primary>is_class</primary><secondary>is_class</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_class"> is_class</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_class</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
class type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as
|
|
yet unspecified) help from the compiler, we cannot distinguish between union
|
|
and class types, as a result this type will erroneously inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> for
|
|
union types. See also <link linkend="boost_typetraits.reference.is_union">is_union</link>.
|
|
Currently (May 2005) only Visual C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to correctly identify union types, and therefore make is_class function correctly.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">MyClass</phrase><phrase role="special">;</phrase></computeroutput> then:
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_complex"><indexterm type="class_name"><primary>is_complex</primary><secondary>is_complex</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_complex"> is_complex</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_complex</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
is a complex number type then true (of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">complex</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">></phrase></computeroutput>
|
|
for some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>), otherwise
|
|
false.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 26.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_complex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_compound"><indexterm type="class_name"><primary>is_compound</primary><secondary>is_compound</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_compound"> is_compound</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_compound</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
compound type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Any type that is not a fundamental type is a compound type (see also <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link>).
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_compound</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyEnum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_const"><indexterm type="class_name"><primary>is_const</primary><secondary>is_const</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_const"> is_const</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_const</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (top level) const-qualified
|
|
type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>:
|
|
the const-qualifier is not at the top level in this case.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>:
|
|
the const-qualifier is not at the top level in this case.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_convertible"><indexterm type="class_name"><primary>is_convertible</primary><secondary>is_convertible</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_convertible"> is_convertible</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_convertible</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If an imaginary lvalue of type
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> is convertible to type
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
Type From must not be an incomplete type.
|
|
</para>
|
|
<para>
|
|
Type To must not be an incomplete, or function type.
|
|
</para>
|
|
<para>
|
|
No types are considered to be convertible to array types or abstract-class
|
|
types.
|
|
</para>
|
|
<para>
|
|
This template can not detect whether a converting-constructor is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> or not: if type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput>
|
|
has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> converting constructor
|
|
from type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> then instantiating
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase></computeroutput>
|
|
will produce a compiler error. For this reason <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase></computeroutput>
|
|
can not be used to determine whether a type has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput>
|
|
copy-constructor or not.
|
|
</para>
|
|
<para>
|
|
This template will also produce compiler errors if the conversion is ambiguous,
|
|
for example:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">B</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">C</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">D</phrase> <phrase role="special">:</phrase> <phrase role="identifier">B</phrase><phrase role="special">,</phrase> <phrase role="identifier">C</phrase> <phrase role="special">{};</phrase>
|
|
<phrase role="comment">// This produces a compiler error, the conversion is ambiguous:
|
|
</phrase><phrase role="keyword">bool</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">D</phrase><phrase role="special">*,</phrase><phrase role="identifier">A</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase><phrase role="special">;</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 4 and 8.5.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> This template is
|
|
currently broken with Borland C++ Builder 5 (and earlier), for constructor-based
|
|
conversions, and for the Metrowerks 7 (and earlier) compiler in all cases.
|
|
If the compiler does not support <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_abstract">is_abstract</link></computeroutput>,
|
|
then the template parameter <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput>
|
|
must not be an abstract type.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>:
|
|
the conversion would require a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const_cast</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&,</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_empty"><indexterm type="class_name"><primary>is_empty</primary><secondary>is_empty</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_empty"> is_empty</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_empty</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is an empty class type then
|
|
inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 10p5.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> In order to correctly
|
|
detect empty classes this trait relies on either:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
the compiler implementing zero sized empty base classes, or
|
|
</listitem>
|
|
<listitem>
|
|
the compiler providing <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to detect empty classes.
|
|
</listitem>
|
|
</itemizedlist>
|
|
<para>
|
|
Can not be used with incomplete types.
|
|
</para>
|
|
<para>
|
|
Can not be used with union types, until is_union can be made to work.
|
|
</para>
|
|
<para>
|
|
If the compiler does not support partial-specialization of class templates,
|
|
then this template can not be used with abstract types.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">empty_class</phrase>
|
|
<phrase role="special">{};</phrase></computeroutput>
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_enum"><indexterm type="class_name"><primary>is_enum</primary><secondary>is_enum</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_enum"> is_enum</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_enum</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
enum type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 7.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_enum</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> Requires a correctly
|
|
functioning <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link>
|
|
template; this means that is_enum is currently broken under Borland C++ Builder
|
|
5, and for the Metrowerks compiler prior to version 8, other compilers should
|
|
handle this template just fine.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">enum</phrase> <phrase role="identifier">my_enum</phrase>
|
|
<phrase role="special">{</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase> <phrase role="special">};</phrase></computeroutput>
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_floating_point"><indexterm type="class_name"><primary>is_floating_point</primary><secondary>is_floating_point</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_floating_point"> is_floating_point</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_floating_point</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
floating point type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_floating_point</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_function"><indexterm type="class_name"><primary>is_function</primary><secondary>is_function</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_function"> is_function</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_function</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
function type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Note that this template does not detect <emphasis>pointers to functions</emphasis>,
|
|
or <emphasis>references to functions</emphasis>, these are detected by <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> and <link linkend="boost_typetraits.reference.is_reference">is_reference</link> respectively:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">f1</phrase><phrase role="special">();</phrase> <phrase role="comment">// f1 is of function type.
|
|
</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f2</phrase><phrase role="special">*)();</phrase> <phrase role="comment">// f2 is a pointer to a function.
|
|
</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f3</phrase><phrase role="special">&)();</phrase> <phrase role="comment">// f3 is a reference to a function.
|
|
</phrase></programlisting>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p1 and 8.3.5.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_function</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>: the argument in this case
|
|
is a pointer type, not a function type.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>: the argument in this case
|
|
is a reference to a function, not a function type.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>: the argument in this case
|
|
is a pointer to a member function.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<tip>
|
|
<para>
|
|
Don't confuse function-types with pointers to functions:
|
|
</para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase>
|
|
<phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">);</phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
defines a function type,
|
|
</para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase> <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
declares a prototype for a function of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase></computeroutput>,
|
|
</para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">*</phrase>
|
|
<phrase role="identifier">pf</phrase> <phrase role="special">=</phrase>
|
|
<phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">&</phrase>
|
|
<phrase role="identifier">fr</phrase> <phrase role="special">=</phrase>
|
|
<phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
declares a pointer and a reference to the function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">foo</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
If you want to detect whether some type is a pointer-to-function then use:
|
|
</para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special"><</phrase><link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
<phrase role="special">&&</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
or for pointers to member functions you can just use <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link>
|
|
directly.
|
|
</para>
|
|
</tip>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_fundamental"><indexterm type="class_name"><primary>is_fundamental</primary><secondary>is_fundamental</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_fundamental"> is_fundamental</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_fundamental</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
fundamental type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Fundamental types include integral, floating point and void types (see also
|
|
<link linkend="boost_typetraits.reference.is_integral">is_integral</link>,
|
|
<link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link>
|
|
and <link linkend="boost_typetraits.reference.is_void">is_void</link>)
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_fundamental</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_integral"><indexterm type="class_name"><primary>is_integral</primary><secondary>is_integral</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_integral"> is_integral</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_integral</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
integral type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p7.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_integral</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_member_function_pointer"><indexterm type="class_name"><primary>is_member_function_pointer</primary><secondary>is_member_function_pointer</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_member_function_pointer">
|
|
is_member_function_pointer</link></title>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_function_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
pointer to a member function then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>:
|
|
the argument in this case is a pointer to a data member and not a member
|
|
function, see <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link>
|
|
and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link>
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_member_object_pointer"><indexterm type="class_name"><primary>is_member_object_pointer</primary><secondary>is_member_object_pointer</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_member_object_pointer">
|
|
is_member_object_pointer</link></title>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_object_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
pointer to a member object (a data member) then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>:
|
|
the argument in this case is a pointer to a member function and not a
|
|
member object, see <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link>
|
|
and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link>
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_member_pointer"><indexterm type="class_name"><primary>is_member_pointer</primary><secondary>is_member_pointer</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_member_pointer"> is_member_pointer</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
pointer to a member (either a function or a data member) then inherits from
|
|
<link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_object"><indexterm type="class_name"><primary>is_object</primary><secondary>is_object</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_object"> is_object</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_object</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
object type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
All types are object types except references, void, and function types.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p9.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_object</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>: reference types are not
|
|
objects
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>: function types are not
|
|
objects
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>:
|
|
void is not an object type
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_pod">
|
|
<title><link linkend="boost_typetraits.reference.is_pod"> is_pod</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pod</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
POD type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
POD stands for "Plain old data". Arithmetic types, and enumeration
|
|
types, a pointers and pointer to members are all PODs. Classes and unions
|
|
can also be POD's if they have no non-static data members that are of reference
|
|
or non-POD type, no user defined constructors, no user defined assignment
|
|
operators, no private or protected non-static data members, no virtual functions
|
|
and no base classes. Finally, a cv-qualified POD is still a POD, as is an
|
|
array of PODs.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10 and 9p4 (Note
|
|
that POD's are also aggregates, see 8.5.1).
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, is<emphasis role="underline">pod
|
|
will never report that a class or struct is a POD; this is always safe, if
|
|
possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have
|
|
the necessary compiler-</emphasis>_intrinsics.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_pointer"><indexterm type="class_name"><primary>is_pointer</primary><secondary>is_pointer</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_pointer"> is_pointer</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
pointer type (includes function pointers, but excludes pointers to members)
|
|
then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p2 and 8.3.1.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<important>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> detects "real"
|
|
pointer types only, and <emphasis>not</emphasis> smart pointers. Users
|
|
should not specialise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput>
|
|
for smart pointer types, as doing so may cause Boost (and other third party)
|
|
code to fail to function correctly. Users wanting a trait to detect smart
|
|
pointers should create their own. However, note that there is no way in
|
|
general to auto-magically detect smart pointer types, so such a trait would
|
|
have to be partially specialised for each supported smart pointer type.
|
|
</para>
|
|
</important>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_polymorphic"><indexterm type="class_name"><primary>is_polymorphic</primary><secondary>is_polymorphic</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_polymorphic"> is_polymorphic</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_polymorphic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
polymorphic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete
|
|
type.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 10.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> The implementation
|
|
requires some knowledge of the compilers ABI, it does actually seem to work
|
|
with the majority of compilers though.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_polymorphic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">poly</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">poly</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase></computeroutput>
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_same"><indexterm type="class_name"><primary>is_same</primary><secondary>is_same</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_same"> is_same</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_same</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T and U are the same types
|
|
then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_same</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with abstract, incomplete or function types.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_scalar"><indexterm type="class_name"><primary>is_scalar</primary><secondary>is_scalar</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_scalar"> is_scalar</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_scalar</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
scalar type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Scalar types include integral, floating point, enumeration, pointer, and
|
|
pointer-to-member types.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_scalar</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_signed"><indexterm type="class_name"><primary>is_signed</primary><secondary>is_signed</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_signed"> is_signed</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_signed</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is an signed integer type
|
|
or an enumerated type with an underlying signed integer type, then inherits
|
|
from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_stateless">
|
|
<title><link linkend="boost_typetraits.reference.is_stateless"> is_stateless</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_stateless</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> Ff T is a stateless type then
|
|
inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
Type T must be a complete type.
|
|
</para>
|
|
<para>
|
|
A stateless type is a type that has no storage and whose constructors and
|
|
destructors are trivial. That means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_stateless</phrase></computeroutput>
|
|
only inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>
|
|
if the following expression is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>:
|
|
</para>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_stateless</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
can not be used with function types.
|
|
</para>
|
|
<para>
|
|
Without some (as yet unspecified) help from the compiler, is_stateless will
|
|
never report that a class or struct is stateless; this is always safe, if
|
|
possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have
|
|
the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to make this template work automatically.
|
|
</para>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_reference"><indexterm type="class_name"><primary>is_reference</primary><secondary>is_reference</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_reference"> is_reference</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_reference</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a reference pointer type
|
|
then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial-specialization of class templates, then this template
|
|
may report the wrong result for function types, and for types that are both
|
|
const and volatile qualified.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis> (the argument in this case
|
|
is a reference to a function).
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_union"><indexterm type="class_name"><primary>is_union</primary><secondary>is_union</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_union"> is_union</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_union</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
union type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
Currently requires some kind of compiler support, otherwise unions are identified
|
|
as classes.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.5.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as
|
|
yet unspecified) help from the compiler, we cannot distinguish between union
|
|
and class types using only standard C++, as a result this type will never
|
|
inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
unless the user explicitly specializes the template for their user-defined
|
|
union types, or unless the compiler supplies some unspecified intrinsic that
|
|
implements this functionality. Currently (May 2005) only Visual C++ 8 has
|
|
the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link>
|
|
to make this trait "just work" without user intervention.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_unsigned"><indexterm type="class_name"><primary>is_unsigned</primary><secondary>is_unsigned</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_unsigned"> is_unsigned</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_unsigned</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is an unsigned integer type
|
|
or an enumerated type with an underlying unsigned integer type, then inherits
|
|
from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase>
|
|
<phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase>
|
|
<phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_void"><indexterm type="class_name"><primary>is_void</primary><secondary>is_void</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_void"> is_void</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_void</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified)
|
|
void type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p9.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_void</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>false</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.is_volatile"><indexterm type="class_name"><primary>is_volatile</primary><secondary>is_volatile</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.is_volatile"> is_volatile</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">is_volatile</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> If T is a (top level) volatile-qualified
|
|
type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>,
|
|
otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">volatile</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase>
|
|
<phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>true</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>false</emphasis>:
|
|
the volatile qualifier is not at the top level in this case.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.make_signed"><indexterm type="class_name"><primary>make_signed</primary><secondary>make_signed</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.make_signed"> make_signed</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">make_signed</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If T is a signed integer type then
|
|
the same type as T, if T is an unsigned integer type then the corresponding
|
|
signed type. Otherwise if T is an enumerated or character type (char or wchar_t)
|
|
then a signed integer type with the same width as T.
|
|
</para>
|
|
<para>
|
|
If T has any cv-qualifiers then these are also present on the result type.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated
|
|
type, and must not be the type bool.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase>
|
|
<phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase>
|
|
<phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">long</phrase>
|
|
<phrase role="keyword">long</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
A signed integer type with the same width as the enum.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
A signed integer type with the same width as wchar_t.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.make_unsigned"><indexterm type="class_name"><primary>make_unsigned</primary><secondary>make_unsigned</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.make_unsigned"> make_unsigned</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">make_unsigned</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If T is a unsigned integer type then
|
|
the same type as T, if T is an signed integer type then the corresponding
|
|
unsigned type. Otherwise if T is an enumerated or character type (char or
|
|
wchar_t) then an unsigned integer type with the same width as T.
|
|
</para>
|
|
<para>
|
|
If T has any cv-qualifiers then these are also present on the result type.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated
|
|
type, and must not be the type bool.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase>
|
|
<phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase>
|
|
<phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase>
|
|
<phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase>
|
|
<phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
An unsigned integer type with the same width as the enum.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
An unsigned integer type with the same width as wchar_t.
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.promote"><indexterm type="class_name"><primary>promote</primary><secondary>promote</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.promote"> promote</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">promote</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If integral or floating point promotion
|
|
can be applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
then applies integral and floating point promotions to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged.
|
|
See also <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link>
|
|
and <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3
|
|
(integral bit-field) and 4.6.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">promote</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.rank"><indexterm type="class_name"><primary>integral_constant</primary><secondary>rank</secondary></indexterm><indexterm><primary>rank</primary><secondary>integral_constant</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.rank"> rank</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">rank</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">Inherits:</emphasis> Class template rank inherits from
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase></computeroutput>,
|
|
where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is the
|
|
number of array dimensions in type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type,
|
|
then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is zero.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">rank</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Examples:</emphasis>
|
|
</para>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[]></phrase></computeroutput>
|
|
inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput>
|
|
is an integral constant expression that evaluates to <emphasis>1</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>2</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression
|
|
that evaluates to <emphasis>0</emphasis>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
<blockquote>
|
|
<para>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>.
|
|
</para>
|
|
</para>
|
|
</blockquote>
|
|
</section>
|
|
<section id="boost_typetraits.reference.remove_all_extents"><indexterm type="class_name"><primary>remove_all_extents</primary><secondary>remove_all_extents</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.remove_all_extents"> remove_all_extents</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_all_extents</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
is an array type, then removes all of the array bounds on <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_all_extents</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.remove_const"><indexterm type="class_name"><primary>remove_const</primary><secondary>remove_const</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.remove_const"> remove_const</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_const</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
but with any <emphasis>top level</emphasis> const-qualifier removed.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase>
|
|
<phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.remove_cv"><indexterm type="class_name"><primary>remove_cv</primary><secondary>remove_cv</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.remove_cv"> remove_cv</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_cv</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
but with any <emphasis>top level</emphasis> cv-qualifiers removed.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase>
|
|
<phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.remove_extent"><indexterm type="class_name"><primary>remove_extent</primary><secondary>remove_extent</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.remove_extent"> remove_extent</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_extent</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
is an array type, then removes the topmost array bound, otherwise leaves
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.remove_pointer"><indexterm type="class_name"><primary>remove_pointer</primary><secondary>remove_pointer</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.remove_pointer"> remove_pointer</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_pointer</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
but with any pointer modifier removed.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">**>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.remove_reference"><indexterm type="class_name"><primary>remove_reference</primary><secondary>remove_reference</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.remove_reference"> remove_reference</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_reference</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
but with any reference modifier removed.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.remove_volatile"><indexterm type="class_name"><primary>remove_volatile</primary><secondary>remove_volatile</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.remove_volatile"> remove_volatile</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_volatile</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>,
|
|
but with any <emphasis>top level</emphasis> volatile-qualifier removed.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler
|
|
does not support partial specialization of class-templates then this template
|
|
will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput>
|
|
will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>
|
|
except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
|
workarounds</link> have been applied.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
<table frame="all"> <title>Examples</title>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
Expression
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
Result Type
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase>
|
|
<phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput>
|
|
</para>
|
|
</entry><entry>
|
|
<para>
|
|
<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput>
|
|
</para>
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</table>
|
|
</section>
|
|
<section id="boost_typetraits.reference.type_with_alignment"><indexterm type="class_name"><primary>type_with_alignment</primary><secondary>type_with_alignment</secondary></indexterm>
|
|
<title><link linkend="boost_typetraits.reference.type_with_alignment"> type_with_alignment</link></title>
|
|
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">type_with_alignment</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<para>
|
|
<emphasis role="bold">type:</emphasis> a built-in or POD type with an alignment
|
|
that is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>.
|
|
</para>
|
|
<para>
|
|
<emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase>
|
|
<phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">type_with_alignment</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput>
|
|
</para>
|
|
</section>
|
|
</section>
|
|
<section id="boost_typetraits.credits">
|
|
<title><link linkend="boost_typetraits.credits"> Credits</link></title>
|
|
<para>
|
|
This documentation was pulled together by John Maddock, using <ulink url="../../../../doc/html/quickbook.html">Boost.Quickbook</ulink>
|
|
and <ulink url="../../../../doc/html/boostbook.html">Boost.DocBook</ulink>.
|
|
</para>
|
|
<para>
|
|
The original version of this library was created by Steve Cleary, Beman Dawes,
|
|
Howard Hinnant, and John Maddock. John Maddock is the current maintainer of
|
|
the library.
|
|
</para>
|
|
<para>
|
|
This version of type traits library is based on contributions by Adobe Systems
|
|
Inc, David Abrahams, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant,
|
|
Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Thorsten Ottosen, Robert
|
|
Ramey and Jeremy Siek.
|
|
</para>
|
|
<para>
|
|
Mat Marcus and Jesse Jones invented, and <ulink url="http://opensource.adobe.com/project4/project.shtml">published
|
|
a paper describing</ulink>, the partial specialization workarounds used in
|
|
this library.
|
|
</para>
|
|
<para>
|
|
Aleksey Gurtovoy added MPL integration to the library.
|
|
</para>
|
|
<para>
|
|
The <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link>
|
|
template is based on code originally devised by Andrei Alexandrescu, see "<ulink url="http://www.cuj.com/experts/1810/alexandr.htm?topic=experts">Generic<Programming>:
|
|
Mappings between Types and Values</ulink>".
|
|
</para>
|
|
<para>
|
|
The latest version of this library and documentation can be found at <ulink url="http://www.boost.org">www.boost.org</ulink>. Bugs, suggestions and discussion
|
|
should be directed to boost@lists.boost.org (see <ulink url="http://www.boost.org/more/mailing_lists.htm#main">www.boost.org/more/mailing_lists.htm#main</ulink>
|
|
for subscription details).
|
|
</para>
|
|
</section>
|
|
|
|
<section id="boost_typetraits.ignored_section">
|
|
<title>This section must not be indexed.</title>
|
|
<?BoostAutoIndex IgnoreSection?>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
</section>
|
|
|
|
<section id="boost_typetraits.ignored_block"><indexterm type="class_name"><primary>add_volatile</primary><secondary>This section contains one block that must not be indexed and one that should be.</secondary></indexterm><indexterm><primary>This section contains one block that must not be indexed and one that should be.</primary><secondary>add_volatile</secondary></indexterm>
|
|
<title>This section contains one block that must not be indexed and one that should be.</title>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">
|
|
<?BoostAutoIndex IgnoreBlock?>
|
|
template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">
|
|
template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase>
|
|
<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase>
|
|
<phrase role="special">{</phrase>
|
|
<phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase>
|
|
<phrase role="special">};</phrase>
|
|
</programlisting>
|
|
</section>
|
|
|
|
|
|
<index type="class_name">
|
|
<title>Class Index</title>
|
|
</index>
|
|
<index type="typedef_name">
|
|
<title>Typedef Index</title>
|
|
</index>
|
|
<index type="macro_name">
|
|
<title>Macro Index</title>
|
|
</index>
|
|
<index type="test_index_1">
|
|
<title>Index Test 1</title>
|
|
</index>
|
|
<index type="test_index_2">
|
|
<title>Index Test 2</title>
|
|
</index>
|
|
<index/>
|
|
|
|
</chapter> |