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

Add trim view #1137

Merged
merged 12 commits into from
May 6, 2019
Merged

Add trim view #1137

merged 12 commits into from
May 6, 2019

Conversation

JohelEGP
Copy link
Contributor

I hope this is within scope. I thought I'd try getting this in so that it's available for the broader public rather than stuffing it in a library of mine. I'm looking forward to the review comments.

The current implementation is simple thanks to the bidirectional range requirement. Looking at #1112, it should be possible to do with a forward range. But I believe it'd be simpler to add a complementing drop_last_while and implement view::trim in terms of it and drop_while. This possibility makes me wonder if this is okay as is.

Copy link
Owner

@ericniebler ericniebler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have certainly done your homework here. Nice work. Just a few small changes. I'm not convinced this can be implemented for non-Bidirectional ranges.

include/range/v3/view/trim.hpp Show resolved Hide resolved
include/range/v3/view/trim.hpp Outdated Show resolved Hide resolved
include/range/v3/view/trim.hpp Show resolved Hide resolved
include/range/v3/view/trim.hpp Outdated Show resolved Hide resolved
include/range/v3/view/trim.hpp Outdated Show resolved Hide resolved
include/range/v3/view/trim.hpp Outdated Show resolved Hide resolved
include/range/v3/view/trim.hpp Outdated Show resolved Hide resolved
@JohelEGP
Copy link
Contributor Author

The latter part of d28764f's message shouldn't matter as the range concepts assign no semantics at all to default initialization.

@JohelEGP
Copy link
Contributor Author

I guess default-initialized views are to be treated as the moved-from state (like being unable to get their begin/end). I have reverted the attempt to assert whether pred_ was not in its default-initialized state.

@JohelEGP
Copy link
Contributor Author

Is it alright to mark find_if_not as constexpr /*c++14*/ so that trim_view can be constexpr too? I thought that you were holding back the algorithms from being constexpr since their standard version weren't, but I noticed that equal is constexpr.

@ericniebler
Copy link
Owner

ericniebler commented Apr 30, 2019

Is it alright to mark find_if_not as constexpr /*c++14*/ so that trim_view can be constexpr too? I thought that you were holding back the algorithms from being constexpr since their standard version weren't, but I noticed that equal is constexpr.

Fine by me.

@ericniebler ericniebler merged commit fe1bc9d into ericniebler:v1.0-beta May 6, 2019
@JohelEGP JohelEGP deleted the trim_view branch May 6, 2019 22:22
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