Page MenuHomePhabricator

Add slice_array operator= valarray overload
ClosedPublic

Authored by zoecarver on Feb 27 2019, 12:57 PM.

Details

Summary

Add the slice_array::operator=(const std::valarray<T>& val_arr) overload. Fixes llvm.org/PR40792.

Diff Detail

Event Timeline

zoecarver created this revision.Feb 27 2019, 12:57 PM

Other than more tests, do I need to update this patch in any way?

ldionne requested changes to this revision.Nov 2 2020, 2:55 PM
ldionne added a reviewer: Restricted Project.
ldionne added inline comments.
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.

This revision now requires changes to proceed.Nov 2 2020, 2:55 PM
zoecarver edited the summary of this revision. (Show Details)Nov 23 2020, 12:31 PM
zoecarver updated this revision to Diff 307182.Nov 23 2020, 1:14 PM
zoecarver retitled this revision from Add slice_array operator= valarray overload to Add slice_array operator= valarray overload.
  • Rebase off master
  • Address review comments
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2020, 1:14 PM
ldionne accepted this revision.Nov 23 2020, 1:34 PM

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.

This revision is now accepted and ready to land.Nov 23 2020, 1:34 PM
  • Rebase off master
  • Split into two tests

By the way, I had to disable the added tests in C++03 mode.

I'll commit once the buildbots are green.

ldionne requested changes to this revision.Nov 25 2020, 11:59 AM

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.

This revision now requires changes to proceed.Nov 25 2020, 11:59 AM
zoecarver updated this revision to Diff 308109.Nov 27 2020, 1:19 PM
  • Rebase off master
  • Support template.pass.cpp in C++03 mode

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).

ldionne accepted this revision.Dec 1 2020, 2:15 PM

Thanks!

This revision is now accepted and ready to land.Dec 1 2020, 2:15 PM
This revision was automatically updated to reflect the committed changes.