diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2019-07-02 09:08:04 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2019-07-14 13:37:30 (GMT) |
commit | d9b2c7dae242868f13fc366773fb09448da26e8d (patch) | |
tree | 12e97152327bdff419861deded5b2f7d6a0961be /Source/cm_memory.hxx | |
parent | 81389a5e8f14a09d26a8efb22fd12063168caba6 (diff) | |
download | CMake-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.hxx | 31 |
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 |