Skip to content

Add ConstNodeRef to enforce const correctness #267

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

Merged
merged 12 commits into from
Aug 14, 2022
Merged

Add ConstNodeRef to enforce const correctness #267

merged 12 commits into from
Aug 14, 2022

Conversation

biojppm
Copy link
Owner

@biojppm biojppm commented Jun 27, 2022

fixes #266

@biojppm
Copy link
Owner Author

biojppm commented Jun 27, 2022

@BenjaminNavarro FYI. This is still a work-in-progress, but I'm satisfied with the mechanics and it already passes all the existing tests, so if you want you can take a look.

I'm still going to try to minimize code duplication across ConstNodeRef and NodeRef, and I have to add more documentation in the quickstart and changelog.

@BenjaminNavarro
Copy link

Nice, didn't thought this was going to be taken care of so quickly.

To minimize code duplication I guess you could have either:

  1. NodeRef inherits from ConstNodeRef and adds the state modifying functions
  2. Have two separate classes, e.g NodeReadOperations and NodeWriteOperations and have ConstNodeRef inherit from the first and NodeRef from both.

I think 2. is what is used in Eigen, but that might require some CRTP to pull off. 1. is easy but some people don't like to use inheritance for these things;

@codecov
Copy link

codecov bot commented Jun 27, 2022

Codecov Report

Merging #267 (06c955e) into master (bddb04b) will increase coverage by 0.04%.
The diff coverage is 98.73%.

❗ Current head 06c955e differs from pull request most recent head 9097d26. Consider uploading reports for the commit 9097d26 to get more accurate results

@@            Coverage Diff             @@
##           master     #267      +/-   ##
==========================================
+ Coverage   97.11%   97.16%   +0.04%     
==========================================
  Files          77       78       +1     
  Lines       17147    17757     +610     
==========================================
+ Hits        16653    17253     +600     
- Misses        494      504      +10     
Impacted Files Coverage Δ
src/c4/yml/detail/print.hpp 96.00% <0.00%> (ø)
src/c4/yml/node.cpp 100.00% <ø> (ø)
src/c4/yml/parse.hpp 100.00% <ø> (ø)
src/c4/yml/std/vector.hpp 100.00% <ø> (ø)
test/test_case.hpp 44.91% <0.00%> (-1.58%) ⬇️
test/test_suite.cpp 93.78% <ø> (ø)
test/test_case.cpp 87.18% <69.23%> (ø)
src/c4/yml/tree.cpp 94.52% <83.33%> (-0.20%) ⬇️
src/c4/yml/node.hpp 97.31% <98.10%> (-0.23%) ⬇️
test/test_noderef.cpp 99.30% <99.30%> (ø)
... and 15 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@biojppm biojppm force-pushed the fix/constnode branch 2 times, most recently from 54532ca to 2a849af Compare June 27, 2022 22:25
@biojppm biojppm changed the title [wip] Add ConstNodeRef to enforce const correctness Jul 5, 2022
@biojppm biojppm merged commit 8123e33 into master Aug 14, 2022
@biojppm biojppm deleted the fix/constnode branch August 14, 2022 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

const on return types
2 participants