forked from boostorg/type_traits
Merges changes from Trunk: refer to history.qbk for the details.
[SVN r65708]
This commit is contained in:
47
doc/add_lvalue_reference.qbk
Normal file
47
doc/add_lvalue_reference.qbk
Normal file
@@ -0,0 +1,47 @@
|
||||
[/
|
||||
Copyright 2010 John Maddock.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:add_lvalue_reference add_lvalue_reference]
|
||||
|
||||
template <class T>
|
||||
struct add_lvalue_reference
|
||||
{
|
||||
typedef __below type;
|
||||
};
|
||||
|
||||
__type If `T` names an object or function type then the member typedef `type`
|
||||
shall name `T&`; otherwise, if `T` names a type ['rvalue reference to U] then
|
||||
the member typedef type shall name `U&`; otherwise, type shall name `T`.
|
||||
|
||||
__std_ref 20.7.6.2.
|
||||
|
||||
__compat If the compiler does not support partial specialization of class-templates
|
||||
then this template will compile, but the member `type` will always be the same as
|
||||
type `T` except where __transform_workaround have been applied.
|
||||
|
||||
__header ` #include <boost/type_traits/add_lvalue_reference.hpp>` or ` #include <boost/type_traits.hpp>`
|
||||
|
||||
[table Examples
|
||||
|
||||
[ [Expression] [Result Type]]
|
||||
|
||||
[[`add_lvalue_reference<int>::type`][`int&`]]
|
||||
|
||||
[[`add_lvalue_reference<int const&>::type`] [`int const&`]]
|
||||
|
||||
[[`add_lvalue_reference<int*>::type`] [`int*&`]]
|
||||
|
||||
[[`add_lvalue_reference<int*&>::type`] [`int*&`]]
|
||||
|
||||
[[`add_lvalue_reference<int&&>::type`][`int&`]]
|
||||
|
||||
[[`add_lvalue_reference<void>::type`][`void`]]
|
||||
|
||||
]
|
||||
|
||||
[endsect]
|
||||
|
@@ -7,6 +7,12 @@
|
||||
|
||||
[section:add_reference add_reference]
|
||||
|
||||
[note This trait has been made obsolete by __add_lvalue_reference and __add_rvalue_reference,
|
||||
and new code should use these new traits rather than __is_reference which is retained
|
||||
for backwards compatibility only.
|
||||
]
|
||||
|
||||
|
||||
template <class T>
|
||||
struct add_reference
|
||||
{
|
||||
|
50
doc/add_rvalue_reference.qbk
Normal file
50
doc/add_rvalue_reference.qbk
Normal file
@@ -0,0 +1,50 @@
|
||||
[/
|
||||
Copyright 2010 John Maddock.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt).
|
||||
]
|
||||
|
||||
[section:add_rvalue_reference add_rvalue_reference]
|
||||
|
||||
template <class T>
|
||||
struct add_rvalue_reference
|
||||
{
|
||||
typedef __below type;
|
||||
};
|
||||
|
||||
__type If `T` names an object or function type then the member typedef type
|
||||
shall name `T&&`; otherwise, type shall name `T`. ['\[Note: This rule reflects
|
||||
the semantics of reference collapsing. For example, when a type `T` names
|
||||
a type U&, the type `add_rvalue_reference<T>::type` is not an rvalue
|
||||
reference. -end note\]].
|
||||
|
||||
__std_ref 20.7.6.2.
|
||||
|
||||
__compat If the compiler does not support partial specialization of class-templates
|
||||
and rvalue references
|
||||
then this template will compile, but the member `type` will always be the same as
|
||||
type `T`.
|
||||
|
||||
__header ` #include <boost/type_traits/add_rvalue_reference.hpp>` or ` #include <boost/type_traits.hpp>`
|
||||
|
||||
[table Examples
|
||||
|
||||
[ [Expression] [Result Type]]
|
||||
|
||||
[[`add_rvalue_reference<int>::type`][`int&&`]]
|
||||
|
||||
[[`add_rvalue_reference<int const&>::type`] [`int const&`]]
|
||||
|
||||
[[`add_rvalue_reference<int*>::type`] [`int*&&`]]
|
||||
|
||||
[[`add_rvalue_reference<int*&>::type`] [`int*&`]]
|
||||
|
||||
[[`add_rvalue_reference<int&&>::type`][`int&&`]]
|
||||
|
||||
[[`add_rvalue_reference<void>::type`][`void`]]
|
||||
|
||||
]
|
||||
|
||||
[endsect]
|
||||
|
219
doc/common_type.qbk
Normal file
219
doc/common_type.qbk
Normal file
@@ -0,0 +1,219 @@
|
||||
|
||||
[/===================================================================]
|
||||
[section:common_type common_type]
|
||||
[/===================================================================]
|
||||
|
||||
[def __declval [@../../../utility/doc/html/declval.html declval]]
|
||||
|
||||
|
||||
`#include <boost/type_traits/common_type.hpp>`
|
||||
|
||||
namespace boost {
|
||||
template <class ...T> struct __common_type;
|
||||
}
|
||||
|
||||
|
||||
__common_type is a traits class used to deduce a type common to a several types, useful as the return type of functions
|
||||
operating on multiple input types such as in mixed-mode arithmetic..
|
||||
|
||||
The nested typedef `::type` could be defined as follows:
|
||||
|
||||
template <class ...T>
|
||||
struct common_type;
|
||||
|
||||
template <class T, class U, class ...V>
|
||||
struct common_type<T,U,...V> {
|
||||
typedef typename __common_type<typename __common_type<T, U>::type, V...>::type type;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct common_type<T> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
struct common_type<T, U> {
|
||||
typedef decltype(__declval<bool>() ? __declval<T>() : __declval<U>()) type;
|
||||
};
|
||||
|
||||
All parameter types must be complete. This trait is permitted to be specialized by a user if at least one
|
||||
template parameter is a user-defined type. [*Note:] Such specializations are required when only explicit conversions
|
||||
are desired among the __common_type arguments.
|
||||
|
||||
Note that when the compiler does not support variadic templates (and the macro BOOST_NO_VARIADIC_TEMPLATES is defined)
|
||||
then the maximum number of template arguments is 3.
|
||||
|
||||
|
||||
[h4 Configuration macros]
|
||||
|
||||
When the compiler does not support static assertions then the user can select the way static assertions are reported. Define
|
||||
|
||||
* BOOST_COMMON_TYPE_USES_STATIC_ASSERT: define it if you want to use Boost.StaticAssert
|
||||
* BOOST_COMMON_TYPE_USES_MPL_ASSERT: define it if you want to use Boost.MPL static asertions
|
||||
|
||||
The default behavior is to use mpl assertions in this case, but setting BOOST_COMMON_TYPE_USES_STATIC_ASSERT may reduce
|
||||
compile times and header dependencies somewhat.
|
||||
|
||||
Depending on the static assertion used you will have an hint of the failing assertion either through the symbol or through the text.
|
||||
|
||||
When possible common_type is implemented using `decltype`. Otherwise when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is not defined
|
||||
it uses Boost.TypeOf.
|
||||
|
||||
[h4 Tutorial]
|
||||
|
||||
In a nutshell, __common_type is a trait that takes 1 or more types, and returns a type which
|
||||
all of the types will convert to. The default definition demands this conversion be implicit.
|
||||
However the trait can be specialized for user-defined types which want to limit their inter-type conversions to explicit,
|
||||
and yet still want to interoperate with the __common_type facility.
|
||||
|
||||
[*Example:]
|
||||
|
||||
template <class T, class U>
|
||||
complex<typename __common_type<T, U>::type>
|
||||
operator+(complex<T>, complex<U>);
|
||||
|
||||
|
||||
In the above example, "mixed-mode" complex arithmetic is allowed. The return type is described by __common_type.
|
||||
For example the resulting type of adding a `complex<float>` and `complex<double>` might be a `complex<double>`.
|
||||
|
||||
Here is how someone might produce a variadic comparison function:
|
||||
|
||||
template <class ...T>
|
||||
typename __common_type<T...>::type
|
||||
min(T... t);
|
||||
|
||||
This is a very useful and broadly applicable utility.
|
||||
|
||||
[h4 How to get the common type of types with explicit conversions?]
|
||||
|
||||
Another choice for the author of the preceding operator could be
|
||||
|
||||
template <class T, class U>
|
||||
typename __common_type<complex<T>, complex<U> >::type
|
||||
operator+(complex<T>, complex<U>);
|
||||
|
||||
As the default definition of __common_type demands the conversion be implicit, we need to specialize the trait for complex types as follows.
|
||||
|
||||
template <class T, class U>
|
||||
struct __common_type<complex<T>, complex<U> > {
|
||||
typedef complex< __common_type<T, U> > type;
|
||||
};
|
||||
|
||||
[h4 How important is the order of the common_type<> template arguments?]
|
||||
|
||||
The order of the template parameters is important.
|
||||
|
||||
`common_type<A,B,C>::type` is not equivalent to `common_type<C,A,B>::type`, but to `common_type<common_type<A,B>::type, C>::type`.
|
||||
|
||||
Consider
|
||||
|
||||
struct A {};
|
||||
struct B {};
|
||||
struct C {
|
||||
C() {}
|
||||
C(A const&) {}
|
||||
C(B const&) {}
|
||||
C& operator=(C const&) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
The following doesn't compile
|
||||
|
||||
typedef boost::common_type<A, B, C>::type ABC; // Does not compile
|
||||
|
||||
while
|
||||
|
||||
typedef boost::common_type<C, A, B>::type ABC;
|
||||
|
||||
compiles.
|
||||
|
||||
Thus, as `common_type<A,B>::type` is undefined, `common_type<A,B,C>::type` is also undefined.
|
||||
|
||||
It is intended that clients who wish for `common_type<A, B>` to be well
|
||||
defined to define it themselves:
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template <>
|
||||
struct common_type<A, B> {typedef C type;};
|
||||
|
||||
}
|
||||
|
||||
Now this client can ask for `common_type<A, B, C>` (and get
|
||||
the same answer).
|
||||
|
||||
Clients wanting to ask `common_type<A, B, C>` in any order and get the same result need to add in addition:
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template <> struct common_type<B, A>
|
||||
: public common_type<A, B> {};
|
||||
|
||||
}
|
||||
|
||||
This is needed as the specialization of `common_type<A, B>` is not be used implicitly for `common_type<B, A>`.
|
||||
|
||||
[h4 Can the common_type of two types be a third type?]
|
||||
|
||||
Given the preceding example, one might expect `common_type<A,B>::type` to be `C` without any intervention from the user.
|
||||
But the default `common_type<>` implementation doesn't grant that. It is intended that clients who wish for `common_type<A, B>`
|
||||
to be well defined to define it themselves:
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template <>
|
||||
struct common_type<A, B> {typedef C type;};
|
||||
|
||||
template <> struct common_type<B, A>
|
||||
: public common_type<A, B> {};
|
||||
|
||||
}
|
||||
|
||||
Now this client can ask for `common_type<A, B>`.
|
||||
|
||||
[h4 How common_type behaves with pointers?]
|
||||
|
||||
Consider
|
||||
|
||||
struct C { }:
|
||||
struct B : C { };
|
||||
struct A : C { };
|
||||
|
||||
|
||||
Shouldn't `common_type<A*,B*>::type` be `C*`? I would say yes, but the default implementation will make it ill-formed.
|
||||
|
||||
The library could add a specialization for pointers, as
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template <typename A, typename B>
|
||||
struct common_type<A*, B*> {
|
||||
typedef common_type<A, B>* type;
|
||||
};
|
||||
}
|
||||
|
||||
But in the absence of a motivating use cases, we prefer not to add more than the standard specifies.
|
||||
|
||||
Of course the user can always make this specialization.
|
||||
|
||||
[h4 Can you explain the pros/cons of common_type against Boost.Typeof?]
|
||||
|
||||
Even if they appear to be close, `__common_type` and `typeof` have
|
||||
different purposes. You use `typeof` to get the type of an expression, while
|
||||
you use __common_type to set explicitly the type returned of a template
|
||||
function. Both are complementary, and indeed __common_type is equivalent to
|
||||
`decltype(__declval<bool>() ? __declval<T>() : __declval<U>())`
|
||||
|
||||
__common_type is also similar to promote_args<class ...T> in boost/math/tools/promotion.hpp,
|
||||
though it is not exactly the same as promote_args either. __common_type<T1, T2>::type simply represents the result of some
|
||||
operation on T1 and T2, and defaults to the type obtained by putting T1 and T2 into a conditional statement.
|
||||
|
||||
It is meant to be customizable (via specialization) if this default is not appropriate.
|
||||
|
||||
[endsect]
|
||||
|
18
doc/conditional.qbk
Normal file
18
doc/conditional.qbk
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
[/===================================================================]
|
||||
[section:conditional conditional]
|
||||
[/===================================================================]
|
||||
|
||||
|
||||
`#include <boost/type_traits/conditional.hpp>`
|
||||
|
||||
namespace boost {
|
||||
template <bool B, class T, class U> struct __conditional;
|
||||
}
|
||||
|
||||
If B is true, the member typedef type shall equal T. If B is false, the member typedef type shall equal F.
|
||||
|
||||
This trait is really just an alias for `boost::mpl::if_c`.
|
||||
|
||||
[endsect]
|
||||
|
@@ -216,5 +216,22 @@ and enum types to double:
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:improved_min Improving std::min with common_type]
|
||||
|
||||
An improved `std::min` function could be written like this:
|
||||
|
||||
template <class T, class U>
|
||||
typename __common_type<T, U>::type min(T t, T u)
|
||||
{
|
||||
return t < u ? t : u;
|
||||
}
|
||||
|
||||
And now expressions such as:
|
||||
|
||||
min(1, 2.0)
|
||||
|
||||
will actually compile and return the correct type!
|
||||
|
||||
[endsect]
|
||||
[endsect]
|
||||
|
||||
|
@@ -7,6 +7,11 @@
|
||||
|
||||
[section:history History]
|
||||
|
||||
[h4 Boost 1.45.0]
|
||||
|
||||
* Added new traits __add_rvalue_reference, __add_lvalue_reference and __common_type.
|
||||
* Minor fixes to __is_signed, __is_unsigned and __is_virtual_base_of.
|
||||
|
||||
[h4 Boost 1.44.0]
|
||||
|
||||
* Added support for rvalue references throughout the library, plus two new traits classes
|
||||
|
@@ -56,7 +56,7 @@
|
||||
method available to them.
|
||||
</p>
|
||||
<a name="boost_typetraits.background.type_traits"></a><h5>
|
||||
<a name="id904364"></a>
|
||||
<a name="id991196"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.type_traits">Type Traits</a>
|
||||
</h5>
|
||||
<p>
|
||||
@@ -84,7 +84,7 @@
|
||||
given.
|
||||
</p>
|
||||
<a name="boost_typetraits.background.implementation"></a><h5>
|
||||
<a name="id904427"></a>
|
||||
<a name="id991259"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.implementation">Implementation</a>
|
||||
</h5>
|
||||
<p>
|
||||
@@ -174,7 +174,7 @@
|
||||
in the default template.
|
||||
</p>
|
||||
<a name="boost_typetraits.background.optimized_copy"></a><h5>
|
||||
<a name="id905164"></a>
|
||||
<a name="id999717"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.optimized_copy">Optimized copy</a>
|
||||
</h5>
|
||||
<p>
|
||||
@@ -247,7 +247,7 @@
|
||||
otherwise it will call the "slow but safe version".
|
||||
</p>
|
||||
<a name="boost_typetraits.background.was_it_worth_it_"></a><h5>
|
||||
<a name="id910514"></a>
|
||||
<a name="id1000085"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.was_it_worth_it_">Was it worth it?</a>
|
||||
</h5>
|
||||
<p>
|
||||
@@ -280,7 +280,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<div class="table">
|
||||
<a name="id910559"></a><p class="title"><b>Table 1.1. Time taken to copy 1000 elements using `copy<const T*, T*>` (times
|
||||
<a name="id1000130"></a><p class="title"><b>Table 1.1. Time taken to copy 1000 elements using `copy<const T*, T*>` (times
|
||||
in micro-seconds)</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Time taken to copy 1000 elements using `copy<const T*, T*>` (times
|
||||
in micro-seconds)">
|
||||
@@ -379,7 +379,7 @@
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><a name="boost_typetraits.background.pair_of_references"></a><h5>
|
||||
<a name="id910709"></a>
|
||||
<a name="id1000280"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.pair_of_references">Pair of References</a>
|
||||
</h5>
|
||||
<p>
|
||||
@@ -416,7 +416,7 @@
|
||||
to hold non-reference types, references, and constant references:
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id910970"></a><p class="title"><b>Table 1.2. Required Constructor Argument Types</b></p>
|
||||
<a name="id1000541"></a><p class="title"><b>Table 1.2. Required Constructor Argument Types</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Required Constructor Argument Types">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -481,7 +481,7 @@
|
||||
adds a reference to its type, unless it is already a reference.
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id911078"></a><p class="title"><b>Table 1.3. Using add_reference to synthesize the correct constructor type</b></p>
|
||||
<a name="id1000649"></a><p class="title"><b>Table 1.3. Using add_reference to synthesize the correct constructor type</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Using add_reference to synthesize the correct constructor type">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -597,7 +597,7 @@
|
||||
easier to maintain and easier to understand.
|
||||
</p>
|
||||
<a name="boost_typetraits.background.conclusion"></a><h5>
|
||||
<a name="id911547"></a>
|
||||
<a name="id1001118"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.conclusion">Conclusion</a>
|
||||
</h5>
|
||||
<p>
|
||||
@@ -610,7 +610,7 @@
|
||||
can be optimal as well as generic.
|
||||
</p>
|
||||
<a name="boost_typetraits.background.acknowledgements"></a><h5>
|
||||
<a name="id911564"></a>
|
||||
<a name="id1001135"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.acknowledgements">Acknowledgements</a>
|
||||
</h5>
|
||||
<p>
|
||||
@@ -618,7 +618,7 @@
|
||||
comments when preparing this article.
|
||||
</p>
|
||||
<a name="background.references"></a><a name="boost_typetraits.background.references"></a><h5>
|
||||
<a name="id911585"></a>
|
||||
<a name="id1001156"></a>
|
||||
<a class="link" href="background.html#boost_typetraits.background.references">References</a>
|
||||
</h5>
|
||||
<div class="orderedlist"><ol type="1">
|
||||
|
@@ -42,15 +42,27 @@
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/add_cv.html" title="add_cv">add_cv</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/add_lvalue_reference.html" title="add_lvalue_reference">add_lvalue_reference</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/add_pointer.html" title="add_pointer">add_pointer</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/add_reference.html" title="add_reference">add_reference</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/add_rvalue_reference.html" title="add_rvalue_reference">add_rvalue_reference</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/add_volatile.html" title="add_volatile">add_volatile</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">bool</span> <span class="identifier">B</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/conditional.html" title="conditional">conditional</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span><span class="special">...</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/common_type.html" title="common_type">common_type</a><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/decay.html" title="decay">decay</a><span class="special">;</span>
|
||||
|
||||
@@ -91,7 +103,7 @@
|
||||
<span class="keyword">struct</span> <a class="link" href="../reference/remove_volatile.html" title="remove_volatile">remove_volatile</a><span class="special">;</span>
|
||||
</pre>
|
||||
<a name="boost_typetraits.category.transform.broken_compiler_workarounds_"></a><h5>
|
||||
<a name="id915484"></a>
|
||||
<a name="id1005216"></a>
|
||||
<a class="link" href="transform.html#boost_typetraits.category.transform.broken_compiler_workarounds_">Broken
|
||||
Compiler Workarounds:</a>
|
||||
</h5>
|
||||
|
@@ -37,6 +37,8 @@
|
||||
of std::iter_swap</a></span></dt>
|
||||
<dt><span class="section"><a href="examples/to_double.html"> Convert Numeric
|
||||
Types and Enums to double</a></span></dt>
|
||||
<dt><span class="section"><a href="examples/improved_min.html"> Improving std::min
|
||||
with common_type</a></span></dt>
|
||||
</dl></div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
|
64
doc/html/boost_typetraits/examples/improved_min.html
Normal file
64
doc/html/boost_typetraits/examples/improved_min.html
Normal file
@@ -0,0 +1,64 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>Improving std::min with common_type</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../examples.html" title="Examples">
|
||||
<link rel="prev" href="to_double.html" title="Convert Numeric Types and Enums to double">
|
||||
<link rel="next" href="../reference.html" title="Alphabetical Reference">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="to_double.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_typetraits.examples.improved_min"></a><a class="link" href="improved_min.html" title="Improving std::min with common_type"> Improving std::min
|
||||
with common_type</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
An improved <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">min</span></code> function could be written like this:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">typename</span> <a class="link" href="../reference/common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">U</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">min</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">t</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">u</span><span class="special">)</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="identifier">t</span> <span class="special"><</span> <span class="identifier">u</span> <span class="special">?</span> <span class="identifier">t</span> <span class="special">:</span> <span class="identifier">u</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
And now expressions such as:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="identifier">min</span><span class="special">(</span><span class="number">1</span><span class="special">,</span> <span class="number">2.0</span><span class="special">)</span>
|
||||
</pre>
|
||||
<p>
|
||||
will actually compile and return the correct type!
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
|
||||
Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat
|
||||
Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert
|
||||
Ramey and Jeremy Siek<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="to_double.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -7,7 +7,7 @@
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../examples.html" title="Examples">
|
||||
<link rel="prev" href="iter.html" title="An improved Version of std::iter_swap">
|
||||
<link rel="next" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="next" href="improved_min.html" title="Improving std::min with common_type">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="iter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="iter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="improved_min.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
@@ -52,7 +52,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="iter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="iter.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../examples.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="improved_min.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -26,8 +26,24 @@
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
<a name="boost_typetraits.history"></a><a class="link" href="history.html" title="History"> History</a>
|
||||
</h2></div></div></div>
|
||||
<a name="boost_typetraits.history.boost_1_45_0"></a><h5>
|
||||
<a name="id1061133"></a>
|
||||
<a class="link" href="history.html#boost_typetraits.history.boost_1_45_0">Boost 1.45.0</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul type="disc">
|
||||
<li>
|
||||
Added new traits <a class="link" href="reference/add_rvalue_reference.html" title="add_rvalue_reference">add_rvalue_reference</a>,
|
||||
<a class="link" href="reference/add_lvalue_reference.html" title="add_lvalue_reference">add_lvalue_reference</a>
|
||||
and <a class="link" href="reference/common_type.html" title="common_type">common_type</a>.
|
||||
</li>
|
||||
<li>
|
||||
Minor fixes to <a class="link" href="reference/is_signed.html" title="is_signed">is_signed</a>,
|
||||
<a class="link" href="reference/is_unsigned.html" title="is_unsigned">is_unsigned</a>
|
||||
and <a class="link" href="reference/is_virtual_base_of.html" title="is_virtual_base_of">is_virtual_base_of</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="boost_typetraits.history.boost_1_44_0"></a><h5>
|
||||
<a name="id965403"></a>
|
||||
<a name="id1061193"></a>
|
||||
<a class="link" href="history.html#boost_typetraits.history.boost_1_44_0">Boost 1.44.0</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul type="disc">
|
||||
@@ -43,7 +59,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<a name="boost_typetraits.history.boost_1_42_0"></a><h5>
|
||||
<a name="id965458"></a>
|
||||
<a name="id1061249"></a>
|
||||
<a class="link" href="history.html#boost_typetraits.history.boost_1_42_0">Boost 1.42.0</a>
|
||||
</h5>
|
||||
<div class="itemizedlist"><ul type="disc"><li>
|
||||
|
@@ -99,7 +99,7 @@
|
||||
of the following macros:
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id917632"></a><p class="title"><b>Table 1.4. Macros for Compiler Intrinsics</b></p>
|
||||
<a name="id1006817"></a><p class="title"><b>Table 1.4. Macros for Compiler Intrinsics</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Macros for Compiler Intrinsics">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="prev" href="examples/to_double.html" title="Convert Numeric Types and Enums to double">
|
||||
<link rel="prev" href="examples/improved_min.html" title="Improving std::min with common_type">
|
||||
<link rel="next" href="reference/add_const.html" title="add_const">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="examples/to_double.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference/add_const.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="examples/improved_min.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference/add_const.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||
@@ -29,11 +29,15 @@
|
||||
<div class="toc"><dl>
|
||||
<dt><span class="section"><a href="reference/add_const.html"> add_const</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/add_cv.html"> add_cv</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/add_lvalue_reference.html"> add_lvalue_reference</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/add_pointer.html"> add_pointer</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/add_reference.html"> add_reference</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/add_rvalue_reference.html"> add_rvalue_reference</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/add_volatile.html"> add_volatile</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/aligned_storage.html"> aligned_storage</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/alignment_of.html"> alignment_of</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/conditional.html"> conditional</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/common_type.html"> common_type</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/decay.html"> decay</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/extent.html"> extent</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/floating_point_promotion.html">
|
||||
@@ -105,6 +109,10 @@
|
||||
<dt><span class="section"><a href="reference/remove_volatile.html"> remove_volatile</a></span></dt>
|
||||
<dt><span class="section"><a href="reference/type_with_alignment.html"> type_with_alignment</a></span></dt>
|
||||
</dl></div>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
@@ -119,7 +127,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="examples/to_double.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference/add_const.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="examples/improved_min.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="reference/add_const.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -53,7 +53,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id923691"></a><p class="title"><b>Table 1.5. Examples</b></p>
|
||||
<a name="id1013096"></a><p class="title"><b>Table 1.5. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="add_const.html" title="add_const">
|
||||
<link rel="next" href="add_pointer.html" title="add_pointer">
|
||||
<link rel="next" href="add_lvalue_reference.html" title="add_lvalue_reference">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_const.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_pointer.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_const.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_lvalue_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
@@ -54,7 +54,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id924169"></a><p class="title"><b>Table 1.6. Examples</b></p>
|
||||
<a name="id1013574"></a><p class="title"><b>Table 1.6. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -142,7 +142,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_const.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_pointer.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_const.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_lvalue_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
174
doc/html/boost_typetraits/reference/add_lvalue_reference.html
Normal file
174
doc/html/boost_typetraits/reference/add_lvalue_reference.html
Normal file
@@ -0,0 +1,174 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>add_lvalue_reference</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="add_cv.html" title="add_cv">
|
||||
<link rel="next" href="add_pointer.html" title="add_pointer">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_cv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_pointer.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_typetraits.reference.add_lvalue_reference"></a><a class="link" href="add_lvalue_reference.html" title="add_lvalue_reference"> add_lvalue_reference</a>
|
||||
</h3></div></div></div>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">add_lvalue_reference</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <em class="replaceable"><code>see-below</code></em> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
<span class="bold"><strong>type:</strong></span> If <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
names an object or function type then the member typedef <code class="computeroutput"><span class="identifier">type</span></code>
|
||||
shall name <code class="computeroutput"><span class="identifier">T</span><span class="special">&</span></code>;
|
||||
otherwise, if <code class="computeroutput"><span class="identifier">T</span></code> names a type
|
||||
<span class="emphasis"><em>rvalue reference to U</em></span> then the member typedef type shall
|
||||
name <code class="computeroutput"><span class="identifier">U</span><span class="special">&</span></code>;
|
||||
otherwise, type shall name <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>C++ Standard Reference:</strong></span> 20.7.6.2.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>Compiler Compatibility:</strong></span> If the compiler
|
||||
does not support partial specialization of class-templates then this template
|
||||
will compile, but the member <code class="computeroutput"><span class="identifier">type</span></code>
|
||||
will always be the same as type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
except where <a class="link" href="../category/transform.html#boost_typetraits.category.transform.broken_compiler_workarounds_">compiler
|
||||
workarounds</a> have been applied.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>Header:</strong></span> <code class="computeroutput"> <span class="preprocessor">#include</span>
|
||||
<span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">add_lvalue_reference</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id1014096"></a><p class="title"><b>Table 1.7. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Expression
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Result Type
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_lvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_lvalue_reference</span><span class="special"><</span><span class="keyword">int</span>
|
||||
<span class="keyword">const</span><span class="special">&>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span> <span class="keyword">const</span><span class="special">&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_lvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">*>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">*&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_lvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">*&>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">*&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_lvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">&&>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_lvalue_reference</span><span class="special"><</span><span class="keyword">void</span><span class="special">>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">void</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break">
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
|
||||
Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat
|
||||
Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert
|
||||
Ramey and Jeremy Siek<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_cv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_pointer.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="add_cv.html" title="add_cv">
|
||||
<link rel="prev" href="add_lvalue_reference.html" title="add_lvalue_reference">
|
||||
<link rel="next" href="add_reference.html" title="add_reference">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_cv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_lvalue_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
@@ -56,7 +56,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id924698"></a><p class="title"><b>Table 1.7. Examples</b></p>
|
||||
<a name="id1014706"></a><p class="title"><b>Table 1.8. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -141,7 +141,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_cv.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_lvalue_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="add_pointer.html" title="add_pointer">
|
||||
<link rel="next" href="add_volatile.html" title="add_volatile">
|
||||
<link rel="next" href="add_rvalue_reference.html" title="add_rvalue_reference">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
@@ -20,12 +20,24 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_pointer.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_volatile.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_pointer.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_rvalue_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_typetraits.reference.add_reference"></a><a class="link" href="add_reference.html" title="add_reference"> add_reference</a>
|
||||
</h3></div></div></div>
|
||||
<div class="note"><table border="0" summary="Note">
|
||||
<tr>
|
||||
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
|
||||
<th align="left">Note</th>
|
||||
</tr>
|
||||
<tr><td align="left" valign="top"><p>
|
||||
This trait has been made obsolete by <a class="link" href="add_lvalue_reference.html" title="add_lvalue_reference">add_lvalue_reference</a>
|
||||
and <a class="link" href="add_rvalue_reference.html" title="add_rvalue_reference">add_rvalue_reference</a>,
|
||||
and new code should use these new traits rather than <a class="link" href="is_reference.html" title="is_reference">is_reference</a>
|
||||
which is retained for backwards compatibility only.
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">add_reference</span>
|
||||
<span class="special">{</span>
|
||||
@@ -53,7 +65,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id925175"></a><p class="title"><b>Table 1.8. Examples</b></p>
|
||||
<a name="id1015204"></a><p class="title"><b>Table 1.9. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -138,7 +150,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_pointer.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_volatile.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_pointer.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_rvalue_reference.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
172
doc/html/boost_typetraits/reference/add_rvalue_reference.html
Normal file
172
doc/html/boost_typetraits/reference/add_rvalue_reference.html
Normal file
@@ -0,0 +1,172 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>add_rvalue_reference</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="add_reference.html" title="add_reference">
|
||||
<link rel="next" href="add_volatile.html" title="add_volatile">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_volatile.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_typetraits.reference.add_rvalue_reference"></a><a class="link" href="add_rvalue_reference.html" title="add_rvalue_reference"> add_rvalue_reference</a>
|
||||
</h3></div></div></div>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">add_rvalue_reference</span>
|
||||
<span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <em class="replaceable"><code>see-below</code></em> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
<span class="bold"><strong>type:</strong></span> If <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
names an object or function type then the member typedef type shall name
|
||||
<code class="computeroutput"><span class="identifier">T</span><span class="special">&&</span></code>;
|
||||
otherwise, type shall name <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||
<span class="emphasis"><em>[Note: This rule reflects the semantics of reference collapsing.
|
||||
For example, when a type <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
names a type U&, the type <code class="computeroutput"><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span></code> is not an rvalue reference. -end note]</em></span>.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>C++ Standard Reference:</strong></span> 20.7.6.2.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>Compiler Compatibility:</strong></span> If the compiler
|
||||
does not support partial specialization of class-templates and rvalue references
|
||||
then this template will compile, but the member <code class="computeroutput"><span class="identifier">type</span></code>
|
||||
will always be the same as type <code class="computeroutput"><span class="identifier">T</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>Header:</strong></span> <code class="computeroutput"> <span class="preprocessor">#include</span>
|
||||
<span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">add_rvalue_reference</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id1015708"></a><p class="title"><b>Table 1.10. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
<p>
|
||||
Expression
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
Result Type
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">&&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="keyword">int</span>
|
||||
<span class="keyword">const</span><span class="special">&>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span> <span class="keyword">const</span><span class="special">&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">*>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">*&&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">*&>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">*&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="keyword">int</span><span class="special">&&>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">int</span><span class="special">&&</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">add_rvalue_reference</span><span class="special"><</span><span class="keyword">void</span><span class="special">>::</span><span class="identifier">type</span></code>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="keyword">void</span></code>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break">
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
|
||||
Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat
|
||||
Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert
|
||||
Ramey and Jeremy Siek<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="add_volatile.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="add_reference.html" title="add_reference">
|
||||
<link rel="prev" href="add_rvalue_reference.html" title="add_rvalue_reference">
|
||||
<link rel="next" href="aligned_storage.html" title="aligned_storage">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="aligned_storage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_rvalue_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="aligned_storage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
@@ -53,7 +53,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id925645"></a><p class="title"><b>Table 1.9. Examples</b></p>
|
||||
<a name="id1017914"></a><p class="title"><b>Table 1.11. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -140,7 +140,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="add_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="aligned_storage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="add_rvalue_reference.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="aligned_storage.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="aligned_storage.html" title="aligned_storage">
|
||||
<link rel="next" href="decay.html" title="decay">
|
||||
<link rel="next" href="conditional.html" title="conditional">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="aligned_storage.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="decay.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="aligned_storage.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="conditional.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
@@ -76,7 +76,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="aligned_storage.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="decay.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="aligned_storage.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="conditional.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
350
doc/html/boost_typetraits/reference/common_type.html
Normal file
350
doc/html/boost_typetraits/reference/common_type.html
Normal file
@@ -0,0 +1,350 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>common_type</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="conditional.html" title="conditional">
|
||||
<link rel="next" href="decay.html" title="decay">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="conditional.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="decay.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_typetraits.reference.common_type"></a><a class="link" href="common_type.html" title="common_type"> common_type</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">common_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">struct</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
is a traits class used to deduce a type common to a several types, useful
|
||||
as the return type of functions operating on multiple input types such as
|
||||
in mixed-mode arithmetic..
|
||||
</p>
|
||||
<p>
|
||||
The nested typedef <code class="computeroutput"><span class="special">::</span><span class="identifier">type</span></code>
|
||||
could be defined as follows:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">V</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">U</span><span class="special">,...</span><span class="identifier">V</span><span class="special">></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="keyword">typename</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">U</span><span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="identifier">V</span><span class="special">...>::</span><span class="identifier">type</span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">T</span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">U</span><span class="special">></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">decltype</span><span class="special">(</span><a href="../../../../../utility/doc/html/declval.html" target="_top">declval</a><span class="special"><</span><span class="keyword">bool</span><span class="special">>()</span> <span class="special">?</span> <a href="../../../../../utility/doc/html/declval.html" target="_top">declval</a><span class="special"><</span><span class="identifier">T</span><span class="special">>()</span> <span class="special">:</span> <a href="../../../../../utility/doc/html/declval.html" target="_top">declval</a><span class="special"><</span><span class="identifier">U</span><span class="special">>())</span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
All parameter types must be complete. This trait is permitted to be specialized
|
||||
by a user if at least one template parameter is a user-defined type. <span class="bold"><strong>Note:</strong></span> Such specializations are required when only
|
||||
explicit conversions are desired among the <a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
arguments.
|
||||
</p>
|
||||
<p>
|
||||
Note that when the compiler does not support variadic templates (and the
|
||||
macro BOOST_NO_VARIADIC_TEMPLATES is defined) then the maximum number of
|
||||
template arguments is 3.
|
||||
</p>
|
||||
<a name="boost_typetraits.reference.common_type.configuration_macros"></a><h5>
|
||||
<a name="id1019667"></a>
|
||||
<a class="link" href="common_type.html#boost_typetraits.reference.common_type.configuration_macros">Configuration
|
||||
macros</a>
|
||||
</h5>
|
||||
<p>
|
||||
When the compiler does not support static assertions then the user can select
|
||||
the way static assertions are reported. Define
|
||||
</p>
|
||||
<div class="itemizedlist"><ul type="disc">
|
||||
<li>
|
||||
BOOST_COMMON_TYPE_USES_STATIC_ASSERT: define it if you want to use Boost.StaticAssert
|
||||
</li>
|
||||
<li>
|
||||
BOOST_COMMON_TYPE_USES_MPL_ASSERT: define it if you want to use Boost.MPL
|
||||
static asertions
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The default behavior is to use mpl assertions in this case, but setting BOOST_COMMON_TYPE_USES_STATIC_ASSERT
|
||||
may reduce compile times and header dependencies somewhat.
|
||||
</p>
|
||||
<p>
|
||||
Depending on the static assertion used you will have an hint of the failing
|
||||
assertion either through the symbol or through the text.
|
||||
</p>
|
||||
<p>
|
||||
When possible common_type is implemented using <code class="computeroutput"><span class="identifier">decltype</span></code>.
|
||||
Otherwise when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is not defined it uses Boost.TypeOf.
|
||||
</p>
|
||||
<a name="boost_typetraits.reference.common_type.tutorial"></a><h5>
|
||||
<a name="id1019723"></a>
|
||||
<a class="link" href="common_type.html#boost_typetraits.reference.common_type.tutorial">Tutorial</a>
|
||||
</h5>
|
||||
<p>
|
||||
In a nutshell, <a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
is a trait that takes 1 or more types, and returns a type which all of the
|
||||
types will convert to. The default definition demands this conversion be
|
||||
implicit. However the trait can be specialized for user-defined types which
|
||||
want to limit their inter-type conversions to explicit, and yet still want
|
||||
to interoperate with the <a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
facility.
|
||||
</p>
|
||||
<p>
|
||||
<span class="bold"><strong>Example:</strong></span>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="identifier">complex</span><span class="special"><</span><span class="keyword">typename</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">U</span><span class="special">>::</span><span class="identifier">type</span><span class="special">></span>
|
||||
<span class="keyword">operator</span><span class="special">+(</span><span class="identifier">complex</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> <span class="identifier">complex</span><span class="special"><</span><span class="identifier">U</span><span class="special">>);</span>
|
||||
</pre>
|
||||
<p>
|
||||
In the above example, "mixed-mode" complex arithmetic is allowed.
|
||||
The return type is described by <a class="link" href="common_type.html" title="common_type">common_type</a>.
|
||||
For example the resulting type of adding a <code class="computeroutput"><span class="identifier">complex</span><span class="special"><</span><span class="keyword">float</span><span class="special">></span></code> and <code class="computeroutput"><span class="identifier">complex</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span></code> might be a <code class="computeroutput"><span class="identifier">complex</span><span class="special"><</span><span class="keyword">double</span><span class="special">></span></code>.
|
||||
</p>
|
||||
<p>
|
||||
Here is how someone might produce a variadic comparison function:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">typename</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="identifier">T</span><span class="special">...>::</span><span class="identifier">type</span>
|
||||
<span class="identifier">min</span><span class="special">(</span><span class="identifier">T</span><span class="special">...</span> <span class="identifier">t</span><span class="special">);</span>
|
||||
</pre>
|
||||
<p>
|
||||
This is a very useful and broadly applicable utility.
|
||||
</p>
|
||||
<a name="boost_typetraits.reference.common_type.how_to_get_the_common_type_of_types_with_explicit_conversions_"></a><h5>
|
||||
<a name="id1020024"></a>
|
||||
<a class="link" href="common_type.html#boost_typetraits.reference.common_type.how_to_get_the_common_type_of_types_with_explicit_conversions_">How
|
||||
to get the common type of types with explicit conversions?</a>
|
||||
</h5>
|
||||
<p>
|
||||
Another choice for the author of the preceding operator could be
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">typename</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="identifier">complex</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> <span class="identifier">complex</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span> <span class="special">>::</span><span class="identifier">type</span>
|
||||
<span class="keyword">operator</span><span class="special">+(</span><span class="identifier">complex</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> <span class="identifier">complex</span><span class="special"><</span><span class="identifier">U</span><span class="special">>);</span>
|
||||
</pre>
|
||||
<p>
|
||||
As the default definition of <a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
demands the conversion be implicit, we need to specialize the trait for complex
|
||||
types as follows.
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="identifier">complex</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> <span class="identifier">complex</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span> <span class="special">></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">complex</span><span class="special"><</span> <a class="link" href="common_type.html" title="common_type">common_type</a><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">U</span><span class="special">></span> <span class="special">></span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<a name="boost_typetraits.reference.common_type.how_important_is_the_order_of_the_common_type_lt__gt__template_arguments_"></a><h5>
|
||||
<a name="id1020324"></a>
|
||||
<a class="link" href="common_type.html#boost_typetraits.reference.common_type.how_important_is_the_order_of_the_common_type_lt__gt__template_arguments_">How
|
||||
important is the order of the common_type<> template arguments?</a>
|
||||
</h5>
|
||||
<p>
|
||||
The order of the template parameters is important.
|
||||
</p>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">>::</span><span class="identifier">type</span></code> is not equivalent to <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">C</span><span class="special">,</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">>::</span><span class="identifier">type</span></code>, but to <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="identifier">C</span><span class="special">>::</span><span class="identifier">type</span></code>.
|
||||
</p>
|
||||
<p>
|
||||
Consider
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">A</span> <span class="special">{};</span>
|
||||
<span class="keyword">struct</span> <span class="identifier">B</span> <span class="special">{};</span>
|
||||
<span class="keyword">struct</span> <span class="identifier">C</span> <span class="special">{</span>
|
||||
<span class="identifier">C</span><span class="special">()</span> <span class="special">{}</span>
|
||||
<span class="identifier">C</span><span class="special">(</span><span class="identifier">A</span> <span class="keyword">const</span><span class="special">&)</span> <span class="special">{}</span>
|
||||
<span class="identifier">C</span><span class="special">(</span><span class="identifier">B</span> <span class="keyword">const</span><span class="special">&)</span> <span class="special">{}</span>
|
||||
<span class="identifier">C</span><span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="identifier">C</span> <span class="keyword">const</span><span class="special">&)</span> <span class="special">{</span>
|
||||
<span class="keyword">return</span> <span class="special">*</span><span class="keyword">this</span><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
The following doesn't compile
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">,</span> <span class="identifier">C</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">ABC</span><span class="special">;</span> <span class="comment">// Does not compile
|
||||
</span></pre>
|
||||
<p>
|
||||
while
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">C</span><span class="special">,</span> <span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">ABC</span><span class="special">;</span>
|
||||
</pre>
|
||||
<p>
|
||||
compiles.
|
||||
</p>
|
||||
<p>
|
||||
Thus, as <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">>::</span><span class="identifier">type</span></code>
|
||||
is undefined, <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">,</span><span class="identifier">C</span><span class="special">>::</span><span class="identifier">type</span></code>
|
||||
is also undefined.
|
||||
</p>
|
||||
<p>
|
||||
It is intended that clients who wish for <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span>
|
||||
<span class="identifier">B</span><span class="special">></span></code>
|
||||
to be well defined to define it themselves:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
|
||||
<span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">></span> <span class="special">{</span><span class="keyword">typedef</span> <span class="identifier">C</span> <span class="identifier">type</span><span class="special">;};</span>
|
||||
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
Now this client can ask for <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span>
|
||||
<span class="identifier">B</span><span class="special">,</span> <span class="identifier">C</span><span class="special">></span></code> (and
|
||||
get the same answer).
|
||||
</p>
|
||||
<p>
|
||||
Clients wanting to ask <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span>
|
||||
<span class="identifier">B</span><span class="special">,</span> <span class="identifier">C</span><span class="special">></span></code> in
|
||||
any order and get the same result need to add in addition:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
|
||||
<span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><></span> <span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span> <span class="identifier">A</span><span class="special">></span>
|
||||
<span class="special">:</span> <span class="keyword">public</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">></span> <span class="special">{};</span>
|
||||
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
This is needed as the specialization of <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span>
|
||||
<span class="identifier">B</span><span class="special">></span></code>
|
||||
is not be used implicitly for <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span>
|
||||
<span class="identifier">A</span><span class="special">></span></code>.
|
||||
</p>
|
||||
<a name="boost_typetraits.reference.common_type.can_the_common_type_of_two_types_be_a_third_type_"></a><h5>
|
||||
<a name="id1021192"></a>
|
||||
<a class="link" href="common_type.html#boost_typetraits.reference.common_type.can_the_common_type_of_two_types_be_a_third_type_">Can
|
||||
the common_type of two types be a third type?</a>
|
||||
</h5>
|
||||
<p>
|
||||
Given the preceding example, one might expect <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span><span class="identifier">B</span><span class="special">>::</span><span class="identifier">type</span></code> to be <code class="computeroutput"><span class="identifier">C</span></code>
|
||||
without any intervention from the user. But the default <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><></span></code> implementation doesn't grant that.
|
||||
It is intended that clients who wish for <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span>
|
||||
<span class="identifier">B</span><span class="special">></span></code>
|
||||
to be well defined to define it themselves:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
|
||||
<span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">></span> <span class="special">{</span><span class="keyword">typedef</span> <span class="identifier">C</span> <span class="identifier">type</span><span class="special">;};</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><></span> <span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">B</span><span class="special">,</span> <span class="identifier">A</span><span class="special">></span>
|
||||
<span class="special">:</span> <span class="keyword">public</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">></span> <span class="special">{};</span>
|
||||
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
Now this client can ask for <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span>
|
||||
<span class="identifier">B</span><span class="special">></span></code>.
|
||||
</p>
|
||||
<a name="boost_typetraits.reference.common_type.how_common_type_behaves_with_pointers_"></a><h5>
|
||||
<a name="id1021474"></a>
|
||||
<a class="link" href="common_type.html#boost_typetraits.reference.common_type.how_common_type_behaves_with_pointers_">How
|
||||
common_type behaves with pointers?</a>
|
||||
</h5>
|
||||
<p>
|
||||
Consider
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">C</span> <span class="special">{</span> <span class="special">}:</span>
|
||||
<span class="keyword">struct</span> <span class="identifier">B</span> <span class="special">:</span> <span class="identifier">C</span> <span class="special">{</span> <span class="special">};</span>
|
||||
<span class="keyword">struct</span> <span class="identifier">A</span> <span class="special">:</span> <span class="identifier">C</span> <span class="special">{</span> <span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
Shouldn't <code class="computeroutput"><span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">*,</span><span class="identifier">B</span><span class="special">*>::</span><span class="identifier">type</span></code>
|
||||
be <code class="computeroutput"><span class="identifier">C</span><span class="special">*</span></code>?
|
||||
I would say yes, but the default implementation will make it ill-formed.
|
||||
</p>
|
||||
<p>
|
||||
The library could add a specialization for pointers, as
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
|
||||
<span class="special">{</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">A</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">B</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">*,</span> <span class="identifier">B</span><span class="special">*></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">A</span><span class="special">,</span> <span class="identifier">B</span><span class="special">>*</span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
But in the absence of a motivating use cases, we prefer not to add more than
|
||||
the standard specifies.
|
||||
</p>
|
||||
<p>
|
||||
Of course the user can always make this specialization.
|
||||
</p>
|
||||
<a name="boost_typetraits.reference.common_type.can_you_explain_the_pros_cons_of_common_type_against_boost_typeof_"></a><h5>
|
||||
<a name="id1021758"></a>
|
||||
<a class="link" href="common_type.html#boost_typetraits.reference.common_type.can_you_explain_the_pros_cons_of_common_type_against_boost_typeof_">Can
|
||||
you explain the pros/cons of common_type against Boost.Typeof?</a>
|
||||
</h5>
|
||||
<p>
|
||||
Even if they appear to be close, <code class="computeroutput"><a class="link" href="common_type.html" title="common_type">common_type</a></code>
|
||||
and <code class="computeroutput"><span class="identifier">typeof</span></code> have different
|
||||
purposes. You use <code class="computeroutput"><span class="identifier">typeof</span></code>
|
||||
to get the type of an expression, while you use <a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
to set explicitly the type returned of a template function. Both are complementary,
|
||||
and indeed <a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
is equivalent to <code class="computeroutput"><span class="identifier">decltype</span><span class="special">(</span><a href="../../../../../utility/doc/html/declval.html" target="_top">declval</a><span class="special"><</span><span class="keyword">bool</span><span class="special">>()</span>
|
||||
<span class="special">?</span> <a href="../../../../../utility/doc/html/declval.html" target="_top">declval</a><span class="special"><</span><span class="identifier">T</span><span class="special">>()</span>
|
||||
<span class="special">:</span> <a href="../../../../../utility/doc/html/declval.html" target="_top">declval</a><span class="special"><</span><span class="identifier">U</span><span class="special">>())</span></code>
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="common_type.html" title="common_type">common_type</a>
|
||||
is also similar to promote_args<class ...T> in boost/math/tools/promotion.hpp,
|
||||
though it is not exactly the same as promote_args either. <a class="link" href="common_type.html" title="common_type">common_type</a><T1,
|
||||
T2>::type simply represents the result of some operation on T1 and T2,
|
||||
and defaults to the type obtained by putting T1 and T2 into a conditional
|
||||
statement.
|
||||
</p>
|
||||
<p>
|
||||
It is meant to be customizable (via specialization) if this default is not
|
||||
appropriate.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
|
||||
Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat
|
||||
Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert
|
||||
Ramey and Jeremy Siek<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="conditional.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="decay.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
117
doc/html/boost_typetraits/reference/common_type_hpp.html
Normal file
117
doc/html/boost_typetraits/reference/common_type_hpp.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
||||
<title>common_type</title>
|
||||
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="alignment_of.html" title="alignment_of">
|
||||
<link rel="next" href="decay.html" title="decay">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
<table cellpadding="2" width="100%"><tr>
|
||||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||
<td align="center"><a href="../../../../../../index.html">Home</a></td>
|
||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="alignment_of.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="decay.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="boost_typetraits.reference.common_type_hpp"></a><a class="link" href="common_type_hpp.html" title="common_type"> common_type</a>
|
||||
</h3></div></div></div>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">/</span><span class="identifier">common_type</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">T</span><span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../../">common_type</a><span class="special">;</span>
|
||||
<span class="special">}</span>
|
||||
</pre>
|
||||
<p>
|
||||
<a class="link" href="../../">common_type</a>
|
||||
is a traits class used to deduce a type common to a several types, useful
|
||||
as the return type of functions operating on multiple input types such as
|
||||
in mixed-mode arithmetic..
|
||||
</p>
|
||||
<p>
|
||||
The nested typedef <code class="computeroutput"><span class="special">::</span><span class="identifier">type</span></code>
|
||||
could be defined as follows:
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special">;</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">V</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span><span class="identifier">U</span><span class="special">,...</span><span class="identifier">V</span><span class="special">></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">__common_type__</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">__common_type__</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">U</span><span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="identifier">V</span><span class="special">...>::</span><span class="identifier">type</span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">T</span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
|
||||
<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">></span>
|
||||
<span class="keyword">struct</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">U</span><span class="special">></span> <span class="special">{</span>
|
||||
<span class="keyword">typedef</span> <span class="identifier">decltype</span><span class="special">(</span><span class="identifier">__declval__</span><span class="special"><</span><span class="keyword">bool</span><span class="special">>()</span> <span class="special">?</span> <span class="identifier">__declval__</span><span class="special"><</span><span class="identifier">T</span><span class="special">>()</span> <span class="special">:</span> <span class="identifier">__declval__</span><span class="special"><</span><span class="identifier">U</span><span class="special">>())</span> <span class="identifier">type</span><span class="special">;</span>
|
||||
<span class="special">};</span>
|
||||
</pre>
|
||||
<p>
|
||||
All parameter types must be complete. This trait is permitted to be specialized
|
||||
by a user if at least one template parameter is a user-defined type. <span class="bold"><strong>Note:</strong></span> Such specializations are required when only
|
||||
explicit conversions are desired among the <a class="link" href="../../">common_type</a>
|
||||
arguments.
|
||||
</p>
|
||||
<a name="boost_typetraits.reference.common_type_hpp.configuration_macros"></a><h5>
|
||||
<a name="id895242"></a>
|
||||
<a class="link" href="common_type_hpp.html#boost_typetraits.reference.common_type_hpp.configuration_macros">Configuration
|
||||
macros</a>
|
||||
</h5>
|
||||
<p>
|
||||
When the compiler does not support static assertions then the user can select
|
||||
the way static assertions are reported. Define
|
||||
</p>
|
||||
<div class="itemizedlist"><ul type="disc">
|
||||
<li>
|
||||
BOOST_COMMON_TYPE_USES_STATIC_ASSERT: define it if you want to use Boost.StaticAssert
|
||||
</li>
|
||||
<li>
|
||||
BOOST_COMMON_TYPE_USES_MPL_ASSERT: define it if you want to use Boost.MPL
|
||||
static asertions
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
The default behavior is to use mpl assertions in this case, but setting BOOST_COMMON_TYPE_USES_STATIC_ASSERT
|
||||
may reduce compile times and header dependencies somewhat.
|
||||
</p>
|
||||
<p>
|
||||
Depending on the static assertion used you will have an hint of the failing
|
||||
assertion either through the symbol or through the text.
|
||||
</p>
|
||||
<p>
|
||||
When possible common_type is implemented using <code class="computeroutput"><span class="identifier">decltype</span></code>.
|
||||
Otherwise when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is not defined it uses Boost.TypeOf.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2000, 2006 Adobe Systems Inc, David Abrahams,
|
||||
Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat
|
||||
Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert
|
||||
Ramey and Jeremy Siek<p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="alignment_of.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="decay.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@@ -6,7 +6,7 @@
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
|
||||
<link rel="home" href="../../index.html" title="Chapter 1. Boost.TypeTraits">
|
||||
<link rel="up" href="../reference.html" title="Alphabetical Reference">
|
||||
<link rel="prev" href="alignment_of.html" title="alignment_of">
|
||||
<link rel="prev" href="common_type.html" title="common_type">
|
||||
<link rel="next" href="extent.html" title="extent">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||
@@ -20,7 +20,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="alignment_of.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="extent.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="common_type.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="extent.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section" lang="en">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
@@ -48,7 +48,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id926890"></a><p class="title"><b>Table 1.10. Examples</b></p>
|
||||
<a name="id1023240"></a><p class="title"><b>Table 1.12. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -145,7 +145,7 @@
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="alignment_of.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="extent.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
<a accesskey="p" href="common_type.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="extent.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -49,7 +49,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id930080"></a><p class="title"><b>Table 1.11. Examples</b></p>
|
||||
<a name="id1024792"></a><p class="title"><b>Table 1.13. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -59,7 +59,7 @@
|
||||
</p></td></tr>
|
||||
</table></div>
|
||||
<div class="table">
|
||||
<a name="id930453"></a><p class="title"><b>Table 1.12. Function Traits Members</b></p>
|
||||
<a name="id1025712"></a><p class="title"><b>Table 1.14. Function Traits Members</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Function Traits Members">
|
||||
<colgroup>
|
||||
<col>
|
||||
@@ -122,7 +122,7 @@
|
||||
</table></div>
|
||||
</div>
|
||||
<br class="table-break"><div class="table">
|
||||
<a name="id930671"></a><p class="title"><b>Table 1.13. Examples</b></p>
|
||||
<a name="id1025929"></a><p class="title"><b>Table 1.15. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -49,7 +49,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id936317"></a><p class="title"><b>Table 1.14. Examples</b></p>
|
||||
<a name="id1032258"></a><p class="title"><b>Table 1.16. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -54,7 +54,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id956877"></a><p class="title"><b>Table 1.15. Examples</b></p>
|
||||
<a name="id1052613"></a><p class="title"><b>Table 1.17. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -54,7 +54,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id957359"></a><p class="title"><b>Table 1.16. Examples</b></p>
|
||||
<a name="id1053095"></a><p class="title"><b>Table 1.18. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -51,7 +51,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id958981"></a><p class="title"><b>Table 1.17. Examples</b></p>
|
||||
<a name="id1053620"></a><p class="title"><b>Table 1.19. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -54,7 +54,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id960078"></a><p class="title"><b>Table 1.18. Examples</b></p>
|
||||
<a name="id1056355"></a><p class="title"><b>Table 1.20. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -53,7 +53,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id960622"></a><p class="title"><b>Table 1.19. Examples</b></p>
|
||||
<a name="id1056899"></a><p class="title"><b>Table 1.21. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -53,7 +53,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id962791"></a><p class="title"><b>Table 1.20. Examples</b></p>
|
||||
<a name="id1057429"></a><p class="title"><b>Table 1.22. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -54,7 +54,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id963320"></a><p class="title"><b>Table 1.21. Examples</b></p>
|
||||
<a name="id1057959"></a><p class="title"><b>Table 1.23. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -55,7 +55,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id963874"></a><p class="title"><b>Table 1.22. Examples</b></p>
|
||||
<a name="id1059606"></a><p class="title"><b>Table 1.24. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -53,7 +53,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id964387"></a><p class="title"><b>Table 1.23. Examples</b></p>
|
||||
<a name="id1060118"></a><p class="title"><b>Table 1.25. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -53,7 +53,7 @@
|
||||
or <code class="computeroutput"> <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">type_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>
|
||||
</p>
|
||||
<div class="table">
|
||||
<a name="id964889"></a><p class="title"><b>Table 1.24. Examples</b></p>
|
||||
<a name="id1060620"></a><p class="title"><b>Table 1.26. Examples</b></p>
|
||||
<div class="table-contents"><table class="table" summary="Examples">
|
||||
<colgroup>
|
||||
<col>
|
||||
|
@@ -30,7 +30,7 @@
|
||||
Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert
|
||||
Ramey and Jeremy Siek</p></div>
|
||||
<div><div class="legalnotice">
|
||||
<a name="id904215"></a><p>
|
||||
<a name="id991047"></a><p>
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
|
||||
</p>
|
||||
@@ -75,16 +75,22 @@
|
||||
of std::iter_swap</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/examples/to_double.html"> Convert Numeric
|
||||
Types and Enums to double</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/examples/improved_min.html"> Improving std::min
|
||||
with common_type</a></span></dt>
|
||||
</dl></dd>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference.html"> Alphabetical Reference</a></span></dt>
|
||||
<dd><dl>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/add_const.html"> add_const</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/add_cv.html"> add_cv</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/add_lvalue_reference.html"> add_lvalue_reference</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/add_pointer.html"> add_pointer</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/add_reference.html"> add_reference</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/add_rvalue_reference.html"> add_rvalue_reference</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/add_volatile.html"> add_volatile</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/aligned_storage.html"> aligned_storage</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/alignment_of.html"> alignment_of</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/conditional.html"> conditional</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/common_type.html"> common_type</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/decay.html"> decay</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/extent.html"> extent</a></span></dt>
|
||||
<dt><span class="section"><a href="boost_typetraits/reference/floating_point_promotion.html">
|
||||
@@ -166,7 +172,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: July 01, 2010 at 17:14:17 +0100</small></p></td>
|
||||
<td align="left"><p><small>Last revised: September 24, 2010 at 18:12:08 +0100</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@@ -19,6 +19,9 @@ result of applying the transformation to the template argument `T`.
|
||||
|
||||
template <class T>
|
||||
struct __add_cv;
|
||||
|
||||
template <class T>
|
||||
struct __add_lvalue_reference;
|
||||
|
||||
template <class T>
|
||||
struct __add_pointer;
|
||||
@@ -26,9 +29,18 @@ result of applying the transformation to the template argument `T`.
|
||||
template <class T>
|
||||
struct __add_reference;
|
||||
|
||||
template <class T>
|
||||
struct __add_rvalue_reference;
|
||||
|
||||
template <class T>
|
||||
struct __add_volatile;
|
||||
|
||||
template <bool B, class T, class U>
|
||||
struct __conditional;
|
||||
|
||||
template <class... T>
|
||||
struct __common_type;
|
||||
|
||||
template <class T>
|
||||
struct __decay;
|
||||
|
||||
|
@@ -101,10 +101,14 @@
|
||||
[def __remove_all_extents [link boost_typetraits.reference.remove_all_extents remove_all_extents]]
|
||||
[def __remove_pointer [link boost_typetraits.reference.remove_pointer remove_pointer]]
|
||||
[def __add_reference [link boost_typetraits.reference.add_reference add_reference]]
|
||||
[def __add_lvalue_reference [link boost_typetraits.reference.add_lvalue_reference add_lvalue_reference]]
|
||||
[def __add_rvalue_reference [link boost_typetraits.reference.add_rvalue_reference add_rvalue_reference]]
|
||||
[def __add_pointer [link boost_typetraits.reference.add_pointer add_pointer]]
|
||||
[def __add_const [link boost_typetraits.reference.add_const add_const]]
|
||||
[def __add_volatile [link boost_typetraits.reference.add_volatile add_volatile]]
|
||||
[def __add_cv [link boost_typetraits.reference.add_cv add_cv]]
|
||||
[def __common_type [link boost_typetraits.reference.common_type common_type]]
|
||||
[def __conditional [link boost_typetraits.reference.conditional conditional]]
|
||||
|
||||
[def __type_with_alignment [link boost_typetraits.reference.type_with_alignment type_with_alignment]]
|
||||
[def __aligned_storage [link boost_typetraits.reference.aligned_storage aligned_storage]]
|
||||
@@ -162,11 +166,15 @@ that is the result of the transformation.
|
||||
|
||||
[include add_const.qbk]
|
||||
[include add_cv.qbk]
|
||||
[include add_lvalue_reference.qbk]
|
||||
[include add_pointer.qbk]
|
||||
[include add_reference.qbk]
|
||||
[include add_rvalue_reference.qbk]
|
||||
[include add_volatile.qbk]
|
||||
[include aligned_storage.qbk]
|
||||
[include alignment_of.qbk]
|
||||
[include conditional.qbk]
|
||||
[include common_type.qbk]
|
||||
[include decay.qbk]
|
||||
[include extent.qbk]
|
||||
[include floating_point_promotion.qbk]
|
||||
|
@@ -12,10 +12,19 @@
|
||||
|
||||
#include "boost/type_traits/add_const.hpp"
|
||||
#include "boost/type_traits/add_cv.hpp"
|
||||
#include "boost/type_traits/add_lvalue_reference.hpp"
|
||||
#include "boost/type_traits/add_pointer.hpp"
|
||||
#include "boost/type_traits/add_reference.hpp"
|
||||
#include "boost/type_traits/add_rvalue_reference.hpp"
|
||||
#include "boost/type_traits/add_volatile.hpp"
|
||||
#include "boost/type_traits/aligned_storage.hpp"
|
||||
#include "boost/type_traits/alignment_of.hpp"
|
||||
#include "boost/type_traits/common_type.hpp"
|
||||
#include "boost/type_traits/conditional.hpp"
|
||||
#include "boost/type_traits/decay.hpp"
|
||||
#include "boost/type_traits/extent.hpp"
|
||||
#include "boost/type_traits/floating_point_promotion.hpp"
|
||||
#include "boost/type_traits/function_traits.hpp"
|
||||
#if !defined(__BORLANDC__) && !defined(__CUDACC__)
|
||||
#include "boost/type_traits/has_new_operator.hpp"
|
||||
#endif
|
||||
@@ -28,14 +37,13 @@
|
||||
#include "boost/type_traits/has_trivial_copy.hpp"
|
||||
#include "boost/type_traits/has_trivial_destructor.hpp"
|
||||
#include "boost/type_traits/has_virtual_destructor.hpp"
|
||||
#include "boost/type_traits/is_signed.hpp"
|
||||
#include "boost/type_traits/is_unsigned.hpp"
|
||||
#include "boost/type_traits/is_abstract.hpp"
|
||||
#include "boost/type_traits/is_arithmetic.hpp"
|
||||
#include "boost/type_traits/is_array.hpp"
|
||||
#include "boost/type_traits/is_base_and_derived.hpp"
|
||||
#include "boost/type_traits/is_base_of.hpp"
|
||||
#include "boost/type_traits/is_class.hpp"
|
||||
#include <boost/type_traits/is_complex.hpp>
|
||||
#include "boost/type_traits/is_compound.hpp"
|
||||
#include "boost/type_traits/is_const.hpp"
|
||||
#include "boost/type_traits/is_convertible.hpp"
|
||||
@@ -46,6 +54,7 @@
|
||||
#include "boost/type_traits/is_function.hpp"
|
||||
#include "boost/type_traits/is_fundamental.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/type_traits/is_lvalue_reference.hpp"
|
||||
#include "boost/type_traits/is_member_function_pointer.hpp"
|
||||
#include "boost/type_traits/is_member_object_pointer.hpp"
|
||||
#include "boost/type_traits/is_member_pointer.hpp"
|
||||
@@ -55,16 +64,18 @@
|
||||
#include "boost/type_traits/is_pointer.hpp"
|
||||
#include "boost/type_traits/is_reference.hpp"
|
||||
#include "boost/type_traits/is_rvalue_reference.hpp"
|
||||
#include "boost/type_traits/is_lvalue_reference.hpp"
|
||||
#include "boost/type_traits/is_signed.hpp"
|
||||
#include "boost/type_traits/is_same.hpp"
|
||||
#include "boost/type_traits/is_scalar.hpp"
|
||||
#include "boost/type_traits/is_stateless.hpp"
|
||||
#include "boost/type_traits/is_union.hpp"
|
||||
#include "boost/type_traits/is_unsigned.hpp"
|
||||
#include "boost/type_traits/is_void.hpp"
|
||||
#include "boost/type_traits/is_virtual_base_of.hpp"
|
||||
#include "boost/type_traits/is_volatile.hpp"
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/make_signed.hpp>
|
||||
#include "boost/type_traits/rank.hpp"
|
||||
#include "boost/type_traits/extent.hpp"
|
||||
#include "boost/type_traits/remove_bounds.hpp"
|
||||
#include "boost/type_traits/remove_extent.hpp"
|
||||
#include "boost/type_traits/remove_all_extents.hpp"
|
||||
@@ -74,17 +85,10 @@
|
||||
#include "boost/type_traits/remove_reference.hpp"
|
||||
#include "boost/type_traits/remove_volatile.hpp"
|
||||
#include "boost/type_traits/type_with_alignment.hpp"
|
||||
#include "boost/type_traits/function_traits.hpp"
|
||||
#include "boost/type_traits/aligned_storage.hpp"
|
||||
#include "boost/type_traits/floating_point_promotion.hpp"
|
||||
#if !(defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238))
|
||||
#include "boost/type_traits/integral_promotion.hpp"
|
||||
#include "boost/type_traits/promote.hpp"
|
||||
#endif
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/make_signed.hpp>
|
||||
#include <boost/type_traits/decay.hpp>
|
||||
#include <boost/type_traits/is_complex.hpp>
|
||||
|
||||
#include "boost/type_traits/ice.hpp"
|
||||
|
||||
|
26
include/boost/type_traits/add_lvalue_reference.hpp
Normal file
26
include/boost/type_traits/add_lvalue_reference.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright 2010 John Maddock
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP
|
||||
#define BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP
|
||||
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
|
||||
// should be the last #include
|
||||
#include <boost/type_traits/detail/type_trait_def.hpp>
|
||||
|
||||
namespace boost{
|
||||
|
||||
BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_lvalue_reference,T,typename boost::add_reference<T>::type)
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(typename T,add_lvalue_reference,T&&,T&)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#include <boost/type_traits/detail/type_trait_undef.hpp>
|
||||
|
||||
#endif // BOOST_TYPE_TRAITS_EXT_ADD_LVALUE_REFERENCE__HPP
|
67
include/boost/type_traits/add_rvalue_reference.hpp
Normal file
67
include/boost/type_traits/add_rvalue_reference.hpp
Normal file
@@ -0,0 +1,67 @@
|
||||
// add_rvalue_reference.hpp ---------------------------------------------------------//
|
||||
|
||||
// Copyright 2010 Vicente J. Botet Escriba
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
|
||||
#define BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
#include <boost/type_traits/is_reference.hpp>
|
||||
|
||||
// should be the last #include
|
||||
#include <boost/type_traits/detail/type_trait_def.hpp>
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// //
|
||||
// C++03 implementation of //
|
||||
// 20.7.6.2 Reference modifications [meta.trans.ref] //
|
||||
// Written by Vicente J. Botet Escriba //
|
||||
// //
|
||||
// If T names an object or function type then the member typedef type
|
||||
// shall name T&&; otherwise, type shall name T. [ Note: This rule reflects
|
||||
// the semantics of reference collapsing. For example, when a type T names
|
||||
// a type T1&, the type add_rvalue_reference<T>::type is not an rvalue
|
||||
// reference. <20>end note ]
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace type_traits_detail {
|
||||
|
||||
template <typename T, bool b>
|
||||
struct add_rvalue_reference_helper
|
||||
{ typedef T type; };
|
||||
|
||||
template <typename T>
|
||||
struct add_rvalue_reference_helper<T, true>
|
||||
{
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
typedef T&& type;
|
||||
#else
|
||||
typedef T type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct add_rvalue_reference_imp
|
||||
{
|
||||
typedef typename boost::type_traits_detail::add_rvalue_reference_helper
|
||||
<T, (!is_void<T>::value && !is_reference<T>::value) >::type type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
BOOST_TT_AUX_TYPE_TRAIT_DEF1(add_rvalue_reference,T,typename boost::type_traits_detail::add_rvalue_reference_imp<T>::type)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/type_traits/detail/type_trait_undef.hpp>
|
||||
|
||||
#endif // BOOST_TYPE_TRAITS_EXT_ADD_RVALUE_REFERENCE__HPP
|
153
include/boost/type_traits/common_type.hpp
Normal file
153
include/boost/type_traits/common_type.hpp
Normal file
@@ -0,0 +1,153 @@
|
||||
// common_type.hpp ---------------------------------------------------------//
|
||||
|
||||
// Copyright 2008 Howard Hinnant
|
||||
// Copyright 2008 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
||||
#define BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef __SUNPRO_CC
|
||||
# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF
|
||||
#endif
|
||||
#ifdef __IBMCPP__
|
||||
# define BOOST_COMMON_TYPE_DONT_USE_TYPEOF
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#define BOOST_COMMON_TYPE_ARITY 3
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#if defined(BOOST_NO_DECLTYPE) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
#define BOOST_TYPEOF_SILENT
|
||||
#include <boost/typeof/typeof.hpp> // boost wonders never cease!
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
#ifndef BOOST_NO_STATIC_ASSERT
|
||||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) static_assert(CND,MSG)
|
||||
#elif defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT)
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) \
|
||||
BOOST_MPL_ASSERT_MSG(boost::mpl::bool_< (CND) >::type::value, MSG, TYPES)
|
||||
#else
|
||||
#include <boost/static_assert.hpp>
|
||||
#define BOOST_COMMON_TYPE_STATIC_ASSERT(CND, MSG, TYPES) BOOST_STATIC_ASSERT(CND)
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_STATIC_ASSERT) || !defined(BOOST_COMMON_TYPE_USES_MPL_ASSERT)
|
||||
#define BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE "must be complete type"
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_DECLTYPE) && defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
#include <boost/type_traits/detail/common_type_imp.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#endif
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
#include <boost/type_traits/add_rvalue_reference.hpp>
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
// //
|
||||
// C++03 implementation of //
|
||||
// 20.6.7 Other transformations [meta.trans.other] //
|
||||
// Written by Howard Hinnant //
|
||||
// Adapted for Boost by Beman Dawes, Vicente Botet and Jeffrey Hellrung //
|
||||
// //
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
namespace boost {
|
||||
|
||||
// prototype
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template<typename... T>
|
||||
struct common_type;
|
||||
#else // or no specialization
|
||||
template <class T, class U = void, class V = void>
|
||||
struct common_type
|
||||
{
|
||||
public:
|
||||
typedef typename common_type<typename common_type<T, U>::type, V>::type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
// 1 arg
|
||||
template<typename T>
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
struct common_type<T>
|
||||
#else
|
||||
struct common_type<T, void, void>
|
||||
|
||||
#endif
|
||||
{
|
||||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T));
|
||||
public:
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
// 2 args
|
||||
namespace type_traits_detail {
|
||||
|
||||
template <class T, class U>
|
||||
struct common_type_2
|
||||
{
|
||||
private:
|
||||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(T) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (T));
|
||||
BOOST_COMMON_TYPE_STATIC_ASSERT(sizeof(U) > 0, BOOST_COMMON_TYPE_MUST_BE_A_COMPLE_TYPE, (U));
|
||||
static bool declval_bool(); // workaround gcc bug; not required by std
|
||||
static typename add_rvalue_reference<T>::type declval_T(); // workaround gcc bug; not required by std
|
||||
static typename add_rvalue_reference<U>::type declval_U(); // workaround gcc bug; not required by std
|
||||
static typename add_rvalue_reference<bool>::type declval_b();
|
||||
|
||||
#if !defined(BOOST_NO_DECLTYPE)
|
||||
public:
|
||||
typedef decltype(declval<bool>() ? declval<T>() : declval<U>()) type;
|
||||
#elif defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
public:
|
||||
typedef typename detail_type_traits_common_type::common_type_impl<
|
||||
typename remove_cv<T>::type,
|
||||
typename remove_cv<U>::type
|
||||
>::type type;
|
||||
#else
|
||||
public:
|
||||
typedef BOOST_TYPEOF_TPL(declval_b() ? declval_T() : declval_U()) type;
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct common_type_2<T, T>
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class T, class U>
|
||||
struct common_type<T, U>
|
||||
#else
|
||||
template <class T, class U>
|
||||
struct common_type<T, U, void>
|
||||
#endif
|
||||
: type_traits_detail::common_type_2<T,U>
|
||||
{ };
|
||||
|
||||
|
||||
// 3 or more args
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template<typename T, typename U, typename... V>
|
||||
struct common_type<T, U, V...> {
|
||||
public:
|
||||
typedef typename common_type<typename common_type<T, U>::type, V...>::type type;
|
||||
};
|
||||
#endif
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TYPE_TRAITS_COMMON_TYPE_HPP
|
25
include/boost/type_traits/conditional.hpp
Normal file
25
include/boost/type_traits/conditional.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
// (C) Copyright John Maddock 2010.
|
||||
// Use, modification and distribution are subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
|
||||
#ifndef BOOST_TT_CONDITIONAL_HPP_INCLUDED
|
||||
#define BOOST_TT_CONDITIONAL_HPP_INCLUDED
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <bool b, class T, class U>
|
||||
struct conditional : public mpl::if_c<b, T, U>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_TT_CONDITIONAL_HPP_INCLUDED
|
302
include/boost/type_traits/detail/common_type_imp.hpp
Normal file
302
include/boost/type_traits/detail/common_type_imp.hpp
Normal file
@@ -0,0 +1,302 @@
|
||||
/*******************************************************************************
|
||||
* boost/type_traits/detail/common_type_imp.hpp
|
||||
*
|
||||
* Copyright 2010, Jeffrey Hellrung.
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* struct boost::common_type<T,U>
|
||||
*
|
||||
* common_type<T,U>::type is the type of the expression
|
||||
* b() ? x() : y()
|
||||
* where b() returns a bool, x() has return type T, and y() has return type U.
|
||||
* See
|
||||
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm#common_type
|
||||
*
|
||||
* Note that this evaluates to void if one or both of T and U is void.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP
|
||||
#define BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/begin_end.hpp>
|
||||
#include <boost/mpl/contains.hpp>
|
||||
#include <boost/mpl/copy.hpp>
|
||||
#include <boost/mpl/deref.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/inserter.hpp>
|
||||
#include <boost/mpl/next.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/mpl/placeholders.hpp>
|
||||
#include <boost/mpl/push_back.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/mpl/vector/vector0.hpp>
|
||||
#include <boost/mpl/vector/vector10.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/make_signed.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <boost/utility/declval.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail_type_traits_common_type
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
* struct propagate_cv< From, To >
|
||||
*
|
||||
* This metafunction propagates cv-qualifiers on type From to type To.
|
||||
******************************************************************************/
|
||||
|
||||
template< class From, class To >
|
||||
struct propagate_cv
|
||||
{ typedef To type; };
|
||||
template< class From, class To >
|
||||
struct propagate_cv< const From, To >
|
||||
{ typedef To const type; };
|
||||
template< class From, class To >
|
||||
struct propagate_cv< volatile From, To >
|
||||
{ typedef To volatile type; };
|
||||
template< class From, class To >
|
||||
struct propagate_cv< const volatile From, To >
|
||||
{ typedef To const volatile type; };
|
||||
|
||||
/*******************************************************************************
|
||||
* struct is_signable_integral<T>
|
||||
*
|
||||
* This metafunction determines if T is an integral type which can be made
|
||||
* signed or unsigned.
|
||||
******************************************************************************/
|
||||
|
||||
template< class T >
|
||||
struct is_signable_integral
|
||||
: mpl::or_< is_integral<T>, is_enum<T> >
|
||||
{ };
|
||||
template<>
|
||||
struct is_signable_integral< bool >
|
||||
: false_type
|
||||
{ };
|
||||
|
||||
/*******************************************************************************
|
||||
* struct sizeof_t<N>
|
||||
* typedef ... yes_type
|
||||
* typedef ... no_type
|
||||
*
|
||||
* These types are integral players in the use of the "sizeof trick", i.e., we
|
||||
* can distinguish overload selection by inspecting the size of the return type
|
||||
* of the overload.
|
||||
******************************************************************************/
|
||||
|
||||
template< std::size_t N > struct sizeof_t { char _dummy[N]; };
|
||||
typedef sizeof_t<1> yes_type;
|
||||
typedef sizeof_t<2> no_type;
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof( yes_type ), ==, 1 );
|
||||
BOOST_MPL_ASSERT_RELATION( sizeof( no_type ), ==, 2 );
|
||||
|
||||
/*******************************************************************************
|
||||
* rvalue_test(T&) -> no_type
|
||||
* rvalue_test(...) -> yes_type
|
||||
*
|
||||
* These overloads are used to determine the rvalue-ness of an expression.
|
||||
******************************************************************************/
|
||||
|
||||
template< class T > no_type rvalue_test(T&);
|
||||
yes_type rvalue_test(...);
|
||||
|
||||
/*******************************************************************************
|
||||
* struct conversion_test_overloads< Sequence >
|
||||
*
|
||||
* This struct has multiple overloads of the static member function apply, each
|
||||
* one taking a single parameter of a type within the Boost.MPL sequence
|
||||
* Sequence. Each such apply overload has a return type with sizeof equal to
|
||||
* one plus the index of the parameter type within Sequence. Thus, we can
|
||||
* deduce the type T of an expression as long as we can generate a finite set of
|
||||
* candidate types containing T via these apply overloads and the "sizeof
|
||||
* trick".
|
||||
******************************************************************************/
|
||||
|
||||
template< class First, class Last, std::size_t Index >
|
||||
struct conversion_test_overloads_iterate
|
||||
: conversion_test_overloads_iterate<
|
||||
typename mpl::next< First >::type, Last, Index + 1
|
||||
>
|
||||
{
|
||||
using conversion_test_overloads_iterate<
|
||||
typename mpl::next< First >::type, Last, Index + 1
|
||||
>::apply;
|
||||
static sizeof_t< Index + 1 >
|
||||
apply(typename mpl::deref< First >::type);
|
||||
};
|
||||
|
||||
template< class Last, std::size_t Index >
|
||||
struct conversion_test_overloads_iterate< Last, Last, Index >
|
||||
{ static sizeof_t< Index + 1 > apply(...); };
|
||||
|
||||
template< class Sequence >
|
||||
struct conversion_test_overloads
|
||||
: conversion_test_overloads_iterate<
|
||||
typename mpl::begin< Sequence >::type,
|
||||
typename mpl::end< Sequence >::type,
|
||||
0
|
||||
>
|
||||
{ };
|
||||
|
||||
/*******************************************************************************
|
||||
* struct select< Sequence, Index >
|
||||
*
|
||||
* select is synonymous with mpl::at_c unless Index equals the size of the
|
||||
* Boost.MPL Sequence, in which case this evaluates to void.
|
||||
******************************************************************************/
|
||||
|
||||
template<
|
||||
class Sequence, int Index,
|
||||
int N = mpl::size< Sequence >::value
|
||||
>
|
||||
struct select
|
||||
: mpl::at_c< Sequence, Index >
|
||||
{ };
|
||||
template< class Sequence, int N >
|
||||
struct select< Sequence, N, N >
|
||||
{ typedef void type; };
|
||||
|
||||
/*******************************************************************************
|
||||
* class deduce_common_type< T, U, NominalCandidates >
|
||||
* struct nominal_candidates<T,U>
|
||||
* struct common_type_dispatch_on_rvalueness<T,U>
|
||||
* struct common_type_impl<T,U>
|
||||
*
|
||||
* These classes and structs implement the logic behind common_type, which goes
|
||||
* roughly as follows. Let C be the type of the conditional expression
|
||||
* declval< bool >() ? declval<T>() : declval<U>()
|
||||
* if C is an rvalue, then:
|
||||
* let T' and U' be T and U stripped of reference- and cv-qualifiers
|
||||
* if T' and U' are pointer types, say, T' = V* and U' = W*, then:
|
||||
* define the set of NominalCandidates to be
|
||||
* { V*, W*, V'*, W'* }
|
||||
* where V' is V with whatever cv-qualifiers are on W, and W' is W
|
||||
* with whatever cv-qualifiers are on V
|
||||
* else T' and U' are both "signable integral types" (integral and enum
|
||||
* types excepting bool), then:
|
||||
* define the set of NominalCandidates to be
|
||||
* { unsigned(T'), unsigned(U'), signed(T'), signed(U') }
|
||||
* where unsigned(X) is make_unsigned<X>::type and signed(X) is
|
||||
* make_signed<X>::type
|
||||
* else
|
||||
* define the set of NominalCandidates to be
|
||||
* { T', U' }
|
||||
* else
|
||||
* let V and W be T and U stripped of reference-qualifiers
|
||||
* define the set of NominalCandidates to be
|
||||
* { V&, W&, V'&, W'& }
|
||||
* where V' is V with whatever cv-qualifiers are on W, and W' is W with
|
||||
* whatever cv-qualifiers are on V
|
||||
* define the set of Candidates to be equal to the set of NominalCandidates with
|
||||
* duplicates removed, and use this set of Candidates to determine C using the
|
||||
* conversion_test_overloads struct
|
||||
******************************************************************************/
|
||||
|
||||
template< class T, class U, class NominalCandidates >
|
||||
class deduce_common_type
|
||||
{
|
||||
typedef typename mpl::copy<
|
||||
NominalCandidates,
|
||||
mpl::inserter<
|
||||
mpl::vector0<>,
|
||||
mpl::if_<
|
||||
mpl::contains< mpl::_1, mpl::_2 >,
|
||||
mpl::_1,
|
||||
mpl::push_back< mpl::_1, mpl::_2 >
|
||||
>
|
||||
>
|
||||
>::type candidate_types;
|
||||
static const int best_candidate_index =
|
||||
sizeof( conversion_test_overloads< candidate_types >::apply(
|
||||
declval< bool >() ? declval<T>() : declval<U>()
|
||||
) ) - 1;
|
||||
public:
|
||||
typedef typename select< candidate_types, best_candidate_index >::type type;
|
||||
};
|
||||
|
||||
template<
|
||||
class T, class U,
|
||||
class V = typename remove_cv< typename remove_reference<T>::type >::type,
|
||||
class W = typename remove_cv< typename remove_reference<U>::type >::type,
|
||||
bool = is_signable_integral<V>::value && is_signable_integral<W>::value
|
||||
>
|
||||
struct nominal_candidates;
|
||||
|
||||
template< class T, class U, class V, class W >
|
||||
struct nominal_candidates< T, U, V, W, false >
|
||||
{ typedef mpl::vector2<V,W> type; };
|
||||
|
||||
template< class T, class U, class V, class W >
|
||||
struct nominal_candidates< T, U, V, W, true >
|
||||
{
|
||||
typedef mpl::vector4<
|
||||
typename make_unsigned<V>::type,
|
||||
typename make_unsigned<W>::type,
|
||||
typename make_signed<V>::type,
|
||||
typename make_signed<W>::type
|
||||
> type;
|
||||
};
|
||||
|
||||
template< class T, class U, class V, class W >
|
||||
struct nominal_candidates< T, U, V*, W*, false >
|
||||
{
|
||||
typedef mpl::vector4<
|
||||
V*, W*,
|
||||
typename propagate_cv<W,V>::type *,
|
||||
typename propagate_cv<V,W>::type *
|
||||
> type;
|
||||
};
|
||||
|
||||
template<class T, class U, bool b>
|
||||
struct common_type_dispatch_on_rvalueness
|
||||
: deduce_common_type< T, U, typename nominal_candidates<T,U>::type >
|
||||
{ };
|
||||
|
||||
template< class T, class U >
|
||||
struct common_type_dispatch_on_rvalueness< T, U, false >
|
||||
{
|
||||
private:
|
||||
typedef typename remove_reference<T>::type unrefed_T_type;
|
||||
typedef typename remove_reference<U>::type unrefed_U_type;
|
||||
public:
|
||||
typedef typename deduce_common_type<
|
||||
T, U,
|
||||
mpl::vector4<
|
||||
unrefed_T_type &,
|
||||
unrefed_U_type &,
|
||||
typename propagate_cv< unrefed_U_type, unrefed_T_type >::type &,
|
||||
typename propagate_cv< unrefed_T_type, unrefed_U_type >::type &
|
||||
>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct common_type_impl
|
||||
: common_type_dispatch_on_rvalueness<T,U, sizeof( ::boost::detail_type_traits_common_type::rvalue_test(
|
||||
declval< bool >() ? declval<T>() : declval<U>() ) ) == sizeof( yes_type ) >
|
||||
{ };
|
||||
|
||||
template< class T > struct common_type_impl< T, void > { typedef void type; };
|
||||
template< class T > struct common_type_impl< void, T > { typedef void type; };
|
||||
template<> struct common_type_impl< void, void > { typedef void type; };
|
||||
|
||||
} // namespace detail_type_traits_common_type
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_HPP
|
||||
|
@@ -24,14 +24,19 @@ namespace boost {
|
||||
|
||||
namespace detail{
|
||||
|
||||
#if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238)
|
||||
#if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) && !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
|
||||
|
||||
template <class T>
|
||||
struct is_signed_values
|
||||
{
|
||||
//
|
||||
// Note that we cannot use BOOST_STATIC_CONSTANT here, using enum's
|
||||
// rather than "real" static constants simply doesn't work or give
|
||||
// the correct answer.
|
||||
//
|
||||
typedef typename remove_cv<T>::type no_cv_t;
|
||||
BOOST_STATIC_CONSTANT(no_cv_t, minus_one = (static_cast<no_cv_t>(-1)));
|
||||
BOOST_STATIC_CONSTANT(no_cv_t, zero = (static_cast<no_cv_t>(0)));
|
||||
static const no_cv_t minus_one = (static_cast<no_cv_t>(-1));
|
||||
static const no_cv_t zero = (static_cast<no_cv_t>(0));
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
@@ -24,14 +24,19 @@ namespace boost {
|
||||
|
||||
namespace detail{
|
||||
|
||||
#if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238)
|
||||
#if !(defined(__EDG_VERSION__) && __EDG_VERSION__ <= 238) && !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
|
||||
|
||||
template <class T>
|
||||
struct is_unsigned_values
|
||||
{
|
||||
//
|
||||
// Note that we cannot use BOOST_STATIC_CONSTANT here, using enum's
|
||||
// rather than "real" static constants simply doesn't work or give
|
||||
// the correct answer.
|
||||
//
|
||||
typedef typename remove_cv<T>::type no_cv_t;
|
||||
BOOST_STATIC_CONSTANT(no_cv_t, minus_one = (static_cast<no_cv_t>(-1)));
|
||||
BOOST_STATIC_CONSTANT(no_cv_t, zero = (static_cast<no_cv_t>(0)));
|
||||
static const no_cv_t minus_one = (static_cast<no_cv_t>(-1));
|
||||
static const no_cv_t zero = (static_cast<no_cv_t>(0));
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
@@ -37,37 +37,37 @@ template<typename Base, typename Derived>
|
||||
struct is_virtual_base_of_impl<Base, Derived, mpl::true_>
|
||||
{
|
||||
#ifdef __BORLANDC__
|
||||
struct X : public virtual Derived, public virtual Base
|
||||
struct boost_type_traits_internal_struct_X : public virtual Derived, public virtual Base
|
||||
{
|
||||
X();
|
||||
X(const X&);
|
||||
X& operator=(const X&);
|
||||
~X()throw();
|
||||
boost_type_traits_internal_struct_X();
|
||||
boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
|
||||
boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
|
||||
~boost_type_traits_internal_struct_X()throw();
|
||||
};
|
||||
struct Y : public virtual Derived
|
||||
struct boost_type_traits_internal_struct_Y : public virtual Derived
|
||||
{
|
||||
Y();
|
||||
Y(const Y&);
|
||||
Y& operator=(const Y&);
|
||||
~Y()throw();
|
||||
boost_type_traits_internal_struct_Y();
|
||||
boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
|
||||
boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
|
||||
~boost_type_traits_internal_struct_Y()throw();
|
||||
};
|
||||
#else
|
||||
struct X : Derived, virtual Base
|
||||
struct boost_type_traits_internal_struct_X : Derived, virtual Base
|
||||
{
|
||||
X();
|
||||
X(const X&);
|
||||
X& operator=(const X&);
|
||||
~X()throw();
|
||||
boost_type_traits_internal_struct_X();
|
||||
boost_type_traits_internal_struct_X(const boost_type_traits_internal_struct_X&);
|
||||
boost_type_traits_internal_struct_X& operator=(const boost_type_traits_internal_struct_X&);
|
||||
~boost_type_traits_internal_struct_X()throw();
|
||||
};
|
||||
struct Y : Derived
|
||||
struct boost_type_traits_internal_struct_Y : Derived
|
||||
{
|
||||
Y();
|
||||
Y(const Y&);
|
||||
Y& operator=(const Y&);
|
||||
~Y()throw();
|
||||
boost_type_traits_internal_struct_Y();
|
||||
boost_type_traits_internal_struct_Y(const boost_type_traits_internal_struct_Y&);
|
||||
boost_type_traits_internal_struct_Y& operator=(const boost_type_traits_internal_struct_Y&);
|
||||
~boost_type_traits_internal_struct_Y()throw();
|
||||
};
|
||||
#endif
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(X)==sizeof(Y)));
|
||||
BOOST_STATIC_CONSTANT(bool, value = (sizeof(boost_type_traits_internal_struct_X)==sizeof(boost_type_traits_internal_struct_Y)));
|
||||
};
|
||||
|
||||
template<typename Base, typename Derived>
|
||||
|
@@ -8,7 +8,18 @@ import testing ;
|
||||
|
||||
# type_traits in V1 seem to have two modes: standalone, triggered
|
||||
# by a command line option, and a regular. For now, just imitate
|
||||
# regular
|
||||
# regular
|
||||
|
||||
project : requirements
|
||||
# default to all warnings on:
|
||||
<warnings>all
|
||||
# set warnings as errors for those compilers we know we get warning free:
|
||||
<toolset>gcc:<cxxflags>-Wextra
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>intel:<warnings-as-errors>on
|
||||
<toolset>sun:<warnings-as-errors>on
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
;
|
||||
|
||||
rule all-tests {
|
||||
local result ;
|
||||
@@ -21,5 +32,7 @@ rule all-tests {
|
||||
|
||||
test-suite type_traits : [ all-tests ] ;
|
||||
|
||||
compile-fail common_type_fail.cpp ;
|
||||
|
||||
|
||||
|
||||
|
63
test/add_lvalue_reference_test.cpp
Normal file
63
test/add_lvalue_reference_test.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
|
||||
// (C) Copyright John Maddock 2000.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_type.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/add_lvalue_reference.hpp>
|
||||
#endif
|
||||
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_1, ::tt::add_lvalue_reference, const, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_2, ::tt::add_lvalue_reference, volatile, volatile&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_3, ::tt::add_lvalue_reference, *, *&)
|
||||
BOOST_DECL_TRANSFORM_TEST2(add_lvalue_reference_test_4, ::tt::add_lvalue_reference, &)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_5, ::tt::add_lvalue_reference, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_6, ::tt::add_lvalue_reference, &, &)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_7, ::tt::add_lvalue_reference, *volatile, *volatile&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_8, ::tt::add_lvalue_reference, const [2], const (&)[2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_9, ::tt::add_lvalue_reference, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_10, ::tt::add_lvalue_reference, const*, const*&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_11, ::tt::add_lvalue_reference, volatile*, volatile*&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_12, ::tt::add_lvalue_reference, const[2][3], const (&)[2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_13, ::tt::add_lvalue_reference, (&)[2], (&)[2])
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_5a, ::tt::add_lvalue_reference, const &&, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_6a, ::tt::add_lvalue_reference, &&, &)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_lvalue_reference_test_13a, ::tt::add_lvalue_reference, (&&)[2], (&)[2])
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(add_lvalue_reference)
|
||||
|
||||
add_lvalue_reference_test_1();
|
||||
add_lvalue_reference_test_2();
|
||||
add_lvalue_reference_test_3();
|
||||
add_lvalue_reference_test_4();
|
||||
add_lvalue_reference_test_5();
|
||||
add_lvalue_reference_test_6();
|
||||
add_lvalue_reference_test_7();
|
||||
add_lvalue_reference_test_8();
|
||||
add_lvalue_reference_test_9();
|
||||
add_lvalue_reference_test_10();
|
||||
add_lvalue_reference_test_11();
|
||||
add_lvalue_reference_test_12();
|
||||
add_lvalue_reference_test_13();
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
add_lvalue_reference_test_5a();
|
||||
add_lvalue_reference_test_6a();
|
||||
add_lvalue_reference_test_13a();
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
80
test/add_rvalue_reference_test.cpp
Normal file
80
test/add_rvalue_reference_test.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
// Copyright 2010 Vicente J. Botet Escriba
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "../../type_traits/test/test.hpp"
|
||||
#include "../../type_traits/test/check_type.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/add_rvalue_reference.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_1, ::tt::add_rvalue_reference, const, const)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_2, ::tt::add_rvalue_reference, volatile, volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_3, ::tt::add_rvalue_reference, *, *)
|
||||
BOOST_DECL_TRANSFORM_TEST0(add_rvalue_reference_test_4, ::tt::add_rvalue_reference)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_5, ::tt::add_rvalue_reference, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_6, ::tt::add_rvalue_reference, &, &)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_7, ::tt::add_rvalue_reference, *volatile, *volatile)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_8, ::tt::add_rvalue_reference, const [2], const [2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_9, ::tt::add_rvalue_reference, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_10, ::tt::add_rvalue_reference, const*, const*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_11, ::tt::add_rvalue_reference, volatile*, volatile*)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_12, ::tt::add_rvalue_reference, const[2][3], const [2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_13, ::tt::add_rvalue_reference, (&)[2], (&)[2])
|
||||
#else
|
||||
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_1, ::tt::add_rvalue_reference, const, const&&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_2, ::tt::add_rvalue_reference, volatile, volatile&&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_3, ::tt::add_rvalue_reference, *, *&&)
|
||||
BOOST_DECL_TRANSFORM_TEST2(add_rvalue_reference_test_4, ::tt::add_rvalue_reference, &&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_5, ::tt::add_rvalue_reference, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_6, ::tt::add_rvalue_reference, &, &)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_7, ::tt::add_rvalue_reference, *volatile, *volatile&&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_8, ::tt::add_rvalue_reference, const [2], const (&&) [2])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_9, ::tt::add_rvalue_reference, const &, const&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_10, ::tt::add_rvalue_reference, const*, const*&&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_11, ::tt::add_rvalue_reference, volatile*, volatile*&&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_12, ::tt::add_rvalue_reference, const[2][3], const (&&) [2][3])
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_13, ::tt::add_rvalue_reference, (&)[2], (&)[2])
|
||||
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_5a, ::tt::add_rvalue_reference, const &&, const&&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_6a, ::tt::add_rvalue_reference, &&, &&)
|
||||
BOOST_DECL_TRANSFORM_TEST(add_rvalue_reference_test_13a, ::tt::add_rvalue_reference, (&&)[2], (&&)[2])
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(add_rvalue_reference)
|
||||
|
||||
add_rvalue_reference_test_1();
|
||||
add_rvalue_reference_test_2();
|
||||
add_rvalue_reference_test_3();
|
||||
add_rvalue_reference_test_4();
|
||||
add_rvalue_reference_test_5();
|
||||
add_rvalue_reference_test_6();
|
||||
add_rvalue_reference_test_7();
|
||||
add_rvalue_reference_test_8();
|
||||
add_rvalue_reference_test_9();
|
||||
add_rvalue_reference_test_10();
|
||||
add_rvalue_reference_test_11();
|
||||
add_rvalue_reference_test_12();
|
||||
add_rvalue_reference_test_13();
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
add_rvalue_reference_test_5a();
|
||||
add_rvalue_reference_test_6a();
|
||||
add_rvalue_reference_test_13a();
|
||||
#endif
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ do_check<long double>();
|
||||
do_check<__int64>();
|
||||
#endif
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
do_check<long long>();
|
||||
do_check<boost::long_long_type>();
|
||||
#endif
|
||||
|
||||
do_check<int(*)(int)>();
|
||||
|
@@ -27,6 +27,10 @@ inline void no_unused_warning(const volatile T&)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(BOOST_INTEL)
|
||||
#pragma GCC diagnostic ignored "-Wmissing-braces"
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
void do_check(const T&)
|
||||
{
|
||||
@@ -55,7 +59,7 @@ void do_check(const T&)
|
||||
|
||||
#ifndef TEST_STD
|
||||
// Non-Tr1 behaviour:
|
||||
typedef typename tt::aligned_storage<T::value,-1L>::type t3;
|
||||
typedef typename tt::aligned_storage<T::value, ~static_cast<std::size_t>(0UL)>::type t3;
|
||||
t3 as3 = { 0, };
|
||||
must_be_pod<t3> pod3;
|
||||
no_unused_warning(as3);
|
||||
|
@@ -16,10 +16,23 @@
|
||||
# include <boost/type_traits/alignment_of.hpp>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Need to defined some member functions for empty_UDT,
|
||||
// we don't want to put these in the test.hpp as that
|
||||
// causes overly-clever compilers to figure out that they can't throw
|
||||
// which in turn breaks other tests.
|
||||
//
|
||||
empty_UDT::empty_UDT(){}
|
||||
empty_UDT::~empty_UDT(){}
|
||||
empty_UDT::empty_UDT(const empty_UDT&){}
|
||||
empty_UDT& empty_UDT::operator=(const empty_UDT&){ return *this; }
|
||||
bool empty_UDT::operator==(const empty_UDT&)const{ return true; }
|
||||
|
||||
|
||||
//
|
||||
// VC++ emits an awful lot of warnings unless we define these:
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable:4244)
|
||||
# pragma warning(disable:4244 4121)
|
||||
//
|
||||
// What follows here is the test case for issue 1946.
|
||||
//
|
@@ -12,6 +12,18 @@
|
||||
# include <boost/type_traits/alignment_of.hpp>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Need to defined some member function for empty_UDT,
|
||||
// we don't want to put these in the test.hpp as that
|
||||
// causes overly-clever compilers to figure out that they can't throw
|
||||
// which in turn breaks other tests.
|
||||
//
|
||||
empty_UDT::empty_UDT(){}
|
||||
empty_UDT::~empty_UDT(){}
|
||||
empty_UDT::empty_UDT(const empty_UDT&){}
|
||||
empty_UDT& empty_UDT::operator=(const empty_UDT&){ return *this; }
|
||||
bool empty_UDT::operator==(const empty_UDT&)const{ return true; }
|
||||
|
||||
//
|
||||
// VC++ emits an awful lot of warnings unless we define these:
|
||||
#ifdef BOOST_MSVC
|
||||
|
28
test/common_type_fail.cpp
Normal file
28
test/common_type_fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// common_type_test.cpp ----------------------------------------------------//
|
||||
|
||||
// Copyright 2010 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS // disable VC++ foolishness
|
||||
|
||||
#include "test.hpp"
|
||||
#ifndef TEST_STD
|
||||
#include <boost/type_traits/common_type.hpp>
|
||||
#else
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
struct C1 {
|
||||
//~ private:
|
||||
//~ C1();
|
||||
};
|
||||
|
||||
struct C2 {};
|
||||
|
||||
|
||||
|
||||
typedef tt::common_type<C1, C2>::type AC;
|
||||
|
||||
|
107
test/common_type_test.cpp
Normal file
107
test/common_type_test.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
// common_type_test.cpp ----------------------------------------------------//
|
||||
|
||||
// Copyright 2010 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_type.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/common_type.hpp>
|
||||
#endif
|
||||
#include <iostream>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
#pragma warning(disable: 304 383)
|
||||
#endif
|
||||
|
||||
struct C1 {};
|
||||
|
||||
struct C2 {};
|
||||
|
||||
|
||||
struct C3 : C2 {};
|
||||
struct C1C2 {
|
||||
C1C2() {}
|
||||
C1C2(C1 const&) {}
|
||||
C1C2(C2 const&) {}
|
||||
C1C2& operator=(C1C2 const&) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename C, typename A>
|
||||
void proc2(typename boost::common_type<A, C>::type const& ) {}
|
||||
|
||||
template <typename C, typename A, typename B>
|
||||
void proc3(typename boost::common_type<C, A, B>::type const& ) {}
|
||||
|
||||
template <typename C, typename A>
|
||||
void assignation_2() {
|
||||
typedef typename boost::common_type<A, C>::type AC;
|
||||
A a;
|
||||
C c;
|
||||
AC ac;
|
||||
ac=a;
|
||||
ac=c;
|
||||
|
||||
proc2<C, A>(a);
|
||||
proc2<C, A>(c);
|
||||
|
||||
}
|
||||
|
||||
template <typename C, typename A, typename B>
|
||||
void assignation_3() {
|
||||
typedef typename boost::common_type<C, A, B>::type ABC;
|
||||
A a;
|
||||
B b;
|
||||
C c;
|
||||
ABC abc;
|
||||
|
||||
abc=a;
|
||||
abc=b;
|
||||
abc=c;
|
||||
|
||||
proc3<C, A, B>(a);
|
||||
proc3<C, A, B>(b);
|
||||
proc3<C, A, B>(c);
|
||||
}
|
||||
|
||||
C1C2 c1c2;
|
||||
C1 c1;
|
||||
|
||||
int f(C1C2 ) { return 1;}
|
||||
int f(C1 ) { return 2;}
|
||||
template <typename OSTREAM>
|
||||
OSTREAM& operator<<(OSTREAM& os, C1 const&) {return os;}
|
||||
|
||||
C1C2& declval_C1C2() {return c1c2;}
|
||||
C1& declval_C1(){return c1;}
|
||||
bool declval_bool(){return true;}
|
||||
|
||||
|
||||
TT_TEST_BEGIN(common_type)
|
||||
{
|
||||
assignation_2<C1C2, C1>();
|
||||
typedef tt::common_type<C1C2&, C1&>::type T1;
|
||||
typedef tt::common_type<C3*, C2*>::type T2;
|
||||
typedef tt::common_type<int*, int const*>::type T3;
|
||||
#if defined(BOOST_NO_DECLTYPE) && !defined(BOOST_COMMON_TYPE_DONT_USE_TYPEOF)
|
||||
// fails if BOOST_COMMON_TYPE_DONT_USE_TYPEOF:
|
||||
typedef tt::common_type<int volatile*, int const*>::type T4;
|
||||
#endif
|
||||
typedef tt::common_type<int*, int volatile*>::type T5;
|
||||
|
||||
assignation_2<C1, C1C2>();
|
||||
assignation_2<C1C2, C2>();
|
||||
assignation_2<C2, C1C2>();
|
||||
assignation_3<C1, C1C2, C2>();
|
||||
assignation_3<C1C2, C1, C2>();
|
||||
assignation_3<C2, C1C2, C1>();
|
||||
assignation_3<C1C2, C2, C1>();
|
||||
//assignation_3<C1, C2, C1C2>(); // fails because the common type is the third
|
||||
}
|
||||
TT_TEST_END
|
31
test/conditional_test.cpp
Normal file
31
test/conditional_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
// (C) Copyright John Maddock 2010.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "test.hpp"
|
||||
#include "check_integral_constant.hpp"
|
||||
#ifdef TEST_STD
|
||||
# include <type_traits>
|
||||
#else
|
||||
# include <boost/type_traits/conditional.hpp>
|
||||
#endif
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
TT_TEST_BEGIN(conditional)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional<true, int, long>::type, int>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional<false, int, long>::type, long>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional<true, int, long>::type, long>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional<false, int, long>::type, int>::value), false);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -16,6 +16,13 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
// remark #383: value copied to temporary, reference to temporary used
|
||||
// std::pair<std::string, int> p2 = boost::make_pair( "foo", 1 );
|
||||
// ^
|
||||
#pragma warning(disable:383)
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
|
@@ -7,6 +7,13 @@
|
||||
#include "check_integral_constant.hpp"
|
||||
#include <boost/type_traits/has_new_operator.hpp>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
// remark #1720: function "class_with_new_op::operator new" has no corresponding member operator delete (to be called if an exception is thrown during initialization of an allocated object)
|
||||
// void * operator new(std::size_t);
|
||||
// ^
|
||||
#pragma warning(disable:1720)
|
||||
#endif
|
||||
|
||||
struct class_with_new_op {
|
||||
void * operator new(std::size_t);
|
||||
};
|
||||
|
@@ -21,71 +21,71 @@
|
||||
struct TestA {};
|
||||
struct TestB { virtual void foo(void) = 0; };
|
||||
struct TestC { private: virtual void foo(void) = 0; };
|
||||
struct TestD : TestA {};
|
||||
struct TestE : TestB {};
|
||||
struct TestF : TestC {};
|
||||
struct TestG : TestB { virtual void foo(void) {} };
|
||||
struct TestH : TestC { private: virtual void foo(void) {} };
|
||||
struct TestI : TestB, TestC {};
|
||||
struct TestJ : TestI { virtual void foo(void) {} };
|
||||
struct TestK : TestB { virtual void foo(void); virtual void foo2(void) = 0; };
|
||||
struct TestL : TestK { virtual void foo2(void) {} };
|
||||
struct TestM : virtual TestB {};
|
||||
struct TestN : virtual TestC {};
|
||||
struct TestO : TestM, TestN {};
|
||||
struct TestP : TestO { virtual void foo(void) {} };
|
||||
struct TestQ : TestB { virtual void foo(void) = 0; };
|
||||
struct TestR : TestC { private: virtual void foo(void) = 0; };
|
||||
struct TestD : public TestA {};
|
||||
struct TestE : public TestB {};
|
||||
struct TestF : public TestC {};
|
||||
struct TestG : public TestB { virtual void foo(void) {} };
|
||||
struct TestH : public TestC { private: virtual void foo(void) {} };
|
||||
struct TestI : public TestB, public TestC {};
|
||||
struct TestJ : public TestI { virtual void foo(void) {} };
|
||||
struct TestK : public TestB { virtual void foo(void); virtual void foo2(void) = 0; };
|
||||
struct TestL : public TestK { virtual void foo2(void) {} };
|
||||
struct TestM : public virtual TestB {};
|
||||
struct TestN : public virtual TestC {};
|
||||
struct TestO : public TestM, public TestN {};
|
||||
struct TestP : public TestO { virtual void foo(void) {} };
|
||||
struct TestQ : public TestB { virtual void foo(void) = 0; };
|
||||
struct TestR : public TestC { private: virtual void foo(void) = 0; };
|
||||
struct TestS { virtual void foo(void) {} };
|
||||
struct TestT { virtual ~TestT(void) {} virtual void foo(void) {} };
|
||||
struct TestU : TestT { virtual void foo(void) = 0; };
|
||||
struct TestV : TestT { virtual void foo(void) {} };
|
||||
struct TestU : public TestT { virtual void foo(void) = 0; };
|
||||
struct TestV : public TestT { virtual void foo(void) {} };
|
||||
struct TestW { virtual void foo1(void) = 0; virtual void foo2(void) = 0; };
|
||||
struct TestX : TestW { virtual void foo1(void) {} virtual void foo2(void) {} };
|
||||
struct TestX : public TestW { virtual void foo1(void) {} virtual void foo2(void) {} };
|
||||
struct TestY { virtual ~TestY(void) = 0; };
|
||||
struct TestZ { virtual ~TestZ(void) = 0; }; TestZ::~TestZ(void) {}
|
||||
struct TestAA : TestZ { virtual ~TestAA(void) = 0; }; TestAA::~TestAA(void) {}
|
||||
struct TestAB : TestAA { virtual ~TestAB(void) {} };
|
||||
struct TestAA : public TestZ { virtual ~TestAA(void) = 0; }; TestAA::~TestAA(void) {}
|
||||
struct TestAB : public TestAA { virtual ~TestAB(void) {} };
|
||||
struct TestAC { virtual void foo(void) = 0; }; void TestAC::foo(void) {}
|
||||
struct TestAD : TestAC {};
|
||||
struct TestAE : TestAD { virtual void foo() {} };
|
||||
struct TestAF : TestAD { virtual void foo(); }; void TestAF::foo(void) {}
|
||||
struct TestAG : virtual TestA {};
|
||||
struct TestAD : public TestAC {};
|
||||
struct TestAE : public TestAD { virtual void foo() {} };
|
||||
struct TestAF : public TestAD { virtual void foo(); }; void TestAF::foo(void) {}
|
||||
struct TestAG : public virtual TestA {};
|
||||
|
||||
// template test types:
|
||||
template <class T> struct TTestA {};
|
||||
template <class T> struct TTestB { virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestC { private: virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestD : TTestA<T> {};
|
||||
template <class T> struct TTestE : TTestB<T> {};
|
||||
template <class T> struct TTestF : TTestC<T> {};
|
||||
template <class T> struct TTestG : TTestB<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestH : TTestC<T> { private: virtual void foo(void) {} };
|
||||
template <class T> struct TTestI : TTestB<T>, TTestC<T> {};
|
||||
template <class T> struct TTestJ : TTestI<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestK : TTestB<T> { virtual void foo(void); virtual void foo2(void) = 0; };
|
||||
template <class T> struct TTestL : TTestK<T> { virtual void foo2(void) {} };
|
||||
template <class T> struct TTestM : virtual TTestB<T> {};
|
||||
template <class T> struct TTestN : virtual TTestC<T> {};
|
||||
template <class T> struct TTestO : TTestM<T>, TTestN<T> {};
|
||||
template <class T> struct TTestP : TTestO<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestQ : TTestB<T> { virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestR : TTestC<T> { private: virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestD : public TTestA<T> {};
|
||||
template <class T> struct TTestE : public TTestB<T> {};
|
||||
template <class T> struct TTestF : public TTestC<T> {};
|
||||
template <class T> struct TTestG : public TTestB<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestH : public TTestC<T> { private: virtual void foo(void) {} };
|
||||
template <class T> struct TTestI : public TTestB<T>, public TTestC<T> {};
|
||||
template <class T> struct TTestJ : public TTestI<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestK : public TTestB<T> { virtual void foo(void); virtual void foo2(void) = 0; };
|
||||
template <class T> struct TTestL : public TTestK<T> { virtual void foo2(void) {} };
|
||||
template <class T> struct TTestM : public virtual TTestB<T> {};
|
||||
template <class T> struct TTestN : public virtual TTestC<T> {};
|
||||
template <class T> struct TTestO : public TTestM<T>, public TTestN<T> {};
|
||||
template <class T> struct TTestP : public TTestO<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestQ : public TTestB<T> { virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestR : public TTestC<T> { private: virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestS { virtual void foo(void) {} };
|
||||
template <class T> struct TTestT { virtual ~TTestT(void) {} virtual void foo(void) {} };
|
||||
template <class T> struct TTestU : TTestT<T> { virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestV : TTestT<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestU : public TTestT<T> { virtual void foo(void) = 0; };
|
||||
template <class T> struct TTestV : public TTestT<T> { virtual void foo(void) {} };
|
||||
template <class T> struct TTestW { virtual void foo1(void) = 0; virtual void foo2(void) = 0; };
|
||||
template <class T> struct TTestX : TTestW<T> { virtual void foo1(void) {} virtual void foo2(void) {} };
|
||||
template <class T> struct TTestX : public TTestW<T> { virtual void foo1(void) {} virtual void foo2(void) {} };
|
||||
template <class T> struct TTestY { virtual ~TTestY(void) = 0; };
|
||||
template <class T> struct TTestZ { virtual ~TTestZ(void) = 0; }; template <class T> TTestZ<T>::~TTestZ(void) {}
|
||||
template <class T> struct TTestAA : TTestZ<T> { virtual ~TTestAA(void) = 0; }; template <class T> TTestAA<T>::~TTestAA(void) {}
|
||||
template <class T> struct TTestAB : TTestAA<T> { virtual ~TTestAB(void) {} };
|
||||
template <class T> struct TTestAA : public TTestZ<T> { virtual ~TTestAA(void) = 0; }; template <class T> TTestAA<T>::~TTestAA(void) {}
|
||||
template <class T> struct TTestAB : public TTestAA<T> { virtual ~TTestAB(void) {} };
|
||||
template <class T> struct TTestAC { virtual void foo(void) = 0; }; template <class T> void TTestAC<T>::foo(void) {}
|
||||
template <class T> struct TTestAD : TTestAC<T> {};
|
||||
template <class T> struct TTestAE : TTestAD<T> { virtual void foo() {} };
|
||||
template <class T> struct TTestAF : TTestAD<T> { virtual void foo(); }; template <class T> void TTestAF<T>::foo(void) {}
|
||||
template <class T> struct TTestAG : virtual TTestA<T> {};
|
||||
template <class T> struct TTestAD : public TTestAC<T> {};
|
||||
template <class T> struct TTestAE : public TTestAD<T> { virtual void foo() {} };
|
||||
template <class T> struct TTestAF : public TTestAD<T> { virtual void foo(); }; template <class T> void TTestAF<T>::foo(void) {}
|
||||
template <class T> struct TTestAG : public virtual TTestA<T> {};
|
||||
|
||||
|
||||
TT_TEST_BEGIN(is_abstract)
|
||||
|
@@ -19,8 +19,8 @@ struct convertible_from
|
||||
};
|
||||
|
||||
struct base2 { };
|
||||
struct middle2 : virtual base2 { };
|
||||
struct derived2 : middle2 { };
|
||||
struct middle2 : public virtual base2 { };
|
||||
struct derived2 : public middle2 { };
|
||||
|
||||
|
||||
TT_TEST_BEGIN(is_convertible)
|
||||
@@ -104,8 +104,11 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<float
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<float const&> >::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<float&> >::value), true);
|
||||
|
||||
#if !(defined(__GNUC__) && (__GNUC__ < 4))
|
||||
// GCC 3.x emits warnings here, which causes the tests to fail when we compile with warnings-as-errors:
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<char> >::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<char const&> >::value), true);
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<float,convertible_from<char&> >::value), false);
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<char,convertible_from<char> >::value), true);
|
||||
|
@@ -30,7 +30,10 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<foo0_t>::value, f
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<int&>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const int&>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const int[2] >::value, false);
|
||||
#ifndef __IBMCPP__
|
||||
// this test may not be strictly legal:
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<const int[] >::value, false);
|
||||
#endif
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_member_function_pointer<void>::value, false);
|
||||
|
||||
#ifdef BOOST_TT_TEST_MS_FUNC_SIGS
|
||||
|
@@ -24,6 +24,20 @@ public:
|
||||
virtual ~D()throw();
|
||||
};
|
||||
|
||||
// for bug report 4453: https://svn.boost.org/trac/boost/ticket/4453
|
||||
class non_virtual_base
|
||||
{
|
||||
public:
|
||||
non_virtual_base();
|
||||
};
|
||||
class non_virtual_derived : public non_virtual_base
|
||||
{
|
||||
public:
|
||||
non_virtual_derived();
|
||||
virtual int Y();
|
||||
virtual int X();
|
||||
};
|
||||
|
||||
TT_TEST_BEGIN(is_virtual_base_of)
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_virtual_base_of<Derived,Base>::value), false);
|
||||
@@ -60,6 +74,7 @@ BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_virtual_base_of<virtual_inherit5,int_con
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_virtual_base_of<Base,virtual_inherit6>::value), true);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_virtual_base_of<virtual_inherit6,Base>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_virtual_base_of<B,D>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_virtual_base_of<non_virtual_base,non_virtual_derived>::value), false);
|
||||
|
||||
TT_TEST_END
|
||||
|
||||
|
@@ -17,6 +17,11 @@
|
||||
|
||||
#include "promote_util.hpp"
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
// remark #1418: external function definition with no prior declaration
|
||||
#pragma warning(disable:1418)
|
||||
#endif
|
||||
|
||||
|
||||
enum UIntEnum { UIntEnum_max = UINT_MAX };
|
||||
|
||||
|
5
test/promote_enum_test.cpp
Executable file → Normal file
5
test/promote_enum_test.cpp
Executable file → Normal file
@@ -31,6 +31,11 @@
|
||||
#include "promote_util.hpp"
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
// remark #1418: external function definition with no prior declaration
|
||||
#pragma warning(disable:1418)
|
||||
#endif
|
||||
|
||||
enum IntEnum1 { IntEnum1_min = -5 , IntEnum1_max = 5 };
|
||||
enum IntEnum2 { IntEnum2_min = SHRT_MIN, IntEnum2_max = SHRT_MAX };
|
||||
enum IntEnum3 { IntEnum3_min = INT_MIN , IntEnum3_max = INT_MAX };
|
||||
|
@@ -23,6 +23,17 @@
|
||||
// We have to turn off warnings that occur within the test suite:
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
#ifdef BOOST_INTEL
|
||||
// remark #1418: external function definition with no prior declaration
|
||||
// remark #981: operands are evaluated in unspecified order
|
||||
#pragma warning(disable:1418 981)
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
// turn off warnings from this header:
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:444)
|
||||
#endif
|
||||
|
||||
//
|
||||
// basic configuration:
|
||||
@@ -156,8 +167,8 @@ void name(){ TRANSFORM_CHECK(type, BOOST_DUMMY_MACRO_PARAM, BOOST_DUMMY_MACRO_PA
|
||||
enum enum_UDT{ one, two, three };
|
||||
struct UDT
|
||||
{
|
||||
UDT(){};
|
||||
~UDT(){};
|
||||
UDT();
|
||||
~UDT();
|
||||
UDT(const UDT&);
|
||||
UDT& operator=(const UDT&);
|
||||
int i;
|
||||
@@ -206,12 +217,11 @@ typedef const r_type cr_type;
|
||||
struct POD_UDT { int x; };
|
||||
struct empty_UDT
|
||||
{
|
||||
empty_UDT(){};
|
||||
empty_UDT(const empty_UDT&){};
|
||||
~empty_UDT(){};
|
||||
empty_UDT& operator=(const empty_UDT&){ return *this; }
|
||||
bool operator==(const empty_UDT&)const
|
||||
{ return true; }
|
||||
empty_UDT();
|
||||
empty_UDT(const empty_UDT&);
|
||||
~empty_UDT();
|
||||
empty_UDT& operator=(const empty_UDT&);
|
||||
bool operator==(const empty_UDT&)const;
|
||||
};
|
||||
struct empty_POD_UDT
|
||||
{
|
||||
@@ -240,7 +250,7 @@ struct nothrow_copy_UDT
|
||||
nothrow_copy_UDT();
|
||||
nothrow_copy_UDT(const nothrow_copy_UDT&)throw();
|
||||
~nothrow_copy_UDT(){};
|
||||
nothrow_copy_UDT& operator=(const nothrow_copy_UDT&){ return *this; }
|
||||
nothrow_copy_UDT& operator=(const nothrow_copy_UDT&);
|
||||
bool operator==(const nothrow_copy_UDT&)const
|
||||
{ return true; }
|
||||
};
|
||||
@@ -289,7 +299,7 @@ struct VB
|
||||
virtual ~VB(){};
|
||||
};
|
||||
|
||||
struct VD : VB
|
||||
struct VD : public VB
|
||||
{
|
||||
~VD(){};
|
||||
};
|
||||
@@ -356,21 +366,21 @@ struct polymorphic_base
|
||||
virtual void method();
|
||||
};
|
||||
|
||||
struct polymorphic_derived1 : polymorphic_base
|
||||
struct polymorphic_derived1 : public polymorphic_base
|
||||
{
|
||||
};
|
||||
|
||||
struct polymorphic_derived2 : polymorphic_base
|
||||
struct polymorphic_derived2 : public polymorphic_base
|
||||
{
|
||||
virtual void method();
|
||||
};
|
||||
|
||||
struct virtual_inherit1 : virtual Base { };
|
||||
struct virtual_inherit2 : virtual_inherit1 { };
|
||||
struct virtual_inherit1 : public virtual Base { };
|
||||
struct virtual_inherit2 : public virtual_inherit1 { };
|
||||
struct virtual_inherit3 : private virtual Base {};
|
||||
struct virtual_inherit4 : virtual boost::noncopyable {};
|
||||
struct virtual_inherit5 : virtual int_convertible {};
|
||||
struct virtual_inherit6 : virtual Base { virtual ~virtual_inherit6()throw(); };
|
||||
struct virtual_inherit4 : public virtual boost::noncopyable {};
|
||||
struct virtual_inherit5 : public virtual int_convertible {};
|
||||
struct virtual_inherit6 : public virtual Base { virtual ~virtual_inherit6()throw(); };
|
||||
|
||||
typedef void foo0_t();
|
||||
typedef void foo1_t(int);
|
||||
@@ -413,6 +423,9 @@ protected:
|
||||
wrap& operator=(const wrap&);
|
||||
};
|
||||
|
||||
#ifdef BOOST_INTEL
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
103
test/type_traits_test.cpp
Normal file
103
test/type_traits_test.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
// (C) Copyright John Maddock 2010.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
//
|
||||
// Just check that each trait actually exists, not
|
||||
// that it gives the correct answer, we do that elsewhere:
|
||||
//
|
||||
|
||||
typedef boost::add_const<int>::type t1;
|
||||
typedef boost::add_cv<int>::type t2;
|
||||
typedef boost::add_lvalue_reference<int>::type t3;
|
||||
typedef boost::add_pointer<int>::type t4;
|
||||
typedef boost::add_reference<int>::type t5;
|
||||
typedef boost::add_rvalue_reference<int>::type t6;
|
||||
typedef boost::add_volatile<int>::type t7;
|
||||
|
||||
typedef boost::aligned_storage<2>::type t8;
|
||||
typedef boost::alignment_of<int>::type t9;
|
||||
typedef boost::conditional<true, int, long>::type t10;
|
||||
typedef boost::common_type<int, long>::type t11;
|
||||
typedef boost::decay<int[2] >::type t12;
|
||||
typedef boost::extent<int[3] >::type t13;
|
||||
typedef boost::floating_point_promotion<int>::type t14;
|
||||
typedef boost::function_traits<int (int) > t15;
|
||||
|
||||
typedef boost::has_new_operator<int> t16;
|
||||
typedef boost::has_nothrow_assign<int> t17;
|
||||
typedef boost::has_nothrow_constructor<int> t18;
|
||||
typedef boost::has_nothrow_copy<int> t19;
|
||||
typedef boost::has_nothrow_copy_constructor<int> t20;
|
||||
typedef boost::has_nothrow_default_constructor<int> t21;
|
||||
typedef boost::has_trivial_assign<int> t22;
|
||||
typedef boost::has_trivial_constructor<int> t23;
|
||||
typedef boost::has_trivial_copy<int> t24;
|
||||
typedef boost::has_trivial_copy_constructor<int> t25;
|
||||
typedef boost::has_trivial_default_constructor<int> t26;
|
||||
typedef boost::has_trivial_destructor<int> t27;
|
||||
typedef boost::has_virtual_destructor<int> t28;
|
||||
|
||||
typedef boost::integral_constant<int, 2> t29;
|
||||
typedef boost::integral_promotion<short>::type t30;
|
||||
|
||||
typedef boost::is_abstract<int>::type t31;
|
||||
typedef boost::is_arithmetic<int>::type t32;
|
||||
typedef boost::is_array<int>::type t33;
|
||||
typedef boost::is_base_of<int, long>::type t34;
|
||||
typedef boost::is_class<int>::type t35;
|
||||
typedef boost::is_complex<int>::type t36;
|
||||
typedef boost::is_compound<int>::type t37;
|
||||
typedef boost::is_const<int>::type t38;
|
||||
typedef boost::is_convertible<int, long>::type t39;
|
||||
typedef boost::is_empty<int>::type t40;
|
||||
typedef boost::is_enum<int>::type t41;
|
||||
typedef boost::is_floating_point<int>::type t42;
|
||||
typedef boost::is_function<int>::type t43;
|
||||
typedef boost::is_fundamental<int>::type t44;
|
||||
typedef boost::is_integral<int>::type t45;
|
||||
typedef boost::is_lvalue_reference<int>::type t46;
|
||||
typedef boost::is_member_function_pointer<int>::type t47;
|
||||
typedef boost::is_member_object_pointer<int>::type t48;
|
||||
typedef boost::is_member_pointer<int>::type t49;
|
||||
typedef boost::is_object<int>::type t50;
|
||||
typedef boost::is_pod<int>::type t51;
|
||||
typedef boost::is_pointer<int>::type t52;
|
||||
typedef boost::is_polymorphic<int>::type t53;
|
||||
typedef boost::is_reference<int>::type t54;
|
||||
typedef boost::is_rvalue_reference<int>::type t55;
|
||||
typedef boost::is_same<int, int>::type t56;
|
||||
typedef boost::is_scalar<int>::type t57;
|
||||
typedef boost::is_signed<int>::type t58;
|
||||
typedef boost::is_stateless<int>::type t59;
|
||||
typedef boost::is_union<int>::type t60;
|
||||
typedef boost::is_unsigned<int>::type t61;
|
||||
typedef boost::is_virtual_base_of<int, int>::type t62;
|
||||
typedef boost::is_void<int>::type t63;
|
||||
typedef boost::is_volatile<int>::type t64;
|
||||
typedef boost::make_signed<int>::type t65;
|
||||
typedef boost::make_unsigned<int>::type t66;
|
||||
typedef boost::promote<int>::type t67;
|
||||
typedef boost::rank<int>::type t68;
|
||||
|
||||
typedef boost::remove_all_extents<int>::type t69;
|
||||
typedef boost::remove_const<int>::type t70;
|
||||
typedef boost::remove_cv<int>::type t71;
|
||||
typedef boost::remove_extent<int>::type t72;
|
||||
typedef boost::remove_pointer<int>::type t73;
|
||||
typedef boost::remove_reference<int>::type t74;
|
||||
typedef boost::remove_volatile<int>::type t75;
|
||||
typedef boost::type_with_alignment<4>::type t76;
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user