-
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::starts_with and ranges::ends_with #1997
Implement ranges::starts_with and ranges::ends_with #1997
Conversation
Note I did not yet add the feature macro, what is the right value? |
@CaseyCarter it seems that mismatch was one of the first ranges algorithms so it has some oddities. I think we should move the unwrapping out of the helper functions and into the main function calls as in the other algorithms. If so should that happen in this PR? |
This comment has been minimized.
This comment has been minimized.
03e4d37
to
75b4380
Compare
I believe we should clean up |
@CaseyCarter, do you have some insights on what to do if the needle range is infinite? Should that return true or false? |
Co-authored-by: Adam Bucior <[email protected]>
@AdamBucior I added the requested optimizations |
You mean something other than
I'm working on #1684 now.
I vaguely recall this being useful for some reason. Feel free to take a stab at it, and if something goes pearshaped we can add an explanatory comment so future us doesn't try to fix this again.
This PR won't be ported to 16.11, so I wouldn't complain about unrelated cleanup - your call.
Agree.
It should return |
This comment has been minimized.
This comment has been minimized.
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 PR was previously passing checks, but is now failing after the MegaMerge, with apparently-real failures with both MSVC and Clang in different tests.
…ual_count` performs no bounds checking
@miscco FYI: I thought we could do better in |
} | ||
} | ||
|
||
// distance(_First1, _Mid1) == distance(_First2, _Last2) == _Count2 |
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.
Chained comparisons don't really work this way in C++ - shout if people think this comment is unclear.
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 noticed it but decided not to meow. 🐱
Thanks for going the extra mile @CaseyCarter Looks good to me |
I'm mirroring this to an MSVC-internal PR; please notify me if any further changes are pushed. |
Thanks for implementing these new ranges algorithms! 🚀 😻 🛠️ |
Co-authored-by: Adam Bucior <[email protected]> Co-authored-by: Stephan T. Lavavej <[email protected]> Co-authored-by: Casey Carter <[email protected]>
This implements P1659 from @cjdb
I really wish we had something like an
constexpr if
-expressionFixes #1975.