← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug986016 into lp:zorba

 

Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/bug986016 into lp:zorba.

Requested reviews:
  Rodolfo Ochoa (rodolfo-ochoa)
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #986016 in Zorba: "Windows trunk not compiling"
  https://bugs.launchpad.net/zorba/+bug/986016

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug986016/+merge/102876

Work-around for Windows compiler problem; see:
http://stackoverflow.com/questions/9285657/sfinae-differentiation-between-signed-and-unsigned
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug986016/+merge/102876
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/util/stl_util.h'
--- src/util/stl_util.h	2012-04-19 21:40:27 +0000
+++ src/util/stl_util.h	2012-04-20 14:55:21 +0000
@@ -299,6 +299,9 @@
 // cases where the "signed-ness" of N1 and N2 differ such that the code is
 // warning-free.
 //
+// Note: the use of "!!" is to work around a compiler problem on Windows;
+// see: http://stackoverflow.com/questions/9285657/sfinae-differentiation-between-signed-and-unsigned
+//
 
 template<typename N1,typename N2> inline
 typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value
@@ -309,21 +312,21 @@
 
 template<typename N1,typename N2> inline
 typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value
-                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
+                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 ge_min( N1 n1, N2 ) {
   return n1 >= 0;
 }
 
 template<typename N1,typename N2> inline
-typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
+typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
                      && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type
 ge_min( N1, N2 ) {
   return true;
 }
 
 template<typename N1,typename N2> inline
-typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
-                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
+typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
+                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 ge_min( N1, N2 ) {
   return true;
 }
@@ -337,21 +340,21 @@
 
 template<typename N1,typename N2> inline
 typename std::enable_if<ZORBA_TR1_NS::is_signed<N1>::value
-                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
+                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 le_max( N1 n1, N2 ) {
   return n1 <= 0 || static_cast<N2>( n1 ) <= std::numeric_limits<N2>::max();
 }
 
 template<typename N1,typename N2> inline
-typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
+typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
                      && ZORBA_TR1_NS::is_signed<N2>::value,bool>::type
 le_max( N1 n1, N2 ) {
   return n1 <= static_cast<N1>( std::numeric_limits<N2>::max() );
 }
 
 template<typename N1,typename N2> inline
-typename std::enable_if<ZORBA_TR1_NS::is_unsigned<N1>::value
-                     && ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
+typename std::enable_if<!!ZORBA_TR1_NS::is_unsigned<N1>::value
+                     && !!ZORBA_TR1_NS::is_unsigned<N2>::value,bool>::type
 le_max( N1 n1, N2 ) {
   return n1 <= std::numeric_limits<N2>::max();
 }


Follow ups