Module: Mesa
Branch: master
Commit: 8d1f1ce4124c1e0dbfc5f3d0578fbee6e24140c8
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d1f1ce4124c1e0dbfc5f3d0578fbee6e24140c8

Author: Francisco Jerez <curroje...@riseup.net>
Date:   Mon Feb 12 16:32:20 2018 -0800

util: Add EXPLICIT_CONVERSION macro.

This can be used to specify that a C++ conversion operator is not
meant to be used for implicit conversions, which can lead to
unintended loss of information in some cases.  Implemented as a macro
in order to keep old GCC versions happy.

Reviewed-by: Plamena Manolova <plamena.manol...@intel.com>

---

 src/util/macros.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/util/macros.h b/src/util/macros.h
index e3c785af50..6d3df90408 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -285,4 +285,14 @@ do {                       \
 #define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
 #define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
 
+/**
+ * Macro for declaring an explicit conversion operator.  Defaults to an
+ * implicit conversion if C++11 is not supported.
+ */
+#if __cplusplus >= 201103L
+#define EXPLICIT_CONVERSION explicit
+#elif defined(__cplusplus)
+#define EXPLICIT_CONVERSION
+#endif
+
 #endif /* UTIL_MACROS_H */

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to