Alloc: make() now takes variadic arguments, to forward to the constructor

This commit is contained in:
apio 2022-12-06 17:36:20 +01:00
parent eef74e2897
commit dd29156c85
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -3,9 +3,9 @@
#include <luna/Result.h> #include <luna/Result.h>
#include <luna/SafeArithmetic.h> #include <luna/SafeArithmetic.h>
template <typename T> Result<T*> make() template <typename T, class... Args> Result<T*> make(Args... args)
{ {
T* const result = new T; T* const result = new T(args...);
if (!result) return err(ENOMEM); if (!result) return err(ENOMEM);
return result; return result;
} }