-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement ranges::ref_view #1132
Conversation
Now i remember, it was actually not a squirrel but some three headed beast that let the poison pill fail to compile |
Found the bug, it was sitting in front of the monitor... |
|
@AdamBucior thanks, I was confused by the range adaptor sentence that everything lives in std::ranges::views |
Why? |
because then I would not need to go with |
I figured this out during my detailed review; see my comments inline which boil down to "write a concept to determine if |
FYI I am out until Monday, so if this is blocking you feel free to adopt whatever you need. I will pick up the remnants later |
constexpr ref_view(_OtherRng&& _Other) noexcept( | ||
noexcept(static_cast<_Rng&>(_STD forward<_OtherRng>(_Other)))) // strengthened | ||
requires convertible_to<_OtherRng, _Rng&> && requires { | ||
_Rvalue_poison(static_cast<_OtherRng&&>(_Other)); |
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.
I observe that the requires
says static_cast<_OtherRng&&>(_Other)
instead of _STD forward<_OtherRng>(_Other)
. I am not sure if the variation is intentional. No change requested.
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.
This is intentional: I try to avoid instantiating and/or specializing templates during overload resolution for throughput. In this case, that means static_cast<T&&>(t)
in the constraints instead of std::forward<T>(t)
that is used in noexcept
-specifiers and function template bodies which are instantiated after overload resolution. There's an argument to be made that the difference is anomalous enough to offset any readability benefit.
Thanks for implementing these ranges features so quickly! It might be a world record, we should call a ref over to view the instant replay. 🥇 |
This implements
ranges::ref_view
which is a precursor for most other range adaptors.NOTE: I need to come up with a reasonably simple test for the converting onstructor from a different range.
@CaseyCarter: Should we add
empty
totest::range
?