summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-26 09:06:41 -0400
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-26 09:06:41 -0400
commita721830767c6a7819ed82cda5f910b732201f885 (patch)
tree8d39d75be113273e720779ef62891a11e8367e38
parent4d6f0a55731e462a53feb0956484c104ab8c1018 (diff)
parente6380b11e9d900c9b60ad6fbd46171092bf0136e (diff)
downloadcmake-a721830767c6a7819ed82cda5f910b732201f885.tar.gz
Merge topic 'auto-ptr'
e6380b11 Use std::auto_ptr on compilers that do not warn about it 67480c05 Add a feature check to test availability of auto_ptr
-rw-r--r--Source/Checks/cm_cxx_auto_ptr.cxx18
-rw-r--r--Source/Checks/cm_cxx_features.cmake1
-rw-r--r--Source/cmConfigure.cmake.h.in1
-rw-r--r--Source/cm_auto_ptr.hxx10
4 files changed, 29 insertions, 1 deletions
diff --git a/Source/Checks/cm_cxx_auto_ptr.cxx b/Source/Checks/cm_cxx_auto_ptr.cxx
new file mode 100644
index 0000000000..d3100fdc83
--- /dev/null
+++ b/Source/Checks/cm_cxx_auto_ptr.cxx
@@ -0,0 +1,18 @@
+#include <memory>
+
+std::auto_ptr<int> get_auto_ptr()
+{
+ std::auto_ptr<int> ptr;
+ ptr = std::auto_ptr<int>(new int(0));
+ return ptr;
+}
+
+int use_auto_ptr(std::auto_ptr<int> ptr)
+{
+ return *ptr;
+}
+
+int main()
+{
+ return use_auto_ptr(get_auto_ptr());
+}
diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake
index c6a532fcc5..80c9f3b7a7 100644
--- a/Source/Checks/cm_cxx_features.cmake
+++ b/Source/Checks/cm_cxx_features.cmake
@@ -32,6 +32,7 @@ function(cm_check_cxx_feature name)
endfunction()
if(CMAKE_CXX_STANDARD)
+ cm_check_cxx_feature(auto_ptr)
cm_check_cxx_feature(make_unique)
if(CMake_HAVE_CXX_MAKE_UNIQUE)
set(CMake_HAVE_CXX_UNIQUE_PTR 1)
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index 8365367a08..8a1e81f3f1 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -30,6 +30,7 @@
#cmakedefine CMAKE_USE_MACH_PARSER
#cmakedefine CMAKE_USE_LIBUV
#cmakedefine CMAKE_ENCODING_UTF8
+#cmakedefine CMake_HAVE_CXX_AUTO_PTR
#cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE
#cmakedefine CMake_HAVE_CXX_NULLPTR
#cmakedefine CMake_HAVE_CXX_OVERRIDE
diff --git a/Source/cm_auto_ptr.hxx b/Source/cm_auto_ptr.hxx
index f6c43624f8..f38eda5ab4 100644
--- a/Source/cm_auto_ptr.hxx
+++ b/Source/cm_auto_ptr.hxx
@@ -14,7 +14,13 @@
#include <cmConfigure.h>
-// FIXME: Use std::auto_ptr on compilers that do not warn about it.
+#ifdef CMake_HAVE_CXX_AUTO_PTR
+
+#include <memory>
+#define CM_AUTO_PTR std::auto_ptr
+
+#else
+
#define CM_AUTO_PTR cm::auto_ptr
// The HP compiler cannot handle the conversions necessary to use
@@ -219,3 +225,5 @@ public:
#endif
#endif
+
+#endif