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

constexpr signbit #793

Merged
merged 3 commits into from
Jul 2, 2022
Merged

constexpr signbit #793

merged 3 commits into from
Jul 2, 2022

Conversation

mborland
Copy link
Member

@mborland mborland commented Jul 1, 2022

No description provided.

@mborland
Copy link
Member Author

mborland commented Jul 2, 2022

@NAThompson This is good for review. I deviate slightly from the C++ standard (same as copysign) in that using UB to find the sign of a NAN is not allowable in constexpr contexts.

@jzmaddock
Copy link
Collaborator

That all looks fine to me, I wonder how useful it will be if we can't detect signed zero though?

Hmm... just a thought, we can detect signed infinities right? So how about checking the sign of 1/x when x is zero? Might need to verify that the type has infinities first, and I worry it might trigger compiler traps, but would make the facility more generally useful.

@mborland
Copy link
Member Author

mborland commented Jul 2, 2022

That all looks fine to me, I wonder how useful it will be if we can't detect signed zero though?

Hmm... just a thought, we can detect signed infinities right? So how about checking the sign of 1/x when x is zero? Might need to verify that the type has infinities first, and I worry it might trigger compiler traps, but would make the facility more generally useful.

We can detect signed infinities, but division by 0 is not allowed in constexpr contexts because it is UB.

@jzmaddock
Copy link
Collaborator

We can detect signed infinities, but division by 0 is not allowed in constexpr contexts because it is UB.

Oh :( I knew there had to be a catch somewhere. Oh well, never mind, carry on as you were ;)

@mborland mborland merged commit 1cbf7e2 into boostorg:develop Jul 2, 2022
@mborland mborland deleted the signbit branch July 2, 2022 18:47
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.

2 participants