From c77a72a7cc4cde12b2f86f9dd4d52ff3cf0cb2e3 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Fri, 24 Sep 2010 17:12:08 +0000 Subject: [PATCH] Add conditional trait. Update and regenerate docs. Update type_traits.hpp and add trivial test case for it. [SVN r65575] --- doc/conditional.qbk | 18 +++ doc/html/boost_typetraits/background.html | 22 ++-- .../boost_typetraits/category/transform.html | 5 +- doc/html/boost_typetraits/history.html | 4 +- doc/html/boost_typetraits/intrinsics.html | 2 +- doc/html/boost_typetraits/reference.html | 3 + .../boost_typetraits/reference/add_const.html | 2 +- .../boost_typetraits/reference/add_cv.html | 2 +- .../reference/add_lvalue_reference.html | 2 +- .../reference/add_pointer.html | 2 +- .../reference/add_reference.html | 2 +- .../reference/add_rvalue_reference.html | 2 +- .../reference/add_volatile.html | 2 +- .../reference/alignment_of.html | 6 +- .../reference/common_type.html | 20 ++-- .../boost_typetraits/reference/decay.html | 2 +- .../reference/floating_point_promotion.html | 2 +- .../reference/function_traits.html | 4 +- .../reference/integral_promotion.html | 2 +- .../reference/make_signed.html | 2 +- .../reference/make_unsigned.html | 2 +- .../boost_typetraits/reference/promote.html | 2 +- .../reference/remove_all_extents.html | 2 +- .../reference/remove_const.html | 2 +- .../boost_typetraits/reference/remove_cv.html | 2 +- .../reference/remove_extent.html | 2 +- .../reference/remove_pointer.html | 2 +- .../reference/remove_reference.html | 2 +- .../reference/remove_volatile.html | 2 +- doc/html/index.html | 5 +- doc/transform_traits.qbk | 3 + doc/type_traits.qbk | 2 + include/boost/type_traits.hpp | 26 +++-- include/boost/type_traits/conditional.hpp | 25 +++++ test/conditional_test.cpp | 31 ++++++ test/type_traits_test.cpp | 103 ++++++++++++++++++ 36 files changed, 256 insertions(+), 63 deletions(-) create mode 100644 doc/conditional.qbk create mode 100644 include/boost/type_traits/conditional.hpp create mode 100644 test/conditional_test.cpp create mode 100644 test/type_traits_test.cpp diff --git a/doc/conditional.qbk b/doc/conditional.qbk new file mode 100644 index 0000000..317bf53 --- /dev/null +++ b/doc/conditional.qbk @@ -0,0 +1,18 @@ + +[/===================================================================] +[section:conditional conditional] +[/===================================================================] + + +`#include ` + + namespace boost { + template 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] + diff --git a/doc/html/boost_typetraits/background.html b/doc/html/boost_typetraits/background.html index 41c0b33..01b7985 100644 --- a/doc/html/boost_typetraits/background.html +++ b/doc/html/boost_typetraits/background.html @@ -56,7 +56,7 @@ method available to them.

- + Type Traits

@@ -84,7 +84,7 @@ given.

- + Implementation

@@ -174,7 +174,7 @@ in the default template.

- + Optimized copy

@@ -247,7 +247,7 @@ otherwise it will call the "slow but safe version".

- + Was it worth it?

@@ -280,7 +280,7 @@

-

Table 1.1. Time taken to copy 1000 elements using `copy<const T*, T*>` (times +

Table 1.1. Time taken to copy 1000 elements using `copy<const T*, T*>` (times in micro-seconds)

@@ -379,7 +379,7 @@

- + Pair of References

@@ -416,7 +416,7 @@ to hold non-reference types, references, and constant references:

-

Table 1.2. Required Constructor Argument Types

+

Table 1.2. Required Constructor Argument Types

@@ -481,7 +481,7 @@ adds a reference to its type, unless it is already a reference.

-

Table 1.3. Using add_reference to synthesize the correct constructor type

+

Table 1.3. Using add_reference to synthesize the correct constructor type

@@ -597,7 +597,7 @@ easier to maintain and easier to understand.

- + Conclusion

@@ -610,7 +610,7 @@ can be optimal as well as generic.

- + Acknowledgements

@@ -618,7 +618,7 @@ comments when preparing this article.

- + References
    diff --git a/doc/html/boost_typetraits/category/transform.html b/doc/html/boost_typetraits/category/transform.html index ae7900b..ee2a020 100644 --- a/doc/html/boost_typetraits/category/transform.html +++ b/doc/html/boost_typetraits/category/transform.html @@ -57,6 +57,9 @@ template <class T> struct add_volatile; +template <bool B, class T, class U> +struct conditional; + template <class... T> struct common_type; @@ -100,7 +103,7 @@ struct remove_volatile;
    - + Broken Compiler Workarounds:
    diff --git a/doc/html/boost_typetraits/history.html b/doc/html/boost_typetraits/history.html index 07985f8..c3adeac 100644 --- a/doc/html/boost_typetraits/history.html +++ b/doc/html/boost_typetraits/history.html @@ -27,7 +27,7 @@ History
- + Boost 1.44.0
    @@ -43,7 +43,7 @@
- + Boost 1.42.0
  • diff --git a/doc/html/boost_typetraits/intrinsics.html b/doc/html/boost_typetraits/intrinsics.html index f329ecf..532438c 100644 --- a/doc/html/boost_typetraits/intrinsics.html +++ b/doc/html/boost_typetraits/intrinsics.html @@ -99,7 +99,7 @@ of the following macros:

    -

    Table 1.4. Macros for Compiler Intrinsics

    +

    Table 1.4. Macros for Compiler Intrinsics

diff --git a/doc/html/boost_typetraits/reference.html b/doc/html/boost_typetraits/reference.html index 15691e0..67da972 100644 --- a/doc/html/boost_typetraits/reference.html +++ b/doc/html/boost_typetraits/reference.html @@ -36,6 +36,7 @@
add_volatile
aligned_storage
alignment_of
+
Conditional
common_type
decay
extent
@@ -108,6 +109,8 @@
remove_volatile
type_with_alignment
+

+

diff --git a/doc/html/boost_typetraits/reference/add_const.html b/doc/html/boost_typetraits/reference/add_const.html index 277d95f..ac45ffe 100644 --- a/doc/html/boost_typetraits/reference/add_const.html +++ b/doc/html/boost_typetraits/reference/add_const.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.5. Examples

+

Table 1.5. Examples

diff --git a/doc/html/boost_typetraits/reference/add_cv.html b/doc/html/boost_typetraits/reference/add_cv.html index f492e43..1e0e86a 100644 --- a/doc/html/boost_typetraits/reference/add_cv.html +++ b/doc/html/boost_typetraits/reference/add_cv.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.6. Examples

+

Table 1.6. Examples

diff --git a/doc/html/boost_typetraits/reference/add_lvalue_reference.html b/doc/html/boost_typetraits/reference/add_lvalue_reference.html index 613edcd..5edb05b 100644 --- a/doc/html/boost_typetraits/reference/add_lvalue_reference.html +++ b/doc/html/boost_typetraits/reference/add_lvalue_reference.html @@ -58,7 +58,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.7. Examples

+

Table 1.7. Examples

diff --git a/doc/html/boost_typetraits/reference/add_pointer.html b/doc/html/boost_typetraits/reference/add_pointer.html index 71da3d3..b11225e 100644 --- a/doc/html/boost_typetraits/reference/add_pointer.html +++ b/doc/html/boost_typetraits/reference/add_pointer.html @@ -56,7 +56,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.8. Examples

+

Table 1.8. Examples

diff --git a/doc/html/boost_typetraits/reference/add_reference.html b/doc/html/boost_typetraits/reference/add_reference.html index 8d8fc1f..4860561 100644 --- a/doc/html/boost_typetraits/reference/add_reference.html +++ b/doc/html/boost_typetraits/reference/add_reference.html @@ -65,7 +65,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.9. Examples

+

Table 1.9. Examples

diff --git a/doc/html/boost_typetraits/reference/add_rvalue_reference.html b/doc/html/boost_typetraits/reference/add_rvalue_reference.html index 6d8290f..f647c1b 100644 --- a/doc/html/boost_typetraits/reference/add_rvalue_reference.html +++ b/doc/html/boost_typetraits/reference/add_rvalue_reference.html @@ -56,7 +56,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.10. Examples

+

Table 1.10. Examples

diff --git a/doc/html/boost_typetraits/reference/add_volatile.html b/doc/html/boost_typetraits/reference/add_volatile.html index 3ebaef0..c64192a 100644 --- a/doc/html/boost_typetraits/reference/add_volatile.html +++ b/doc/html/boost_typetraits/reference/add_volatile.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.11. Examples

+

Table 1.11. Examples

diff --git a/doc/html/boost_typetraits/reference/alignment_of.html b/doc/html/boost_typetraits/reference/alignment_of.html index f1d3739..034eec5 100644 --- a/doc/html/boost_typetraits/reference/alignment_of.html +++ b/doc/html/boost_typetraits/reference/alignment_of.html @@ -7,7 +7,7 @@ - +
@@ -20,7 +20,7 @@

-PrevUpHomeNext +PrevUpHomeNext

@@ -76,7 +76,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/html/boost_typetraits/reference/common_type.html b/doc/html/boost_typetraits/reference/common_type.html index 27f84a3..b2b1b7f 100644 --- a/doc/html/boost_typetraits/reference/common_type.html +++ b/doc/html/boost_typetraits/reference/common_type.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@
-PrevUpHomeNext +PrevUpHomeNext

@@ -73,7 +73,7 @@ template arguments is 3.

- + Configuration macros
@@ -103,7 +103,7 @@ Otherwise when BOOST_COMMON_TYPE_DONT_USE_TYPEOF is not defined it uses Boost.TypeOf.

- + Tutorial

@@ -138,7 +138,7 @@ This is a very useful and broadly applicable utility.

- + How to get the common type of types with explicit conversions?
@@ -160,7 +160,7 @@ };
- + How important is the order of the common_type<> template arguments?
@@ -240,7 +240,7 @@ A>.

