Make New<>() a variadic function template and forward any arguments to
the constructor. std::forward<>() is inlined to avoid including
<utility>.
Differential Revision: https://reviews.llvm.org/D107147
void *Alloc(uptr sz);
void FreeImpl(void *p);
-template <typename T>
-T *New() {
- return new (Alloc(sizeof(T))) T();
+template <typename T, typename... Args>
+T *New(Args &&...args) {
+ return new (Alloc(sizeof(T))) T(static_cast<Args &&>(args)...);
}
template <typename T>
CHECK("unable to mprotect" && 0);
}
}
- return new (Alloc(sizeof(ThreadContext))) ThreadContext(tid);
+ return New<ThreadContext>(tid);
}
#if !SANITIZER_GO