diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2017-08-15 06:59:08 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2017-11-09 16:53:34 +0100 |
commit | 86179897e230d8e5244fa7690ae1bc84b7958b9b (patch) | |
tree | 586dd9551d2b5bfb01e25ccdd6a33c1e6b389e26 /src | |
parent | d223bc940a16712f221f634047408e8771dff26c (diff) |
Add MakeUnique (substitute for C++14 std::make_unique)
From @ryanofsky:s #10973. Thanks!
Diffstat (limited to 'src')
-rw-r--r-- | src/util.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h index 480a80c0a3..43acd93ee2 100644 --- a/src/util.h +++ b/src/util.h @@ -326,4 +326,11 @@ template <typename Callable> void TraceThread(const char* name, Callable func) std::string CopyrightHolders(const std::string& strPrefix); +//! Substitute for C++14 std::make_unique. +template <typename T, typename... Args> +std::unique_ptr<T> MakeUnique(Args&&... args) +{ + return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); +} + #endif // BITCOIN_UTIL_H |