[Orxonox-commit 5886] r10546 - code/trunk/src/libraries/tools

muemart at orxonox.net muemart at orxonox.net
Thu Jul 30 14:13:22 CEST 2015


Author: muemart
Date: 2015-07-30 14:13:21 +0200 (Thu, 30 Jul 2015)
New Revision: 10546

Modified:
   code/trunk/src/libraries/tools/TextureGenerator.cc
Log:
Fix MSVC14/Visual Studio 2015 build: std::less must be constexpr

Modified: code/trunk/src/libraries/tools/TextureGenerator.cc
===================================================================
--- code/trunk/src/libraries/tools/TextureGenerator.cc	2015-07-14 21:23:57 UTC (rev 10545)
+++ code/trunk/src/libraries/tools/TextureGenerator.cc	2015-07-30 12:13:21 UTC (rev 10546)
@@ -38,24 +38,33 @@
 #include "util/Convert.h"
 #include "util/Math.h"
 
+#if _MSC_VER >= 1900
+#define STLSPEC constexpr
+#else
+#define STLSPEC inline
+#endif
+
 namespace std
 {
     template <>
-    inline bool less<orxonox::ColourValue>::operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
+    STLSPEC bool less<orxonox::ColourValue>::operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
     {
-        if (__x.r == __y.r)
-        {
-            if (__x.g == __y.g)
-            {
-                if (__x.b == __y.b)
-                {
-                    return __x.a < __y.a;
-                }
-                return __x.b < __y.b;
-            }
-            return __x.g < __y.g;
-        }
-        return __x.r < __y.r;
+        //MSVC14 needs this function to be constexpr, but doesn't support C++14's style
+        //Keep the old code around for superior readability
+        //if (__x.r == __y.r)
+        //{
+        //    if (__x.g == __y.g)
+        //    {
+        //        if (__x.b == __y.b)
+        //        {
+        //            return __x.a < __y.a;
+        //        }
+        //        return __x.b < __y.b;
+        //    }
+        //    return __x.g < __y.g;
+        //}
+        //return __x.r < __y.r;
+        return __x.r == __y.r ? __x.g == __y.g ? __x.b == __y.b ? __x.a < __y.a : __x.b < __y.b : __x.g < __y.g :  __x.r < __y.r;
     }
 }
 




More information about the Orxonox-commit mailing list