-
Notifications
You must be signed in to change notification settings - Fork 113
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
Removing reliance on copy assignment iterator for zip_iterator::operator+= #1437
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Dan Hoeflinger <[email protected]>
Signed-off-by: Dan Hoeflinger <[email protected]>
671b091
to
7348af7
Compare
These additions LGTM. Do we need a documentation update as well listing the newly supported operators in |
Yes, we can update the guide with this on the supported operations provided by the "unspecified type". |
Signed-off-by: Dan Hoeflinger <[email protected]>
@mmichel11 The operator support of the "unspecified type" is actually defined by the specification, so if we are updating the guide, we also need to look at updating the specification. Also according to the oneDPL specification: Prior to this PR, our implementation was not following the spec, because instead of using I propose we update both the specification and guide to add support by the "unspecified type" of the following operators: It seems that in practice we already support |
Signed-off-by: Dan Hoeflinger <[email protected]>
Signed-off-by: Dan Hoeflinger <[email protected]>
Signed-off-by: Dan Hoeflinger <[email protected]>
I looked through the implementations of the new operators and they seem good to me. Since in practice the Perhaps the line you found in the spec ("The arithmetic operators of zip_iterator update the source iterators of a zip_iterator instance as though the operation were applied to each of these iterators") implies that the "undefined type" has at least the same operators as |
@adamfidel Thanks for taking a look.
Its a good question... and I had a similar thought. The reason I think we should add it to the specification is because we depend on that functionality being there for the "unspecified type" by the combination of (1) using I'm not sure its necessarily required, because its unlikely that someone would mix part of this implementation of the oneDPL specification with another implementation of oneDPL.
The line I quote from the spec about One option I did consider was using a |
To summarize an offline conversation about this PR: Additionally, we have decided that it is unlikely we will fully remove the custom copy assignment operator of For now, I'm marking this as a draft pending discussions and improvements to the specification. It is likely preferable to improve the specification for custom iterator requirements, as opposed to adding operators to our "unspecified type". |
zip_iterator::operator+=
currently relies on the copy assignment operator of its zipped iterator elements.This PR shifts that to instead rely upon the same
operator+=
of the zipped iterator elements as described by the specification:"The arithmetic operators of zip_iterator update the source iterators of a zip_iterator instance as though the operation were applied to each of these iterators."
In order to maintain support for wrapping a
sycl_iterator
with azip_iterator
, this PR also adds the following operators tosycl_iterator
:++
,--
,++(int)
,--(int)
,+=
,-=
,>
,<=
,>=
. At least+=
is required to be able to usesycl_iterator
within azip_iterator
with theoperator+=
. It makes sense to add all of these operators together.The PR also augments the description of the "unspecified type" in the documentation to reflect its operator support. The intention would be to also adjust the oneDPL specification accordingly for this "unspecified type".
Additional context / motivation:
This change is important because we are considering changes in the future which may impact the copy-assignability of some
transform_iterators
.If we remove
transform_iterator
custom copy assignment operator in the future, it will rely on implicitly defined copy assignment (which will be deleted for c++17 lambdas). This means that if we make that future change, an iterator of typezip_iterator<transform_iterator<it,lambda>>
would result in a build error if itsoperator+=
was used due to this lack of copy assignment operator for thetransform_iterator<it,lambda>
. This PR removes that potential build error.