Skip to content

src: use ranges library (C++20) to simplify code #57975

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 6 commits into
base: main
Choose a base branch
from

Conversation

lemire
Copy link
Member

@lemire lemire commented Apr 22, 2025

This PR uses C++20 ranges to slightly simplify a piece of code. To be honest, the real motivation of this PR is to introduce ranges and test whether the platforms play nice with ranges. If so, then this could be generalized in the code base.

@lemire lemire requested a review from codebytere April 22, 2025 15:36
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. config Issues or PRs related to the config subsystem needs-ci PRs that need a full CI run. labels Apr 22, 2025
@lemire lemire requested a review from anonrig April 22, 2025 15:38
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 22, 2025
@github-actions github-actions bot added request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Apr 22, 2025
Copy link
Contributor

Failed to start CI
   ⚠  Commits were pushed since the last approving review:
   ⚠  - src: use ranges library (C++20) to simplify code
   ⚠  - breaking long lines
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/14598958420

@richardlau
Copy link
Member

Looks like a missing #include <algorithm>:
https://github.com/nodejs/node/actions/runs/14598914061/job/40951831889?pr=57975#step:6:6555

In file included from ../src/node_options.cc:2:
../src/node_options-inl.h:398:20: error: no member named 'for_each' in namespace 'std::ranges'
  398 |       std::ranges::for_each(
      |       ~~~~~~~~~~~~~^

@aduh95 aduh95 added dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. labels Apr 22, 2025
@lemire
Copy link
Member Author

lemire commented Apr 22, 2025

@richardlau good catch.

@anonrig
Copy link
Member

anonrig commented Apr 22, 2025

@lemire It seems it doesn't build on any platforms at all

@lemire
Copy link
Member Author

lemire commented Apr 23, 2025

@anonrig

It seems it doesn't build on any platforms at all

It should build. Let us find out what the issue is.

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.27%. Comparing base (367d593) to head (8289bba).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/node_options-inl.h 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57975      +/-   ##
==========================================
- Coverage   90.28%   90.27%   -0.02%     
==========================================
  Files         630      630              
  Lines      186169   186169              
  Branches    36479    36479              
==========================================
- Hits       168082   168062      -20     
- Misses      10971    10974       +3     
- Partials     7116     7133      +17     
Files with missing lines Coverage Δ
src/node_options-inl.h 81.30% <88.88%> (+0.48%) ⬆️

... and 33 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.

@lemire
Copy link
Member Author

lemire commented Apr 24, 2025

@anonrig I am unhappy with the formatting of the code, but it works now !!!!!!!!!

@anonrig anonrig added request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Apr 24, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 24, 2025
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

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++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. config Issues or PRs related to the config subsystem dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. needs-ci PRs that need a full CI run. request-ci-failed An error occurred while starting CI via request-ci label, and manual interventon is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants