// -*-c++-*- // vim: set ft=cpp: /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #ifndef cm_memory #define cm_memory #include // IWYU pragma: export #if !defined(CMake_HAVE_CXX_MAKE_UNIQUE) # include # include # include #endif namespace cm { #if defined(CMake_HAVE_CXX_MAKE_UNIQUE) using std::make_unique; #else namespace internals { template struct make_unique_if { using single = std::unique_ptr; }; template struct make_unique_if { using unbound_array = std::unique_ptr; }; template struct make_unique_if { using bound_array = void; }; } template typename internals::make_unique_if::single make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } template typename internals::make_unique_if::unbound_array make_unique(std::size_t n) { using E = typename std::remove_extent::type; return std::unique_ptr(new E[n]()); } template typename internals::make_unique_if::bound_array make_unique(Args&&...) = delete; #endif } // namespace cm #endif