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 // <valarray>
11
12 // template<class T> class valarray;
13
14 // valarray& operator=(valarray&& v);
15
16 #include <valarray>
17 #include <cassert>
18
main()19 int main()
20 {
21 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
22 {
23 typedef int T;
24 T a[] = {1, 2, 3, 4, 5};
25 const unsigned N = sizeof(a)/sizeof(a[0]);
26 std::valarray<T> v(a, N);
27 std::valarray<T> v2;
28 v2 = std::move(v);
29 assert(v2.size() == N);
30 assert(v.size() == 0);
31 for (int i = 0; i < v2.size(); ++i)
32 assert(v2[i] == a[i]);
33 }
34 {
35 typedef double T;
36 T a[] = {1, 2.5, 3, 4.25, 5};
37 const unsigned N = sizeof(a)/sizeof(a[0]);
38 std::valarray<T> v(a, N);
39 std::valarray<T> v2;
40 v2 = std::move(v);
41 assert(v2.size() == N);
42 assert(v.size() == 0);
43 for (int i = 0; i < v2.size(); ++i)
44 assert(v2[i] == a[i]);
45 }
46 {
47 typedef std::valarray<double> T;
48 T a[] = {T(1), T(2), T(3), T(4), T(5)};
49 const unsigned N = sizeof(a)/sizeof(a[0]);
50 std::valarray<T> v(a, N);
51 std::valarray<T> v2(a, N-2);
52 v2 = std::move(v);
53 assert(v2.size() == N);
54 assert(v.size() == 0);
55 for (int i = 0; i < N; ++i)
56 {
57 assert(v2[i].size() == a[i].size());
58 for (int j = 0; j < a[i].size(); ++j)
59 assert(v2[i][j] == a[i][j]);
60 }
61 }
62 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
63 }
64