diff options
author | Yizhe <yizhe@pku.edu.cn> | 2021-03-17 01:54:44 +0000 |
---|---|---|
committer | YizhePKU <yizhe@pku.edu.cn> | 2021-04-02 17:10:41 +0000 |
commit | d4f8f92142340a7e6b931bd5235486c64b7d8e22 (patch) | |
tree | d0a0fd6051d97b60b7e0169b08a58194d9a71210 /gcc | |
parent | 099fcbd107ad6139de2c387c62327d0d189a5261 (diff) | |
download | gcc-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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/util/rust-make_unique.h | 17 |
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 |