Skip to content

feat: adopt C++20 defaulted comparisons and spaceship operator - #1761

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

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

Conversation

@dave-365

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

Copy link
Copy Markdown

Fixes #1748

Summary of Changes:

  • Leverage C++20 defaulted comparisons (operator== and <=>) when compiling under C++20 or later.
  • Remove redundant hand-written operator!= implementations in C++20 mode for Value, Reference<T>, Object::iterator, Object::const_iterator, and Maybe<T> as the compiler synthesizes them automatically from operator==.
  • Adopt = default equality and three-way comparison (<=>) for BasicEnv.
  • Add spaceship operator (<=>) for Maybe<T> using std::compare_three_way_result_t<T> to support relational ordering when T supports comparison.
  • Preserve full backward compatibility for C++14/C++17 compilers under #if !defined(NAPI_HAS_CPP20_COMPARISONS).
  • Add binding_cpp20 target and unit tests covering C++20 comparison behavior.

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.

Adopt C++20 defaulted comparisons (operator== / <=>)

1 participant