From a8c65cc5955a60a95a0175a61c1f0f79e1da1a2e Mon Sep 17 00:00:00 2001
From: Joel de Guzman
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
@@ -46,29 +45,29 @@
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
- Class
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,
-
- Here we define a primary version of the template class
The syntax for partial specialization is somewhat arcane and could easily occupy
@@ -153,35 +152,35 @@
and close enough to the actual rule to be useful for everyday use.
- As a more complex example of partial specialization consider the class
- The aim of
As an example of how the type traits classes can be used, consider the standard
library algorithm copy:
@@ -192,24 +191,24 @@
Obviously, there's no problem writing a generic version of copy that works
- for all iterator types
- If all these conditions are met then a type can be copied using
- The code for an optimized version of copy that uses
It has often been repeated in these columns that "premature optimization
is the root of all evil" [4].
@@ -286,9 +286,9 @@
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
@@ -397,7 +397,7 @@
references [6].
- First, let us examine the definition of
-
@@ -24,8 +24,7 @@
strlen
and wcslen
+ more efficient methods available: for example, the C library functions strlen and wcslen
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 char
and wchar_t
- into the class char_traits
.
- Generic code that works with character strings can simply use char_traits<>::length
to determine the length of a null
- terminated string, safe in the knowledge that specializations of char_traits
will use the most appropriate
+ C++ standard library realized this, and abstracted the properties of char and wchar_t
+ into the class char_traits.
+ Generic code that works with character strings can simply use char_traits<>::length to determine the length of a null
+ terminated string, safe in the knowledge that specializations of char_traits will use the most appropriate
method available to them.
-
+
+
+
Type Traits
-
char_traits
is a classic
+ Class char_traits is a classic
example of a collection of type specific properties wrapped up in a single
class - what Nathan Myers termed a baggage class[1]. In the Boost type-traits library,
we[2] 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 true_type
- if the type has the specified property and inherits from false_type
+ share a unified design: each class inherits from a the type true_type
+ if the type has the specified property and inherits from false_type
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.
@@ -77,51 +76,51 @@
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 type
+ a single typedef-member type
that is the result of the transformation. All of the type-traits classes are
- defined inside namespace boost
;
+ defined inside namespace boost;
for brevity, namespace-qualification is omitted in most of the code samples
given.
-
+
+
+
Implementation
-
is_void<T>
inherits
- from true_type
- only if T
is void
.
+ is_void<T> inherits
+ from true_type
+ only if T is void.
template <typename T>
-struct is_void : public false_type{};
+struct is_void : public false_type{};
template <>
-struct is_void<void> : public true_type{};
+struct is_void<void> : public true_type{};
is_void
,
- and provide a full-specialization when T
- is void
. While full specialization
+ Here we define a primary version of the template class is_void,
+ and provide a full-specialization when T
+ is void. 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 boost::is_pointer<T>
:
+ template-class specialization. As an example, consider the class boost::is_pointer<T>:
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:
template <typename T>
-struct is_pointer : public false_type{};
+struct is_pointer : public false_type{};
template <typename T>
-struct is_pointer<T*> : public true_type{};
+struct is_pointer<T*> : public true_type{};
remove_extent<T>
. This
- class defines a single typedef-member type
+ As a more complex example of partial specialization consider the class remove_extent<T>. This
+ class defines a single typedef-member type
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:
template <typename T>
-struct remove_extent
+struct remove_extent
{ typedef T type; };
template <typename T, std::size_t N>
-struct remove_extent<T[N]>
+struct remove_extent<T[N]>
{ typedef T type; };
remove_extent
+ The aim of remove_extent
is this: imagine a generic algorithm that is passed an array type as a template
- parameter, remove_extent
+ parameter, remove_extent
provides a means of determining the underlying type of the array. For example
- remove_extent<int[4][5]>::type
would evaluate to the type int[5]
. This example also shows that the number of
+ remove_extent<int[4][5]>::type would evaluate to the type int[5]. 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.
-
+
+
+
Optimized copy
-
Iter1
- and Iter2
; however, there are
+ for all iterator types Iter1
+ and Iter2; however, there are
some circumstances when the copy operation can best be performed by a call
- to memcpy
. In order to implement
- copy in terms of memcpy
all
+ to memcpy. In order to implement
+ copy in terms of memcpy all
of the following conditions need to be met:
Iter1
- and Iter2
must be pointers.
+ Both of the iterator types Iter1
+ and Iter2 must be pointers.
Iter1
and Iter2
must point to the same type - excluding
+ Both Iter1 and Iter2 must point to the same type - excluding
const and volatile-qualifiers.
Iter1
+ The type pointed to by Iter1
must have a trivial assignment operator.
memcpy
rather than using a compiler generated
- assignment operator. The type-traits library provides a class has_trivial_assign
,
- such that has_trivial_assign<T>::value
is true only if T has a trivial assignment
+ If all these conditions are met then a type can be copied using memcpy rather than using a compiler generated
+ assignment operator. The type-traits library provides a class has_trivial_assign,
+ such that has_trivial_assign<T>::value 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 has_trivial_assign
+ assignment operator. In other words if has_trivial_assign
gives the wrong answer, it will give the "safe" wrong answer - that
trivial assignment is not allowable.
memcpy
- where appropriate is given in the
- examples. The code begins by defining a template function do_copy
that performs a "slow but safe"
- copy. The last parameter passed to this function may be either a true_type
- or a false_type
.
+ The code for an optimized version of copy that uses memcpy
+ where appropriate is given in the
+ examples. The code begins by defining a template function do_copy that performs a "slow but safe"
+ copy. The last parameter passed to this function may be either a true_type
+ or a false_type.
Following that there is an overload of docopy that
uses `memcpy`: this time the iterators are required to actually be pointers
- to the same type, and the final parameter must be a `_true_type. Finally, the version
- of
copy calls
-
docopy`, passing `_has_trivial_assign<value_type>()`
+ to the same type, and the final parameter must be a `_true_type. Finally, the version
+ of copy calls
+ docopy`, passing `_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".
-
+
+
+
Was it worth it?
-
-
+
+
+
Pair of References
-
std::pair
, omitting
+ First, let us examine the definition of std::pair, omitting
the comparison operators, default constructor, and template copy constructor
for simplicity:
Table 1.2. Required Constructor Argument Types
-
- Type of |
@@ -479,18 +479,18 @@ |
---|
+
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 add_reference, which + of the contained class. The type traits classes provide a transformation add_reference, which adds a reference to its type, unless it is already a reference.
Table 1.3. Using add_reference to synthesize the correct constructor +
Table 1.3. Using add_reference to synthesize the correct constructor type
-
- Type of |
- Type of |
- Type of |
---|
- This allows us to build a primary template definition for pair
+
+ This allows us to build a primary template definition for pair that can contain non-reference types, reference types, and constant reference types:
@@ -584,20 +584,20 @@ T1 first; T2 second; -pair(boost::add_reference<const T1>::type nfirst, - boost::add_reference<const T2>::type nsecond) +pair(boost::add_reference<const T1>::type nfirst, + boost::add_reference<const T2>::type nsecond) :first(nfirst), second(nsecond) { } };
Add back in the standard comparison operators, default constructor, and template
- copy constructor (which are all the same), and you have a std::pair
that
+ copy constructor (which are all the same), and you have a std::pair that
can hold reference types!
This same extension could have been done using partial template specialization
- of pair
, but to specialize
- pair
in this way would require
+ of pair, but to specialize
+ pair 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
@@ -605,10 +605,10 @@
partial specialization to the type traits classes, resulting in code that is
easier to maintain and easier to understand.
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 @@ -618,18 +618,18 @@ does not have to sink to the lowest common denominator, and that templates can be optimal as well as generic.
-The authors would like to thank Beman Dawes and Howard Hinnant for their helpful comments when preparing this article.
-- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
![]() |
Tip |
---|---|
+ | |
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 remove_pointer. + functions. To convert a function pointer type to a suitable type use remove_pointer. |
Table 1.12. Function Traits Members
-
- |
An integral constant expression that gives the number of arguments
- accepted by the function type |
- |
- The type returned by function type |
- |
- The |
Table 1.13. Examples
-
- |
@@ -157,7 +157,7 @@ |
- |
@@ -169,7 +169,7 @@ |
- |
@@ -181,60 +181,60 @@ |
- |
- The type |
- |
- The type |
- |
- The type |
- |
- The type |
- |
- A compiler error: there is no |
@@ -242,7 +242,7 @@
- |
@@ -253,16 +253,19 @@ |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- |
- |
- |
- |
- |
- |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
![]() |
Tip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Don't confuse function-types with pointers to functions:
- defines a function type,
-
- declares a prototype for a function of type
-
-
- declares a pointer and a reference to the function If you want to detect whether some type is a pointer-to-function then use:
- - or for pointers to member functions you can just use is_member_function_pointer + or for pointers to member functions you can just use is_member_function_pointer directly. |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
- | Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
+
+ Ramey and Jeremy Siek | + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.orgLICENSE_1_0.txt"> + http:/www.boost.org/LICENSE_1_0.txt </ulink>) + |
![]() |
Important | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+ is_pointer detects "real"
pointer types only, and not smart pointers. Users
- should not specialise
diff --git a/doc/html/boost_typetraits/reference/is_polymorphic.html b/doc/html/boost_typetraits/reference/is_polymorphic.html
index 8ba6496..439eb74 100644
--- a/doc/html/boost_typetraits/reference/is_polymorphic.html
+++ b/doc/html/boost_typetraits/reference/is_polymorphic.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_reference.html b/doc/html/boost_typetraits/reference/is_reference.html
index e2f2192..0c8bca0 100644
--- a/doc/html/boost_typetraits/reference/is_reference.html
+++ b/doc/html/boost_typetraits/reference/is_reference.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_same.html b/doc/html/boost_typetraits/reference/is_same.html
index 198aa4f..c1bcceb 100644
--- a/doc/html/boost_typetraits/reference/is_same.html
+++ b/doc/html/boost_typetraits/reference/is_same.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_scalar.html b/doc/html/boost_typetraits/reference/is_scalar.html
index a2c1119..daa6286 100644
--- a/doc/html/boost_typetraits/reference/is_scalar.html
+++ b/doc/html/boost_typetraits/reference/is_scalar.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_signed.html b/doc/html/boost_typetraits/reference/is_signed.html
index 680dbaa..e367498 100644
--- a/doc/html/boost_typetraits/reference/is_signed.html
+++ b/doc/html/boost_typetraits/reference/is_signed.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_stateless.html b/doc/html/boost_typetraits/reference/is_stateless.html
index c7d63bf..af9f386 100644
--- a/doc/html/boost_typetraits/reference/is_stateless.html
+++ b/doc/html/boost_typetraits/reference/is_stateless.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_union.html b/doc/html/boost_typetraits/reference/is_union.html
index a051ae4..16a82bc 100644
--- a/doc/html/boost_typetraits/reference/is_union.html
+++ b/doc/html/boost_typetraits/reference/is_union.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_unsigned.html b/doc/html/boost_typetraits/reference/is_unsigned.html
index d18fdbf..fa0c65a 100644
--- a/doc/html/boost_typetraits/reference/is_unsigned.html
+++ b/doc/html/boost_typetraits/reference/is_unsigned.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_void.html b/doc/html/boost_typetraits/reference/is_void.html
index 12b570a..89063d7 100644
--- a/doc/html/boost_typetraits/reference/is_void.html
+++ b/doc/html/boost_typetraits/reference/is_void.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/is_volatile.html b/doc/html/boost_typetraits/reference/is_volatile.html
index fa1b090..3cb0ed2 100644
--- a/doc/html/boost_typetraits/reference/is_volatile.html
+++ b/doc/html/boost_typetraits/reference/is_volatile.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/make_signed.html b/doc/html/boost_typetraits/reference/make_signed.html
index bbf824e..de6a3f7 100644
--- a/doc/html/boost_typetraits/reference/make_signed.html
+++ b/doc/html/boost_typetraits/reference/make_signed.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/make_unsigned.html b/doc/html/boost_typetraits/reference/make_unsigned.html
index b77a4d5..1b86312 100644
--- a/doc/html/boost_typetraits/reference/make_unsigned.html
+++ b/doc/html/boost_typetraits/reference/make_unsigned.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/promote.html b/doc/html/boost_typetraits/reference/promote.html
index cb3bf1f..8a833eb 100644
--- a/doc/html/boost_typetraits/reference/promote.html
+++ b/doc/html/boost_typetraits/reference/promote.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/rank.html b/doc/html/boost_typetraits/reference/rank.html
index b60bfc2..4510d27 100644
--- a/doc/html/boost_typetraits/reference/rank.html
+++ b/doc/html/boost_typetraits/reference/rank.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/remove_all_extents.html b/doc/html/boost_typetraits/reference/remove_all_extents.html
index b7b23d5..89104df 100644
--- a/doc/html/boost_typetraits/reference/remove_all_extents.html
+++ b/doc/html/boost_typetraits/reference/remove_all_extents.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/remove_const.html b/doc/html/boost_typetraits/reference/remove_const.html
index 26e6421..bf4643a 100644
--- a/doc/html/boost_typetraits/reference/remove_const.html
+++ b/doc/html/boost_typetraits/reference/remove_const.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/remove_cv.html b/doc/html/boost_typetraits/reference/remove_cv.html
index 290a560..845be09 100644
--- a/doc/html/boost_typetraits/reference/remove_cv.html
+++ b/doc/html/boost_typetraits/reference/remove_cv.html
@@ -1,13 +1,13 @@
-
diff --git a/doc/html/boost_typetraits/reference/remove_extent.html b/doc/html/boost_typetraits/reference/remove_extent.html
index 24aa231..f899db9 100644
--- a/doc/html/boost_typetraits/reference/remove_extent.html
+++ b/doc/html/boost_typetraits/reference/remove_extent.html
@@ -1,13 +1,13 @@
- |