Boost logo

Boost-Commit :

From: steven_at_[hidden]
Date: 2008-06-28 00:09:43


Author: steven_watanabe
Date: 2008-06-28 00:09:43 EDT (Sat, 28 Jun 2008)
New Revision: 46804
URL: http://svn.boost.org/trac/boost/changeset/46804

Log:
Make the fail add and subtract tests pass on sun
Text files modified:
   trunk/boost/units/quantity.hpp | 42 ++++++++++++++++++++++++++++++++++++++++
   1 files changed, 42 insertions(+), 0 deletions(-)

Modified: trunk/boost/units/quantity.hpp
==============================================================================
--- trunk/boost/units/quantity.hpp (original)
+++ trunk/boost/units/quantity.hpp 2008-06-28 00:09:43 EDT (Sat, 28 Jun 2008)
@@ -549,6 +549,28 @@
     typedef quantity<unit_type,value_type> type;
 };
 
+/// for sun CC we need to invoke SFINAE at
+/// the top level, otherwise it will silently
+/// return int.
+template<class Dim1, class System1,
+ class Dim2, class System2,
+ class X,
+ class Y>
+struct add_typeof_helper< quantity<unit<Dim1, System1>,X>,quantity<unit<Dim2, System2>,Y> >
+{
+};
+
+template<class Dim,
+ class System,
+ class X,
+ class Y>
+struct add_typeof_helper< quantity<unit<Dim, System>,X>,quantity<unit<Dim, System>,Y> >
+{
+ typedef typename add_typeof_helper<X,Y>::type value_type;
+ typedef unit<Dim, System> unit_type;
+ typedef quantity<unit_type,value_type> type;
+};
+
 /// specialize subtract typeof helper
 /// INTERNAL ONLY
 template<class Unit1,
@@ -562,6 +584,26 @@
     typedef quantity<unit_type,value_type> type;
 };
 
+// Force adding different units to fail on sun.
+template<class Dim1, class System1,
+ class Dim2, class System2,
+ class X,
+ class Y>
+struct subtract_typeof_helper< quantity<unit<Dim1, System1>,X>,quantity<unit<Dim2, System2>,Y> >
+{
+};
+
+template<class Dim,
+ class System,
+ class X,
+ class Y>
+struct subtract_typeof_helper< quantity<unit<Dim, System>,X>,quantity<unit<Dim, System>,Y> >
+{
+ typedef typename subtract_typeof_helper<X,Y>::type value_type;
+ typedef unit<Dim, System> unit_type;
+ typedef quantity<unit_type,value_type> type;
+};
+
 /// scalar times unit typeof helper
 /// INTERNAL ONLY
 template<class System,


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