- + Can the common_type of two types be a third type?
@@ -267,7 +267,7 @@ B>.

- + How common_type behaves with pointers?
@@ -303,7 +303,7 @@ Of course the user can always make this specialization.

- + Can you explain the pros/cons of common_type against Boost.Typeof?
@@ -344,7 +344,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/html/boost_typetraits/reference/decay.html b/doc/html/boost_typetraits/reference/decay.html index b9156c7..bb61bc9 100644 --- a/doc/html/boost_typetraits/reference/decay.html +++ b/doc/html/boost_typetraits/reference/decay.html @@ -48,7 +48,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.12. Examples

+

Table 1.12. Examples

diff --git a/doc/html/boost_typetraits/reference/floating_point_promotion.html b/doc/html/boost_typetraits/reference/floating_point_promotion.html index 366a913..f168d20 100644 --- a/doc/html/boost_typetraits/reference/floating_point_promotion.html +++ b/doc/html/boost_typetraits/reference/floating_point_promotion.html @@ -49,7 +49,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.13. Examples

+

Table 1.13. Examples

diff --git a/doc/html/boost_typetraits/reference/function_traits.html b/doc/html/boost_typetraits/reference/function_traits.html index 22c6c98..299f4a7 100644 --- a/doc/html/boost_typetraits/reference/function_traits.html +++ b/doc/html/boost_typetraits/reference/function_traits.html @@ -59,7 +59,7 @@

-

Table 1.14. Function Traits Members

+

Table 1.14. Function Traits Members

@@ -122,7 +122,7 @@

-

Table 1.15. Examples

+

Table 1.15. Examples

diff --git a/doc/html/boost_typetraits/reference/integral_promotion.html b/doc/html/boost_typetraits/reference/integral_promotion.html index 58e1bad..90093c3 100644 --- a/doc/html/boost_typetraits/reference/integral_promotion.html +++ b/doc/html/boost_typetraits/reference/integral_promotion.html @@ -49,7 +49,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.16. Examples

+

Table 1.16. Examples

diff --git a/doc/html/boost_typetraits/reference/make_signed.html b/doc/html/boost_typetraits/reference/make_signed.html index ba7ae32..2641e52 100644 --- a/doc/html/boost_typetraits/reference/make_signed.html +++ b/doc/html/boost_typetraits/reference/make_signed.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.17. Examples

+

Table 1.17. Examples

diff --git a/doc/html/boost_typetraits/reference/make_unsigned.html b/doc/html/boost_typetraits/reference/make_unsigned.html index bca3d3e..6ab6fc4 100644 --- a/doc/html/boost_typetraits/reference/make_unsigned.html +++ b/doc/html/boost_typetraits/reference/make_unsigned.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.18. Examples

+

Table 1.18. Examples

