// // MakeUnique.h // // Library: Foundation // Package: Core // Module: MakeUnique // // Definition of the MakeUnique template class. This is essentially std::make_unique // for pre-C++14 compilers. // // Code adapted for naming convention from https://isocpp.org/files/papers/N3656.txt // // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // and Contributors. // // SPDX-License-Identifier: BSL-1.0 // #ifndef Foundation_MakeUnique_INCLUDED #define Foundation_MakeUnique_INCLUDED #include "Poco/Foundation.h" #include #include #include #include namespace Poco { template struct UniqueIf { typedef std::unique_ptr SingleObject; }; template struct UniqueIf { typedef std::unique_ptr UnknownBound; }; template struct UniqueIf { typedef void KnownBound; }; template typename UniqueIf::SingleObject makeUnique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } template typename UniqueIf::UnknownBound makeUnique(size_t n) { typedef typename std::remove_extent::type U; return std::unique_ptr(new U[n]()); } template typename UniqueIf::KnownBound makeUnique(Args&&...) = delete; } // namespace Poco #endif // Foundation_MakeUnique_INCLUDED