1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++98, c++03
11
12 // <valarray>
13
14 // template<class T> class valarray;
15
16 // valarray& operator=(valarray&& v);
17
18 #include <valarray>
19 #include <cassert>
20 #include <cstddef>
21
main()22 int main()
23 {
24 {
25 typedef int T;
26 T a[] = {1, 2, 3, 4, 5};
27 const unsigned N = sizeof(a)/sizeof(a[0]);
28 std::valarray<T> v(a, N);
29 std::valarray<T> v2;
30 v2 = std::move(v);
31 assert(v2.size() == N);
32 assert(v.size() == 0);
33 for (std::size_t i = 0; i < v2.size(); ++i)
34 assert(v2[i] == a[i]);
35 }
36 {
37 typedef double T;
38 T a[] = {1, 2.5, 3, 4.25, 5};
39 const unsigned N = sizeof(a)/sizeof(a[0]);
40 std::valarray<T> v(a, N);
41 std::valarray<T> v2;
42 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]);
47 }
48 {
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(a, N-2);
54 v2 = std::move(v);
55 assert(v2.size() == N);
56 assert(v.size() == 0);
57 for (unsigned i = 0; i < N; ++i)
58 {
59 assert(v2[i].size() == a[i].size());
60 for (std::size_t j = 0; j < a[i].size(); ++j)
61 assert(v2[i][j] == a[i][j]);
62 }
63 }
64 }
65