mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-04 15:09:40 +00:00
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
|
@ -41,10 +41,10 @@ private:
|
|||
Function<T> m_function;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
static NonnullGCPtr<HeapFunction<T>> create_heap_function(Heap& heap, Function<T> function)
|
||||
template<typename Callable, typename T = EquivalentFunctionType<Callable>>
|
||||
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…
Reference in a new issue