Add return statement to slice_array and mask_array assignment. Closes PR20614.

This patch just adds the required return statements to slice_array::operator=
and mask_array::operator=.

Tests were added to check that the return value is the same as the object assigned
to.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@215414 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2014-08-12 00:06:58 +00:00
parent 35d775d0e4
commit f4124610c2
3 changed files with 30 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
int main()
{
{
int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12};
std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
@@ -40,4 +41,16 @@ int main()
assert(v1[13] == -11);
assert(v1[14] == 14);
assert(v1[15] == 15);
}
// Test return value of assignment.
{
int a1[] = {0, 1, 2};
int a2[] = {3, 4, 3};
std::valarray<int> v1(a1, 3);
const std::valarray<int> v2(a2, 3);
std::slice_array<int> s1 = v1[std::slice(1, 2, 3)];
std::slice_array<int> s2 = v1[std::slice(2, 2, 3)];
std::slice_array<int> const & s3 = (s1 = s2);
assert(&s1 == &s3);
}
}