mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +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
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;
|
||||
};
|
||||
|
||||
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