LibJS: Allow JS::create_heap_function to accept a lambda
This helps us avoid from needing to construct a Function<T> when invoking `create_heap_function` with a lambda. Co-Authored-By: Ali Mohammad Pur <mpfard@serenityos.org>
This commit is contained in:
parent
c6319d68c3
commit
e118430648
Notes:
sideshowbarker
2024-07-17 05:03:11 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/e118430648 Pull-request: https://github.com/SerenityOS/serenity/pull/22946 Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 3 additions and 3 deletions
|
@ -41,10 +41,10 @@ private:
|
||||||
Function<T> m_function;
|
Function<T> m_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename Callable, typename T = EquivalentFunctionType<Callable>>
|
||||||
static NonnullGCPtr<HeapFunction<T>> create_heap_function(Heap& heap, Function<T> function)
|
static NonnullGCPtr<HeapFunction<T>> create_heap_function(Heap& heap, Callable&& function)
|
||||||
{
|
{
|
||||||
return HeapFunction<T>::create(heap, move(function));
|
return HeapFunction<T>::create(heap, Function<T> { forward<Callable>(function) });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue