Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-05-31 17:58:01


Author: steven_watanabe
Date: 2008-05-31 17:58:00 EDT (Sat, 31 May 2008)
New Revision: 45993
URL: http://svn.boost.org/trac/boost/changeset/45993

Log:
Switched description of heterogeneous operators to use Boost.Typeof
Text files modified:
   sandbox/units/libs/units/doc/units.qbk | 27 ++++++++-------------------
   1 files changed, 8 insertions(+), 19 deletions(-)

Modified: sandbox/units/libs/units/doc/units.qbk
==============================================================================
--- sandbox/units/libs/units/doc/units.qbk (original)
+++ sandbox/units/libs/units/doc/units.qbk 2008-05-31 17:58:00 EDT (Sat, 31 May 2008)
@@ -387,25 +387,14 @@
 * [$../../../units/images/form_15.png]
 
 This library is designed to support arbitrary value type algebra for addition, subtraction, multiplication, division, and
-rational powers and roots. For compilers that support `typeof`, the appropriate value type will be automatically deduced.
-For compilers that do not provide language support for `typeof`, it is necessary to specialize the desired operator helper
-template classes to define the algebra. For the case of natural numbers, this would amount to something like the following
-pseudocode:
-
- template<> struct add_typeof_helper<natural,natural> { typedef natural type; };
- template<> struct subtract_typeof_helper<natural,natural> { typedef integer type; };
- template<> struct multiply_typeof_helper<natural,natural> { typedef natural type; };
- template<> struct divide_typeof_helper<natural,natural> { typedef rational type; };
-
- typename add_typeof_helper<natural,natural>::type operator+(natural x,natural y);
- typename subtract_typeof_helper<natural,natural>::type operator-(natural x,natural y);
- typename multiply_typeof_helper<natural,natural>::type operator*(natural x,natural y);
- typename divide_typeof_helper<natural,natural>::type operator/(natural x,natural y);
-
-Naturally, it is also possible to define heterogeneous operators between different value types:
-
- template<> struct add_typeof_helper<natural,integer> { typedef integer type; };
- template<> struct add_typeof_helper<integer,natural> { typedef integer type; };
+rational powers and roots. It uses Boost.Typeof to deduce the result of these operators. For compilers that
+support `typeof`, the appropriate value type will be automatically deduced. For compilers that do not provide
+language support for `typeof` it is necessary to register all the types used. For the case of natural numbers,
+this would amount to something like the following:
+
+ BOOST_TYPEOF_REGISTER_TYPE(natural);
+ BOOST_TYPEOF_REGISTER_TYPE(integer);
+ BOOST_TYPEOF_REGISTER_TYPE(rational);
 
 [endsect]
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk