Skip to content

src: simplify is_callable by making it a concept #58169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tniessen
Copy link
Member

@tniessen tniessen commented May 4, 2025

Using a C++20 concept here makes is_callable much simpler than relying on SFINAE. It is equivalent for function types, std::function, lambdas, and classes with operator(), regardless of argument or return types.

@tniessen tniessen added the c++ Issues and PRs that require attention from people who are familiar with C++. label May 4, 2025
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label May 4, 2025
Using a C++20 `concept` here makes `is_callable` much simpler
than relying on SFINAE. It is equivalent for function types,
`std::function`, lambdas, and classes with `operator()`,
regardless of argument or return types.
@tniessen tniessen force-pushed the simplify-is-callable branch from cf9d612 to 33a9784 Compare May 4, 2025 17:47
@@ -111,7 +111,7 @@ struct CallLibuvFunction<ReqT, void(*)(ReqT*, Args...)> {
template <typename ReqT, typename T>
struct MakeLibuvRequestCallback {
static T For(ReqWrap<ReqT>* req_wrap, T v) {
static_assert(!is_callable<T>::value,
static_assert(!is_callable<T>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change type name T to is_callable T and remove this static_assertion.

Copy link

codecov bot commented May 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.14%. Comparing base (5fb879c) to head (33a9784).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #58169   +/-   ##
=======================================
  Coverage   90.13%   90.14%           
=======================================
  Files         630      630           
  Lines      186611   186611           
  Branches    36631    36634    +3     
=======================================
+ Hits       168204   168220   +16     
+ Misses      11192    11183    -9     
+ Partials     7215     7208    -7     
Files with missing lines Coverage Δ
src/req_wrap-inl.h 92.72% <ø> (ø)
src/util.h 91.22% <ø> (ø)

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants