Skip to content

feat: enforce callback signatures with C++ Concepts (#1746) - #1762

Open
dave-365 wants to merge 1 commit into
nodejs:mainfrom
dave-365:feat/cpp20-concepts
Open

dave-365 wants to merge 1 commit into
nodejs:mainfrom
dave-365:feat/cpp20-concepts

Conversation

@dave-365

@dave-365 dave-365 commented Nov 5, 2026

Copy link
Copy Markdown

Fixes #1746

Overview

When passing mismatched callback or finalizer signatures to methods such as Function::New, PropertyDescriptor::Accessor, Object::AddFinalizer, or ThreadSafeFunction::New, unconstrained templates would fail deep inside internal wrappers (such as details::CallbackData in napi-inl.h). This produced lengthy, cryptic template instantiation errors that were difficult to decipher.

This PR adopts C++20 Concepts () to enforce callable and finalizer signatures at the call site at compile time, providing immediate and readable compiler diagnostics while maintaining 100% backward compatibility for pre-C++20 builds.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Need Triage

Development

Successfully merging this pull request may close these issues.

Enforce callback signatures with C++ Concepts

1 participant