]> git.saurik.com Git - apple/system_cmds.git/blobdiff - CPPUtil/UtilMakeUnique.hpp
system_cmds-643.30.1.tar.gz
[apple/system_cmds.git] / CPPUtil / UtilMakeUnique.hpp
diff --git a/CPPUtil/UtilMakeUnique.hpp b/CPPUtil/UtilMakeUnique.hpp
new file mode 100644 (file)
index 0000000..0be557c
--- /dev/null
@@ -0,0 +1,23 @@
+//
+//  UtilMakeUnique.hpp
+//  CPPUtil
+//
+//  Created by James McIlree on 4/15/13.
+//  Copyright (c) 2013 Apple. All rights reserved.
+//
+
+#ifndef CPPUtil_UtilMakeUnique_hpp
+#define CPPUtil_UtilMakeUnique_hpp
+
+/* Not needed in C++14 or later */
+#if __cplusplus <= 201103
+
+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
+
+#endif