1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // template<class T> class valarray;
15 // valarray(const valarray<value_type>& v);
22 #include "test_macros.h"
28 T a
[] = {1, 2, 3, 4, 5};
29 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
30 std::valarray
<T
> v(a
, N
);
31 std::valarray
<T
> v2
= std::move(v
);
32 assert(v2
.size() == N
);
33 assert(v
.size() == 0);
34 for (std::size_t i
= 0; i
< v2
.size(); ++i
)
35 assert(v2
[i
] == a
[i
]);
39 T a
[] = {1, 2.5, 3, 4.25, 5};
40 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
41 std::valarray
<T
> v(a
, N
);
42 std::valarray
<T
> v2
= std::move(v
);
43 assert(v2
.size() == N
);
44 assert(v
.size() == 0);
45 for (std::size_t i
= 0; i
< v2
.size(); ++i
)
46 assert(v2
[i
] == a
[i
]);
49 typedef std::valarray
<double> T
;
50 T a
[] = {T(1), T(2), T(3), T(4), T(5)};
51 const unsigned N
= sizeof(a
)/sizeof(a
[0]);
52 std::valarray
<T
> v(a
, N
);
53 std::valarray
<T
> v2
= std::move(v
);
54 assert(v2
.size() == N
);
55 assert(v
.size() == 0);
56 for (unsigned i
= 0; i
< N
; ++i
)
58 assert(v2
[i
].size() == a
[i
].size());
59 for (std::size_t j
= 0; j
< v2
[i
].size(); ++j
)
60 assert(v2
[i
][j
] == a
[i
][j
]);