summaryrefslogtreecommitdiffstats
path: root/src/util/macros.h
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2018-02-12 16:32:20 -0800
committerFrancisco Jerez <[email protected]>2018-02-24 15:28:36 -0800
commit8d1f1ce4124c1e0dbfc5f3d0578fbee6e24140c8 (patch)
tree8c7c2a0d3c3a9c0a267a81791d5ea6f001bf5f41 /src/util/macros.h
parent378e918e2891b2712b64c4ad1ef92bfc539a13e7 (diff)
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 <[email protected]>
Diffstat (limited to 'src/util/macros.h')
-rw-r--r--src/util/macros.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/util/macros.h b/src/util/macros.h
index e3c785af508..6d3df904082 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 */