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 // const value_type& operator[](size_t i) const; 15 16 #include <valarray> 17 #include <cassert> 18 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 const std::valarray<T> v(a, N); 26 for (unsigned i = 0; i < N; ++i) 27 { 28 assert(v[i] == a[i]); 29 } 30 } 31 } 32