Prototype __tuple_for_each and __tuple_apply for zip_view#2613
Prototype __tuple_for_each and __tuple_apply for zip_view#2613kboyarinov wants to merge 218 commits intomainfrom
Conversation
…ew::iterator type
…d::apply doesnt work with oneDPL tuple
…d::apply doesnt work with oneDPL tuple
…de duplication" This reverts commit fc04caf.
…en zip_view::iterators
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
Co-authored-by: Konstantin Boyarinov <konstantin.boyarinov@intel.com>
|
To tell the truth, I could not notice advantages, it does more or less the same, plus renaming - |
For me, the main concern was that the usages of In this PR, no extra functions are passed to |
danhoeflinger
left a comment
There was a problem hiding this comment.
Sorry I ran out of time to look at this in depth.
I see.. But, bassically, the background here is quite general - knowledge about In any case, this is not an error or an issue. It’s not even about code style — it’s more about a coding approach, which can be subjective. |
Only one overload is close to
I agree that this does not affect correctness. However, in my opinion, it makes the already complex code harder to read, harder to understand, and, accordingly, harder to support. |
|
I think this PR does help make things a bit more clear, but there are some inconsistencies I'll comment on shortly. I definitely think the naming changes of variables throughout the usage of the helpers is an improvement, rather than generic names like |
|
|
||
| template <typename _F, typename _Tuple1, typename _Tuple2, std::size_t... _Ip> | ||
| void | ||
| __tuples_apply_impl(_F __f, _Tuple1& __t1, _Tuple2& __t2, std::index_sequence<_Ip...>) |
There was a problem hiding this comment.
Should this be called __tuples_for_each to match the convention above where for_each does not return, but apply does return?
There was a problem hiding this comment.
Yes, this makes sense
danhoeflinger
left a comment
There was a problem hiding this comment.
yeah, overall, I dont have very strong opinions about it but I think its a bit of an improvement, especially if we rename the non-returning tuples_apply to tuples_for_each
…ew_apply_to_tuple
There was a problem hiding this comment.
Pull request overview
This PR prototypes new internal tuple utilities (__tuple_for_each, __tuple_apply) and refactors zip_view to use them for iterator construction, dereference, increment/decrement, and size/end computations.
Changes:
- Introduces
__tuple_for_each*and__tuple_apply*helpers for operating on tuple elements. - Refactors
zip_viewiterator operators andbegin/end/sizeto use the new helpers. - Renames several local “adapter” lambdas to more specific names (
__make_iterator,__make_sentinel, etc.).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lets ask Copilot what name is more suitable in given context :-) Because, I think the question has is a subjective view. F.e. I dont see "language semantic difference" between The main sense - "to apply some lambda/callable object to each component of tuple", right? So,
1 and 2 are absolutely the same, IMHO. If you point on "return/no return" - we can improve a little bit the name with return - |
I think there is a meaningful semantic difference between them:
In my opinion, that's a substantial semantic differenct.
My "return/no return" point was mainly about the current merged version: it sometimes forces a stub adaptor lambda that returns something even when it is irrelevant. The goal of this patch is to redesign the internal helpers so they accept only what's necessary, avoiding those unnecessary adaptors. |
| __tuple_apply_impl(_F __f, _Tuple& __t, std::index_sequence<_Ip...>) | ||
| { | ||
| return __tr(__f(std::get<_Ip>(__t))...); | ||
| return __f(std::get<_Ip>(__t)...); | ||
| } |
There was a problem hiding this comment.
I think this overload is confusing. It names the "adaptor" function applied to all elements of the tuple as __f which is the name used in the nearby context for the function applied to each element of the tuple. It also only serves one caller (creation of zip_iterator). Either we should just pass the identity in as the per element function and get rid of this overload, or it should be named better to differentiate it from the rest of the context.
There was a problem hiding this comment.
In fact, this function is a direct analogue of std::apply. I agree that renaming _F to _Adaptor makes sense to align with the second overload.
We could also use a single __tuple_apply_impl with two functions and pass an identity lambda from __tuple_apply, if that makes the intent clearer from your point of view.
There was a problem hiding this comment.
Renamed _F to _Adaptor and reused another overload with identity lambda in __tuple_apply with 2 arguments
|
@danhoeflinger @MikeDvorskiy |
|
@kboyarinov I havent re-reviewed this but I do think it is an improvement. now that we are past the release, perhaps we can run a full CI on this. If it comes back clean then I would still be in favor of it. |
No description provided.