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

Feature/ranges part2 #8

Merged
merged 19 commits into from
Nov 8, 2023
Merged

Feature/ranges part2 #8

merged 19 commits into from
Nov 8, 2023

Conversation

whaeck
Copy link
Member

@whaeck whaeck commented Nov 6, 2023

Adding a TransformView

Copy link

@timburculosis timburculosis left a comment

Choose a reason for hiding this comment

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

Looks good! One behavioral question to consider, and maybe some tests are missing?


/**
* @brief Make an IteratorView based on a container and a transformation
* To avoid copying containers like vectors, maps, etc. into the TransportView,

Choose a reason for hiding this comment

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

Suggested change
* To avoid copying containers like vectors, maps, etc. into the TransportView,
* To avoid copying containers like vectors, maps, etc. into the TransformView,

Choose a reason for hiding this comment

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

@whaeck don't forget to fix this typo

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed it, it's no longer there. But I'll check ...

* @param[in] range the range to be transformed
* @param[in] transform the transformation to be applied to the range
*/
constexpr TransformView( Range range, Transform transform ) :

Choose a reason for hiding this comment

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

Looked it up in cppref - I didn't know transform_view copied the data, I would have assumed it made a view of the data first. Is there any reason to not store an IteratorView of the range instead of copying the range itself? When I see a 'make_foo" function I expect it to basically forward along the args to the ctor of Foo. But in this case TransformView's ctor has different behavior than make_transform_view.

Copy link
Member Author

@whaeck whaeck Nov 7, 2023

Choose a reason for hiding this comment

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

I was as surprised as you were when I saw that here: https://github.com/CaseyCarter/cmcstl2. ranges v3 actually does create a subrange (i.e. IteratorView) for the transport_view. I was actually debating on putting an IteratorView into the TransportView to avoid copies.

Choose a reason for hiding this comment

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

Are Iterator's methods tested somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are not. I forgot :-)

I'll add these.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are now :-)

@whaeck whaeck requested a review from timburculosis November 7, 2023 17:00
Copy link

@timburculosis timburculosis left a comment

Choose a reason for hiding this comment

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

Copy-paste errors should be fixed. Thanks for the changes!


static_assert(
concepts::IsRandomAccessIterator< Iterator >::value == true,
"the at() method can only be made available for random access iterators" );

Choose a reason for hiding this comment

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

Copy-paste errors on all of these static-asserts - they all reference the 'at()' method instead of the appropriate method.

Also, I may not have realized that doing this instead of SFINAE would require static asserts on all of the methods. Sorry about that.

Choose a reason for hiding this comment

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

Ah, I see you fixed it in the next MR

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, I fixed it later.

I don;t mind all those static asserts. It;s more readable compared to sfinae

@timburculosis timburculosis self-assigned this Nov 8, 2023
@timburculosis timburculosis self-requested a review November 8, 2023 19:01
timburculosis
timburculosis previously approved these changes Nov 8, 2023
Base automatically changed from feature/ranges-part1 to develop November 8, 2023 19:37
@whaeck whaeck dismissed timburculosis’s stale review November 8, 2023 19:37

The base branch was changed.

@whaeck whaeck merged commit 4873558 into develop Nov 8, 2023
8 checks passed
@whaeck whaeck deleted the feature/ranges-part2 branch November 8, 2023 19:40
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