diff options
author | Desour <ds.desour@proton.me> | 2023-04-10 18:42:59 +0200 |
---|---|---|
committer | DS <ds.desour@proton.me> | 2023-04-11 20:06:15 +0200 |
commit | ceec560779e43813dd1c212557160f4dee4910ed (patch) | |
tree | 566feee524a41bd4cf9280bf626cd24d5c6a69cc /src | |
parent | d39a07efea5b80f0f2ce31f05751f7c19dd12163 (diff) | |
download | minetest-ceec560779e43813dd1c212557160f4dee4910ed.tar.xz |
Add make_irr
Diffstat (limited to 'src')
-rw-r--r-- | src/irr_ptr.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/irr_ptr.h b/src/irr_ptr.h index 43add00da..f1caf9c7d 100644 --- a/src/irr_ptr.h +++ b/src/irr_ptr.h @@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include <type_traits> +#include <utility> #include "irrlichttypes.h" #include "IReferenceCounted.h" @@ -197,4 +198,12 @@ bool operator!=(const ReferenceCounted *a, const irr_ptr<ReferenceCounted> &b) n return a != b.get(); } +/** Same as std::make_unique<T>, but for irr_ptr. + */ +template <class T, class... Args> +irr_ptr<T> make_irr(Args&&... args) +{ + return irr_ptr<T>(new T(std::forward<Args>(args)...)); +} + // clang-format on |