Browse Source

Features: Add cxx_explicit_conversions.

Stephen Kelly 11 years ago
parent
commit
ebab2015f9

+ 5 - 0
Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst

@@ -42,6 +42,11 @@ The features known to this version of CMake are:
 
   .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
 
+``cxx_explicit_conversions``
+  Explicit conversion operators, as defined in N2437_.
+
+  .. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
+
 ``cxx_final``
   Override control ``final`` keyword, as defined in N2928_.
 

+ 3 - 0
Modules/Compiler/GNU-CXX-FeatureTests.cmake

@@ -15,6 +15,9 @@ set(_cmake_feature_test_cxx_override "${GNU47_CXX11}")
 # TODO: Should be supported by GNU 4.6
 set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}")
+# TODO: Should be supported by GNU 4.5
+set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}")
 # TODO: Should be supported by GNU 4.4
 set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
 set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}")

+ 1 - 0
Source/cmMakefile.cxx

@@ -48,6 +48,7 @@
   F(cxx_defaulted_functions) \
   F(cxx_delegating_constructors) \
   F(cxx_deleted_functions) \
+  F(cxx_explicit_conversions) \
   F(cxx_final) \
   F(cxx_override) \
   F(cxx_static_assert) \

+ 10 - 0
Tests/CompileFeatures/cxx_explicit_conversions.cpp

@@ -0,0 +1,10 @@
+
+class A
+{
+  int m_i;
+public:
+  explicit operator bool()
+  {
+    return m_i != 0;
+  }
+};