[object] Forward hb_object_create() arguments to constructor

This commit is contained in:
Behdad Esfahbod 2022-08-18 16:15:54 -06:00
parent df040de9b4
commit 2eda2ab3bb
1 changed files with 3 additions and 3 deletions

View File

@ -214,15 +214,15 @@ static inline void hb_object_trace (const Type *obj, const char *function)
obj ? obj->header.ref_count.get_relaxed () : 0);
}
template <typename Type>
static inline Type *hb_object_create ()
template <typename Type, typename ...Ts>
static inline Type *hb_object_create (Ts... ds)
{
Type *obj = (Type *) hb_calloc (1, sizeof (Type));
if (unlikely (!obj))
return obj;
new (obj) Type;
new (obj) Type (std::forward<Ts> (ds)...);
hb_object_init (obj);
hb_object_trace (obj, HB_FUNC);