Skip to content

Commit 8617989

Browse files
Add MakeUnique (substitute for C++14 std::make_unique)
From @ryanofsky:s #10973. Thanks!
1 parent d223bc9 commit 8617989

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,4 +326,11 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
326326

327327
std::string CopyrightHolders(const std::string& strPrefix);
328328

329+
//! Substitute for C++14 std::make_unique.
330+
template <typename T, typename... Args>
331+
std::unique_ptr<T> MakeUnique(Args&&... args)
332+
{
333+
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
334+
}
335+
329336
#endif // BITCOIN_UTIL_H

0 commit comments

Comments
 (0)