-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Finish P0768R1 by adding Spaceship CPOs #1370
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
Conversation
miscco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, I had a tiny question about the include chain and another one regarding readability
|
@miscco, @CaseyCarter - I've addressed your feedback with:
I also added a couple of additional changes:
|
Co-authored-by: Casey Carter <cartec69@gmail.com>
Explicitly convert the (potentially user-defined) result of ADL meow_order to meow_ordering, before converting it to the final type.
| {10, bit_cast<float>(0xFFC00000u)}, // negative quiet NaN, no payload bits | ||
| {20, -numeric_limits<float>::infinity()}, // negative infinity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need test coverage for signaling NaNs?
Note that it could be currently impossible to generate a float signaling NaN on the MSVC compiler at compile time. It emits a quiet NaN for bit_cast<float>(0xFF800001u) or numeric_limits<float>::signaling_NaN().
Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, yes, this would test signaling NaNs - but as you noted, the compiler bugs make it difficult. I think we can live without test coverage for them, given that the code is clearly written to handle them uniformly (the main question is whether I got the "infinity plus one" logic correct, but I think that can be verified by inspecting the code).
All this header does is include `stdint.h` and provide typedefs.
Resolves #64 by implementing WG21-N4861's spaceship customization point objects specified in [cmp.alg].
Note that this is targeted at
master, as it doesn't directly interact with #62 which is being developed infeature/spaceship.<charconv>_Floating_type_traitsinto a central header,<type_traits>. It was the only thing using<float.h>here (forFLT_MANT_DIGetc.).<type_traits><cstdint>needed by_Floating_type_traits. This is a very small header, "core" compatible, and it's actually surprising that<type_traits>wasn't already dragging it in._Floating_type_traitshere. It's functionally unchanged, except that I've eliminated the<float.h>dependency by directly writing out the literal values. I believe that this makes the masks easier to understand, and I've retained the original computations as comments._Floating_type_traits<long double>, needed now but not by<charconv>.<charconv>includes<xutility>includes<utility>includes<type_traits>.<compare>includes (in concepts mode)<concepts>includes<type_traits>.<xutility>std::ranges::_Choice_tandstd::_Implicitly_convertible_tointo a central header,<concepts>. Both will remain guarded by__cpp_lib_concepts._Choice_tis additionally being lifted out tostd.<xutility>includes<utility>includes (in concepts mode)<concepts>.<compare><bit>forbit_cast. It's a "core" header, although it does drag in<limits>._Bit_castin<xutility>up to<type_traits>, except that it wantsmemcpyfor__CUDACC__and<type_traits>doesn't include<cstring>. Maybe we could write a raw byte-copying loop?_Choice/_Strategysystem.<yvals_core.h>__cpp_lib_concepts. Note that__cpp_lib_three_way_comparisonis being defined to the lower value201711Lfor P0768R1; it will be increased to the larger value201907Lfor P1614R2.tests/libcxx/expected_results.txttests/libcxx/skipped_tests.txttests/std/tests/VSO_0157762_feature_test_macros/test.cpptests/std/test.lsttests/std/tests/P0768R1_spaceship_cpos/env.lsttests/std/tests/P0768R1_spaceship_cpos/test.cppconcepts_matrix, but we don't need the strict concepts matrix - I was able to resolve all of the issues with/permissivemode).test_floating(), I've devised a system to test every possible "interesting" pair of floating-point values.