diff --git a/doc/html/boost_typetraits/reference/promote.html b/doc/html/boost_typetraits/reference/promote.html index 3cf0828..224b7bb 100644 --- a/doc/html/boost_typetraits/reference/promote.html +++ b/doc/html/boost_typetraits/reference/promote.html @@ -51,7 +51,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.19. Examples

+

Table 1.19. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_all_extents.html b/doc/html/boost_typetraits/reference/remove_all_extents.html index d58b0ea..0db28f1 100644 --- a/doc/html/boost_typetraits/reference/remove_all_extents.html +++ b/doc/html/boost_typetraits/reference/remove_all_extents.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.20. Examples

+

Table 1.20. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_const.html b/doc/html/boost_typetraits/reference/remove_const.html index 2edc490..142a279 100644 --- a/doc/html/boost_typetraits/reference/remove_const.html +++ b/doc/html/boost_typetraits/reference/remove_const.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.21. Examples

+

Table 1.21. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_cv.html b/doc/html/boost_typetraits/reference/remove_cv.html index c7ba3cc..f9093c6 100644 --- a/doc/html/boost_typetraits/reference/remove_cv.html +++ b/doc/html/boost_typetraits/reference/remove_cv.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.22. Examples

+

Table 1.22. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_extent.html b/doc/html/boost_typetraits/reference/remove_extent.html index 64f8278..3287eb1 100644 --- a/doc/html/boost_typetraits/reference/remove_extent.html +++ b/doc/html/boost_typetraits/reference/remove_extent.html @@ -54,7 +54,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.23. Examples

+

Table 1.23. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_pointer.html b/doc/html/boost_typetraits/reference/remove_pointer.html index 6b021be..a231b5d 100644 --- a/doc/html/boost_typetraits/reference/remove_pointer.html +++ b/doc/html/boost_typetraits/reference/remove_pointer.html @@ -55,7 +55,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.24. Examples

+

Table 1.24. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_reference.html b/doc/html/boost_typetraits/reference/remove_reference.html index c7e7505..30c9a27 100644 --- a/doc/html/boost_typetraits/reference/remove_reference.html +++ b/doc/html/boost_typetraits/reference/remove_reference.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.25. Examples

+

Table 1.25. Examples

diff --git a/doc/html/boost_typetraits/reference/remove_volatile.html b/doc/html/boost_typetraits/reference/remove_volatile.html index d99b91a..e7dcb15 100644 --- a/doc/html/boost_typetraits/reference/remove_volatile.html +++ b/doc/html/boost_typetraits/reference/remove_volatile.html @@ -53,7 +53,7 @@ or #include <boost/type_traits.hpp>

-

Table 1.26. Examples

+

Table 1.26. Examples

diff --git a/doc/html/index.html b/doc/html/index.html index 5ff86e6..404b38b 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -30,7 +30,7 @@ Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert Ramey and Jeremy Siek

-

+

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)

@@ -89,6 +89,7 @@
add_volatile
aligned_storage
alignment_of
+
Conditional
common_type
decay
extent
@@ -171,7 +172,7 @@

- +

Last revised: September 11, 2010 at 19:00:56 +0100

Last revised: September 17, 2010 at 13:12:03 +0100


