refactor: make CService and CNetAddr constexpr (when in cpp20) #5600
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
Underlying motivation is making a lot of other potential stuff constexpr; CService and CNetAddr is used by quite a few things, and making it fully stack allocated (and constexpr) can be quite valuable I think
Also, I think I would like to PR this to bitcoin, so please provide review as if you were a bitcoin core developer and had very high standards :D
What was done?
In c++20, CService and CNetAddr will always be constexpr, in c++17 some of it's constructors are constexpr; removes use of prevector, so we know that CService and CNetAddr will be fully on the stack in both 17 and 20; however certain constructors that need std::copy or reinterpret_cast cannot be c++17 constexpr
How Has This Been Tested?
Building with c++17 and c++20 and ensuring that I was able to connect to ipv4 v6 and tor nodes
Breaking Changes
Should be none; this is mostly for conceptual review (and running it); I'm not positive this is completely bug free; I want to test a bit more.
Checklist:
Go over all the following points, and put an
x
in all the boxes that apply.