diff options
Diffstat (limited to 'gdbsupport/gdb_unique_ptr.h')
-rw-r--r-- | gdbsupport/gdb_unique_ptr.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h index a3ab624..8ff7cec 100644 --- a/gdbsupport/gdb_unique_ptr.h +++ b/gdbsupport/gdb_unique_ptr.h @@ -56,6 +56,19 @@ struct noop_deleter void operator() (T *ptr) const { } }; +/* Create simple std::unique_ptr<T> objects. */ + +template<typename T, typename... Arg> +std::unique_ptr<T> +make_unique (Arg &&...args) +{ +#if __cplusplus >= 201402L + return std::make_unique<T> (std::forward<Arg> (args)...); +#else + return std::unique_ptr<T> (new T (std::forward<Arg> (args)...)); +#endif /* __cplusplus < 201402L */ +} + } /* namespace gdb */ /* Dup STR and return a unique_xmalloc_ptr for the result. */ |