diff --git a/doc/html/boost_typetraits/background.html b/doc/html/boost_typetraits/background.html index be75eb7..64d11c0 100644 --- a/doc/html/boost_typetraits/background.html +++ b/doc/html/boost_typetraits/background.html @@ -1,13 +1,13 @@
-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 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 T1
+ 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 T1
+ Type of |
- Type of const T1
+ Type of |
- Type of add_reference<const T1>::type
+ 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:
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.
-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>) + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
| @@ -232,8 +232,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- add_const<int>::type
+ |
- int const
+ |
|
- add_const<int&>::type
+ |
- int&
+ |
|
- add_const<int*>::type
+ |
- int*
- const
+ |
|
- add_const<int const>::type
+ |
- int const
+ |
| @@ -132,8 +134,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- add_cv<int>::type
+ |
- int const
- volatile
+ |
|
- add_cv<int&>::type
+ |
- int&
+ |
|
- add_cv<int*>::type
+ |
- int*
- const volatile
+ |
|
- add_cv<int const>::type
+ |
- int const
- volatile
+ |
| @@ -135,8 +137,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- add_pointer<int>::type
+ |
- int*
+ |
|
- add_pointer<int const&>::type
+ |
- int const*
+ |
|
- add_pointer<int*>::type
+ |
- int**
+ |
|
- add_pointer<int*&>::type
+ |
- int**
+ |
| @@ -134,8 +136,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- add_reference<int>::type
+ |
- int&
+ |
|
- add_reference<int const&>::type
+ |
- int const&
+ |
|
- add_reference<int*>::type
+ |
- int*&
+ |
|
- add_reference<int*&>::type
+ |
- int*&
+ |
| @@ -131,8 +133,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- add_volatile<int>::type
+ |
- int volatile
+ |
|
- add_volatile<int&>::type
+ |
- int&
+ |
|
- add_volatile<int*>::type
+ |
- int*
- volatile
+ |
|
- add_volatile<int const>::type
+ |
- int const
- volatile
+ |
| @@ -133,8 +135,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- decay<int[2][3]>::type
+ |
- int[2]*
+ |
|
- decay<int(&)[2]>::type
+ |
- int*
+ |
|
- decay<int(&)(double)>::type
+ |
- int(*)(double)
+ |
|
- int(*)(double
+ |
- int(*)(double)
+ |
|
- int(double)
+ |
- int(*)(double)
+ |
| @@ -138,8 +140,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- floating_point_promotion<float
- const>::type
+ |
- double const
+ |
|
- floating_point_promotion<float&>::type
+ |
- float&
+ |
|
- floating_point_promotion<short>::type
+ |
- short
+ |
| @@ -118,8 +118,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
![]() |
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
-|
- function_traits<T>::arity
+ |
An integral constant expression that gives the number of arguments
- accepted by the function type F.
+ accepted by the function type |
|
- function_traits<T>::result_type
+ |
- The type returned by function type F.
+ The type returned by function type |
|
- function_traits<T>::argN_type
+ |
- The Nth argument type of function type F,
- where 1 <=
+ The |
Table 1.13. Examples
-|
- function_traits<void (void)>::arity
+ |
@@ -157,7 +157,7 @@ |
|
- function_traits<long (int)>::arity
+ |
@@ -169,7 +169,7 @@ |
|
- function_traits<long (int, long, double, void*)>::arity
+ |
@@ -181,60 +181,60 @@ |
|
- function_traits<void (void)>::result_type
+ |
- The type void.
+ The type |
|
- function_traits<long (int)>::result_type
+ |
- The type long.
+ The type |
|
- function_traits<long (int)>::arg1_type
+ |
- The type int.
+ The type |
|
- function_traits<long (int, long, double, void*)>::arg4_type
+ |
- The type void*.
+ The type |
|
- function_traits<long (int, long, double, void*)>::arg5_type
+ |
- A compiler error: there is no arg4_type
+ A compiler error: there is no |
@@ -242,7 +242,7 @@
|
- function_traits<long (*)(void)>::arity
+ |
@@ -253,8 +253,9 @@ |
| @@ -263,8 +264,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- integral_promotion<short
- const>::type
+ |
- int const
+ |
|
- integral_promotion<short&>::type
+ |
- short&
+ |
|
- integral_promotion<enum std::float_round_style>::type
+ |
- int
+ |
| @@ -116,8 +118,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
![]() |
Tip |
|---|---|
| + | |
|
Don't confuse function-types with pointers to functions:
- typedef int
- f(double);
+ defines a function type,
- f foo;
+
- declares a prototype for a function of type f,
+ declares a prototype for a function of type
- f*
+
- f&
+
- declares a pointer and a reference to the function foo.
+ declares a pointer and a reference to the function If you want to detect whether some type is a pointer-to-function then use:
- is_function<remove_pointer<T>::type>::value
- && is_pointer<T>::value
+ - 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. | |
![]() |
Important |
|---|---|
- is_pointer detects "real" + | |
+ 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>) + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
|
|
- make_signed<int>::type
+ |
- int
+ |
|
- make_signed<unsigned int
- const>::type
+ |
- int const
+ |
|
- make_signed<const unsigned
- long long>::type
+ |
- const long
- long
+ |
|
- make_signed<my_enum>::type
+ |
@@ -127,7 +128,7 @@ |
|
- make_signed<wchar_t>::type
+ |
@@ -137,8 +138,9 @@ |
| @@ -147,8 +149,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- make_signed<int>::type
+ |
- unsigned int
+ |
|
- make_signed<unsigned int
- const>::type
+ |
- unsigned int
- const
+ |
|
- make_signed<const unsigned
- long long>::type
+ |
- const unsigned
- long long
+ |
|
- make_signed<my_enum>::type
+ |
@@ -128,7 +129,7 @@ |
|
- make_signed<wchar_t>::type
+ |
@@ -138,8 +139,9 @@ |
| @@ -148,8 +150,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- promote<short volatile>::type
+ |
- int volatile
+ |
|
- promote<float const>::type
+ |
- double const
+ |
|
- promote<short&>::type
+ |
- short&
+ |
| @@ -118,8 +119,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- remove_all_extents<int>::type
+ |
- int
+ |
|
- remove_all_extents<int const[2]>::type
+ |
- int const
+ |
|
- remove_all_extents<int[][2]>::type
+ |
- int
+ |
|
- remove_all_extents<int[2][3][4]>::type
+ |
- int
+ |
|
- remove_all_extents<int const*>::type
+ |
- int const*
+ |
| @@ -144,8 +146,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- remove_const<int>::type
+ |
- int
+ |
|
- remove_const<int const>::type
+ |
- int
+ |
|
- remove_const<int const
- volatile>::type
+ |
- int volatile
+ |
|
- remove_const<int const&>::type
+ |
- int const&
+ |
|
- remove_const<int const*>::type
+ |
- int const*
+ |
| @@ -144,8 +146,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- remove_cv<int>::type
+ |
- int
+ |
|
- remove_cv<int const>::type
+ |
- int
+ |
|
- remove_cv<int const
- volatile>::type
+ |
- int
+ |
|
- remove_cv<int const&>::type
+ |
- int const&
+ |
|
- remove_cv<int const*>::type
+ |
- int const*
+ |
| @@ -144,8 +146,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- remove_extent<int>::type
+ |
- int
+ |
|
- remove_extent<int const[2]>::type
+ |
- int const
+ |
|
- remove_extent<int[2][4]>::type
+ |
- int[4]
+ |
|
- remove_extent<int[][2]>::type
+ |
- int[2]
+ |
|
- remove_extent<int const*>::type
+ |
- int const*
+ |
| @@ -144,8 +146,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- remove_pointer<int>::type
+ |
- int
+ |
|
- remove_pointer<int const*>::type
+ |
- int const
+ |
|
- remove_pointer<int const**>::type
+ |
- int const*
+ |
|
- remove_pointer<int&>::type
+ |
- int&
+ |
|
- remove_pointer<int*&>::type
+ |
- int*&
+ |
| @@ -143,8 +145,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- remove_reference<int>::type
+ |
- int
+ |
|
- remove_reference<int const&>::type
+ |
- int const
+ |
|
- remove_reference<int*>::type
+ |
- int*
+ |
|
- remove_reference<int*&>::type
+ |
- int*
+ |
| @@ -131,8 +133,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
|
- remove_volatile<int>::type
+ |
- int
+ |
|
- remove_volatile<int volatile>::type
+ |
- int
+ |
|
- remove_volatile<int const
- volatile>::type
+ |
- int const
+ |
|
- remove_volatile<int volatile&>::type
+ |
- int const&
+ |
|
- remove_volatile<int volatile*>::type
+ |
- int const*
+ |
| @@ -144,8 +146,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek |
Last revised: September 10, 2007 at 19:24:53 +0800 |
+Last revised: November 07, 2007 at 18:38:23 +0000 |