• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // value_type& operator[](size_t i);
15 
16 #include <valarray>
17 #include <cassert>
18 
main()19 int main()
20 {
21     {
22         typedef int T;
23         T a[] = {5, 4, 3, 2, 1};
24         const unsigned N = sizeof(a)/sizeof(a[0]);
25         std::valarray<T> v(a, N);
26         for (unsigned i = 0; i < N; ++i)
27         {
28             assert(v[i] == a[i]);
29             v[i] = i;
30             assert(v[i] == static_cast<int>(i));
31         }
32     }
33 }
34