-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<valarray>: Implement copies for slice_array, gslice_array, mask_array, and indirect_array #988
Conversation
Though sub-optimal
I think it is ready for initial review. |
Mostly to use `_Start_off` and `_Next_off` in microsoft#991
I have a question on assignment operator with mistmatched size. First, consider [valarray.assign]/1
(cppreference says it was UB before C++11) Then [valarray.assign]/10
Note that precondition is somewhat ambiguous. The length of the array to which the argument refers could be both size of underlying array or size of resulting slice. It seems that the later should be assumed, since the former does not make sense in context of [valarray.assign]/11:
Now, [slice.arr.assign], [gslice.array.assign], [mask.array.assign], [indirect.array.assign]:
And that's it. Nothing about different destination size and other size. So here's a comparison of what the Standard says and what implementation so far does:
In the current PR for Note that unlike The questions are:
|
Co-authored-by: S. B. Tam <[email protected]>
Co-authored-by: S. B. Tam <[email protected]>
Co-authored-by: S. B. Tam <[email protected]>
Co-authored-by: S. B. Tam <[email protected]>
# Conflicts: # tests/std/test.lst
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.
Just some small things.
FWIW, I agree with your analysis of the specification or lack thereof. valarray
is a neglected piece of the Standard Library that needs someone to pick it up and rework all of the wording. Until that happens I think it's basically the Wild West in here: we can do anything we like with all of the leeway the spec gives us.
Co-authored-by: Casey Carter <[email protected]>
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.
Thanks for fixing these high-priority customer-reported bugs! I'll go ahead and push a couple of #include
directives to the test, and then this will be Ready To Merge! 🚀
void test_slice() { | ||
std::valarray<int> v{0, 1, 2, 3, 4}; | ||
|
||
std::slice_array<int> slice_array = v[std::slice(2, 2, 2)]; |
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 change requested, just a stylistic comment - while we have tests that vary in their usage of using namespace std;
and it's fine to std::
qualify everything, even when the namespace prevents ambiguity I think that naming things identically to Standard identifiers makes things unnecessarily hard to read/search. (Being able to search for all occurrences of slice_array
in product and test code, and having few spurious results show up, is useful.) Any other names would be fine; e.g. slice_array_copy
won't show up in a whole-word search.
Since it looks like this PR will be ready to merge with a couple of include fixups (yay!), I don't think it's worth renaming now, but I wanted to mention it.
Thanks for the bugfix! |
Resolves #940