aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYizhe <yizhe@pku.edu.cn>2021-03-17 01:54:44 +0000
committerYizhePKU <yizhe@pku.edu.cn>2021-04-02 17:10:41 +0000
commitd4f8f92142340a7e6b931bd5235486c64b7d8e22 (patch)
treed0a0fd6051d97b60b7e0169b08a58194d9a71210
parent099fcbd107ad6139de2c387c62327d0d189a5261 (diff)
downloadgcc-d4f8f92142340a7e6b931bd5235486c64b7d8e22.zip
gcc-d4f8f92142340a7e6b931bd5235486c64b7d8e22.tar.gz
gcc-d4f8f92142340a7e6b931bd5235486c64b7d8e22.tar.bz2
Backport std::unique_ptr
A handy helper function. I copied the code from Effective Modern C++. The code is too short to be considered "legally significant", so copyright should not be an issue. Also, GCC copyright notice is not needed on such small files as well.
-rw-r--r--gcc/rust/util/rust-make_unique.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/rust/util/rust-make_unique.h b/gcc/rust/util/rust-make_unique.h
new file mode 100644
index 0000000..0c4da2f
--- /dev/null
+++ b/gcc/rust/util/rust-make_unique.h
@@ -0,0 +1,17 @@
+#ifndef RUST_MAKE_UNIQUE_H
+#define RUST_MAKE_UNIQUE_H
+
+#include <memory>
+
+namespace Rust {
+
+template <typename T, typename... Ts>
+std::unique_ptr<T>
+make_unique (Ts &&...params)
+{
+ return std::unique_ptr<T> (new T (std::forward<Ts> (params)...));
+}
+
+} // namespace Rust
+
+#endif // RUST_MAKE_UNIQUE_H