-
Notifications
You must be signed in to change notification settings - Fork 96
Add transform_iterator #1836
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
base: develop
Are you sure you want to change the base?
Add transform_iterator #1836
Conversation
360872b
to
32068ed
Compare
auto test_iter = gko::detail::make_transform_iterator<TypeParam*>( | ||
nullptr, [](TypeParam v) { return v; }); | ||
|
||
ASSERT_NO_THROW((void)std::find(test_iter, test_iter, TypeParam{})); |
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.
does it check anything? std::find
does not do anything because first and end are the same.
also what is (void)
for?
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.
No, this is just a copy of the same test for permute_iterator. I needed to use a read-only operation, so find was the first thing that came to mind. The (void) is there to silence the [[nodiscard]]
warning.
32068ed
to
34f6a8c
Compare
34f6a8c
to
a94c5a8
Compare
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.
LGTM from the implementation, but I am not familiar with the iterator implementation.
If someone can review it to check whether it match the std iterator requirement or you can give the reference. I only check the iterator_traits and the random access iterator requirement.
I assume it will just give a compilation error when the Iterator is not random accessable because the following member functions uses the iterator as random access iterator.
TYPED_TEST(TransformIterator, IncreasingIterator) | ||
{ | ||
std::vector<TypeParam> vec{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | ||
auto transform = double_transform{}; |
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.
The following two tests do not check the value after transformation, so I think use scale_transofrm
should be good enough
This adds a transform_iterator that can be used with standard library algorithms and other functions like the ones from #1820