Add the slice_array::operator=(const std::valarray<T>& val_arr) overload. Fixes llvm.org/PR40792.
Details
- Reviewers
howard.hinnant EricWF ldionne mclow.lists - Group Reviewers
Restricted Project - Commits
- rG644f68ed4d74: [libc++] Add slice_array operator= valarray overload.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
include/valarray | ||
---|---|---|
1267 ↗ | (On Diff #188606) | Can you please update the synopsis? |
test/std/numerics/numarray/template.indirect.array/indirect.array.assign/slice_assignment.pass.cpp | ||
3 ↗ | (On Diff #188606) | This test is in the wrong file. It should be merged with libcxx/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp (which was not testing the right thing unless I'm mistaken). |
24 ↗ | (On Diff #188606) | Can you create a slice_array variable here to make sure we return the right type (and hence are testing the right operator=? Also, we should test that slice_array::operator= returns void. |
LGTM once CI passes.
Even better (IMO) would be to split off the tests for void operator=(const T& value) const; into a separate file, since that was most likely an oversight.
By the way, I had to disable the added tests in C++03 mode.
I'll commit once the buildbots are green.
We use tricks like this in other valarray tests to workaround the lack of initializer_list:
int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
Can we use the same trick here and enable the tests in C++03? I think it would be good for consistency.
Can we use the same trick here and enable the tests in C++03? I think it would be good for consistency.
@ldionne I did that for template.pass.cpp but kept the initializer list test in valarray.pass.cpp because we already have a test without initializer lists (that is enabled in C++03 mode).
clang-format suggested style edits found: