Index: type_traits.qbk =================================================================== RCS file: /cvsroot/boost/boost/libs/type_traits/doc/type_traits.qbk,v retrieving revision 1.8 diff -u -r1.8 type_traits.qbk --- type_traits.qbk 21 Apr 2006 09:43:55 -0000 1.8 +++ type_traits.qbk 25 May 2006 16:43:34 -0000 @@ -1,7 +1,8 @@ [library Boost.TypeTraits - [copyright 2000 2005 Adobe Systems Inc, David Abrahams, Steve Cleary, + [copyright 2000 2006 Adobe Systems Inc, David Abrahams, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat Marcus, - Itay Maman, John Maddock, Thorsten Ottosen, Robert Ramey and Jeremy Siek] + Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, + Robert Ramey and Jeremy Siek] [purpose Meta-programming support library] [license Distributed under the Boost Software License, Version 1.0. @@ -93,6 +94,10 @@ [def __function_traits [link boost_typetraits.function_traits function_traits]] +[def __promote [link boost_typetraits.promote promote]] +[def __integral_promotion [link boost_typetraits.integral_promotion integral_promotion]] +[def __floating_point_promotion [link boost_typetraits.floating_point_promotion floating_point_promotion]] + [section:intro Introduction] The Boost type-traits library contains a @@ -618,6 +623,15 @@ struct __add_volatile; template + struct __floating_point_promotion; + + template + struct __integral_promotion; + + template + struct __promote; + + template struct __remove_all_extents; template @@ -1017,6 +1031,19 @@ [endsect] +[section:to_double Convert Numeric Types and Enums to double] + +Demonstrates + + template + inline double to_double(T const& value) + { + typedef typename boost::promote::type promoted; + return boost::numeric::converter::convert(value); + } + +[endsect] + [endsect] [section:reference Alphabetical Reference] @@ -1271,6 +1298,36 @@ [endsect] +[section:floating_point_promotion floating_point_promotion] + + template + struct floating_point_promotion + { + typedef __below type; + }; + +__type If floating point promotion can be applied to an rvalue of type `T`, +then applies floating point promotion to `T` and keeps cv-qualifiers of `T`, +otherwise leaves `T` unchanged. + +__std_ref 4.6. + +__header ` #include ` or ` #include ` + +[table Examples + +[ [Expression] [Result Type]] + +[[`floating_point_promotion::type`][`double const`]] + +[[`floating_point_promotion::type`][`float&`]] + +[[`floating_point_promotion::type`][`short`]] + +] + +[endsect] + [section:function_traits function_traits] [def __argN '''argN_type'''] @@ -1582,6 +1639,36 @@ [endsect] +[section:integral_promotion integral_promotion] + + template + struct integral_promotion + { + typedef __below type; + }; + +__type If integral promotion can be applied to an rvalue of type `T`, then +applies integral promotion to `T` and keeps cv-qualifiers of `T`, +otherwise leaves `T` unchanged. + +__std_ref 4.5 except 4.5/3 (integral bit-field). + +__header ` #include ` or ` #include ` + +[table Examples + +[ [Expression] [Result Type]] + +[[`integral_promotion::type`][`int const`]] + +[[`integral_promotion::type`][`short&`]] + +[[`integral_promotion::type`][`int`]] + +] + +[endsect] + [section:is_abstract is_abstract] template struct is_abstract : public __tof {}; @@ -2520,6 +2607,37 @@ [endsect] +[section:promote promote] + + template + struct promote + { + typedef __below type; + }; + +__type If integral or floating point promotion can be applied to an rvalue +of type `T`, then applies integral and floating point promotions to `T` and +keeps cv-qualifiers of `T`, otherwise leaves `T` unchanged. See also +__integral_promotion and __floating_point_promotion. + +__std_ref 4.5 except 4.5/3 (integral bit-field) and 4.6. + +__header ` #include ` or ` #include ` + +[table Examples + +[ [Expression] [Result Type]] + +[[`promote::type`][`int volatile`]] + +[[`promote::type`][`double const`]] + +[[`promote::type`][`short&`]] + +] + +[endsect] + [section:rank rank] template struct rank : public __integral_constant {};