diff --git a/doc/transform_traits.qbk b/doc/transform_traits.qbk index 85763bc..980ebe4 100644 --- a/doc/transform_traits.qbk +++ b/doc/transform_traits.qbk @@ -35,6 +35,9 @@ result of applying the transformation to the template argument `T`. template struct __add_volatile; + template + struct __conditional; + template struct __common_type; diff --git a/doc/type_traits.qbk b/doc/type_traits.qbk index f709943..734c9f5 100644 --- a/doc/type_traits.qbk +++ b/doc/type_traits.qbk @@ -108,6 +108,7 @@ [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]] @@ -172,6 +173,7 @@ that is the result of the transformation. [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] diff --git a/include/boost/type_traits.hpp b/include/boost/type_traits.hpp index a46e90a..c725296 100644 --- a/include/boost/type_traits.hpp +++ b/include/boost/type_traits.hpp @@ -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 #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 +#include #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 -#include -#include -#include #include "boost/type_traits/ice.hpp" diff --git a/include/boost/type_traits/conditional.hpp b/include/boost/type_traits/conditional.hpp new file mode 100644 index 0000000..8bbda85 --- /dev/null +++ b/include/boost/type_traits/conditional.hpp @@ -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 + +namespace boost { + +template +struct conditional : public mpl::if_c +{ +}; + +} // namespace boost + + +#endif // BOOST_TT_CONDITIONAL_HPP_INCLUDED diff --git a/test/conditional_test.cpp b/test/conditional_test.cpp new file mode 100644 index 0000000..1cc3534 --- /dev/null +++ b/test/conditional_test.cpp @@ -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 +#else +# include +#endif +#include + +TT_TEST_BEGIN(conditional) + +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional::type, int>::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional::type, long>::value), true); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional::type, long>::value), false); +BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_same< ::tt::conditional::type, int>::value), false); + +TT_TEST_END + + + + + + + + diff --git a/test/type_traits_test.cpp b/test/type_traits_test.cpp new file mode 100644 index 0000000..c0fc21d --- /dev/null +++ b/test/type_traits_test.cpp @@ -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 + +// +// Just check that each trait actually exists, not +// that it gives the correct answer, we do that elsewhere: +// + +typedef boost::add_const::type t1; +typedef boost::add_cv::type t2; +typedef boost::add_lvalue_reference::type t3; +typedef boost::add_pointer::type t4; +typedef boost::add_reference::type t5; +typedef boost::add_rvalue_reference::type t6; +typedef boost::add_volatile::type t7; + +typedef boost::aligned_storage<2>::type t8; +typedef boost::alignment_of::type t9; +typedef boost::conditional::type t10; +typedef boost::common_type::type t11; +typedef boost::decay::type t12; +typedef boost::extent::type t13; +typedef boost::floating_point_promotion::type t14; +typedef boost::function_traits t15; + +typedef boost::has_new_operator t16; +typedef boost::has_nothrow_assign t17; +typedef boost::has_nothrow_constructor t18; +typedef boost::has_nothrow_copy t19; +typedef boost::has_nothrow_copy_constructor t20; +typedef boost::has_nothrow_default_constructor t21; +typedef boost::has_trivial_assign t22; +typedef boost::has_trivial_constructor t23; +typedef boost::has_trivial_copy t24; +typedef boost::has_trivial_copy_constructor t25; +typedef boost::has_trivial_default_constructor t26; +typedef boost::has_trivial_destructor t27; +typedef boost::has_virtual_destructor t28; + +typedef boost::integral_constant t29; +typedef boost::integral_promotion::type t30; + +typedef boost::is_abstract::type t31; +typedef boost::is_arithmetic::type t32; +typedef boost::is_array::type t33; +typedef boost::is_base_of::type t34; +typedef boost::is_class::type t35; +typedef boost::is_complex::type t36; +typedef boost::is_compound::type t37; +typedef boost::is_const::type t38; +typedef boost::is_convertible::type t39; +typedef boost::is_empty::type t40; +typedef boost::is_enum::type t41; +typedef boost::is_floating_point::type t42; +typedef boost::is_function::type t43; +typedef boost::is_fundamental::type t44; +typedef boost::is_integral::type t45; +typedef boost::is_lvalue_reference::type t46; +typedef boost::is_member_function_pointer::type t47; +typedef boost::is_member_object_pointer::type t48; +typedef boost::is_member_pointer::type t49; +typedef boost::is_object::type t50; +typedef boost::is_pod::type t51; +typedef boost::is_pointer::type t52; +typedef boost::is_polymorphic::type t53; +typedef boost::is_reference::type t54; +typedef boost::is_rvalue_reference::type t55; +typedef boost::is_same::type t56; +typedef boost::is_scalar::type t57; +typedef boost::is_signed::type t58; +typedef boost::is_stateless::type t59; +typedef boost::is_union::type t60; +typedef boost::is_unsigned::type t61; +typedef boost::is_virtual_base_of::type t62; +typedef boost::is_void::type t63; +typedef boost::is_volatile::type t64; +typedef boost::make_signed::type t65; +typedef boost::make_unsigned::type t66; +typedef boost::promote::type t67; +typedef boost::rank::type t68; + +typedef boost::remove_all_extents::type t69; +typedef boost::remove_const::type t70; +typedef boost::remove_cv::type t71; +typedef boost::remove_extent::type t72; +typedef boost::remove_pointer::type t73; +typedef boost::remove_reference::type t74; +typedef boost::remove_volatile::type t75; +typedef boost::type_with_alignment<4>::type t76; + +int main() +{ + return 0; +} + + + +