mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:07:35 +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
1 changed files with 3 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue