1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <valarray> 10 11 // template<class T> class valarray; 12 13 // valarray& operator=(const slice_array<value_type>& sa); 14 15 #include <valarray> 16 #include <cassert> 17 18 int main(int, char**) 19 { 20 int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; 21 std::valarray<int> v1(a, sizeof(a)/sizeof(a[0])); 22 std::valarray<int> v(5); 23 v = v1[std::slice(1, 5, 3)]; 24 assert(v.size() == 5); 25 assert(v[0] == 1); 26 assert(v[1] == 4); 27 assert(v[2] == 7); 28 assert(v[3] == 10); 29 assert(v[4] == 13); 30 31 return 0; 32 } 33