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 // void resize(size_t n, value_type x = value_type()); 15 16 #include <valarray> 17 #include <cassert> 18 #include <cstddef> 19 main()20int main() 21 { 22 { 23 typedef int T; 24 T a1[] = {1, 2, 3, 4, 5}; 25 const unsigned N1 = sizeof(a1)/sizeof(a1[0]); 26 std::valarray<T> v1(a1, N1); 27 v1.resize(8); 28 assert(v1.size() == 8); 29 for (std::size_t i = 0; i < v1.size(); ++i) 30 assert(v1[i] == 0); 31 v1.resize(0); 32 assert(v1.size() == 0); 33 v1.resize(80); 34 assert(v1.size() == 80); 35 for (std::size_t i = 0; i < v1.size(); ++i) 36 assert(v1[i] == 0); 37 v1.resize(40); 38 assert(v1.size() == 40); 39 for (std::size_t i = 0; i < v1.size(); ++i) 40 assert(v1[i] == 0); 41 } 42 } 43