Skip to content
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

refactor: make CService and CNetAddr constexpr (when in cpp20) #5600

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

PastaPastaPasta
Copy link
Member

@PastaPastaPasta PastaPastaPasta commented Oct 4, 2023

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.

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

Copy link

This pull request has conflicts, please rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant