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(const valarray<value_type>& v);
17
18 #include <valarray>
19 #include <utility>
20 #include <cassert>
21 #include <cstddef>
22
main()23 int main()
24 {
25 {
26 typedef int T;
27 T a[] = {1, 2, 3, 4, 5};
28 const unsigned N = sizeof(a)/sizeof(a[0]);
29 std::valarray<T> v(a, N);
30 std::valarray<T> 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 = std::move(v);
42 assert(v2.size() == N);
43 assert(v.size() == 0);
44 for (std::size_t i = 0; i < v2.size(); ++i)
45 assert(v2[i] == a[i]);
46 }
47 {
48 typedef std::valarray<double> T;
49 T a[] = {T(1), T(2), T(3), T(4), T(5)};
50 const unsigned N = sizeof(a)/sizeof(a[0]);
51 std::valarray<T> v(a, N);
52 std::valarray<T> v2 = std::move(v);
53 assert(v2.size() == N);
54 assert(v.size() == 0);
55 for (unsigned i = 0; i < N; ++i)
56 {
57 assert(v2[i].size() == a[i].size());
58 for (std::size_t j = 0; j < v2[i].size(); ++j)
59 assert(v2[i][j] == a[i][j]);
60 }
61 }
62 }
63