summaryrefslogtreecommitdiffstats
path: root/Source/cm_memory.hxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2019-07-02 09:08:04 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2019-07-14 13:37:30 (GMT)
commitd9b2c7dae242868f13fc366773fb09448da26e8d (patch)
tree12e97152327bdff419861deded5b2f7d6a0961be /Source/cm_memory.hxx
parent81389a5e8f14a09d26a8efb22fd12063168caba6 (diff)
downloadCMake-d9b2c7dae242868f13fc366773fb09448da26e8d.zip
CMake-d9b2c7dae242868f13fc366773fb09448da26e8d.tar.gz
CMake-d9b2c7dae242868f13fc366773fb09448da26e8d.tar.bz2
Introduce memory management helper: cm_memory.hxx
Diffstat (limited to 'Source/cm_memory.hxx')
-rw-r--r--Source/cm_memory.hxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/cm_memory.hxx b/Source/cm_memory.hxx
new file mode 100644
index 0000000..9f5e678
--- /dev/null
+++ b/Source/cm_memory.hxx
@@ -0,0 +1,31 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_memory_hxx
+#define cm_memory_hxx
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <memory> // IWYU pragma: export
+#if !defined(CMake_HAVE_CXX_MAKE_UNIQUE)
+# include <utility>
+#endif
+
+namespace cm {
+
+#if defined(CMake_HAVE_CXX_MAKE_UNIQUE)
+
+using std::make_unique;
+
+#else
+
+template <typename T, typename... Args>
+std::unique_ptr<T> make_unique(Args&&... args)
+{
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+#endif
+
+} // namespace cm
+
+#endif