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 | // class gslice; |
12 | |
13 | // gslice(size_t start, const valarray<size_t>& size, |
14 | // const valarray<size_t>& stride); |
15 | |
16 | #include <valarray> |
17 | #include <cassert> |
18 | |
19 | #include "test_macros.h" |
20 | |
21 | int main(int, char**) |
22 | { |
23 | std::size_t a1[] = {1, 2, 3}; |
24 | std::size_t a2[] = {4, 5, 6}; |
25 | std::valarray<std::size_t> size(a1, sizeof(a1)/sizeof(a1[0])); |
26 | std::valarray<std::size_t> stride(a2, sizeof(a2)/sizeof(a2[0])); |
27 | std::gslice gs(7, size, stride); |
28 | assert(gs.start() == 7); |
29 | std::valarray<std::size_t> r = gs.size(); |
30 | assert(r.size() == 3); |
31 | assert(r[0] == 1); |
32 | assert(r[1] == 2); |
33 | assert(r[2] == 3); |
34 | r = gs.stride(); |
35 | assert(r.size() == 3); |
36 | assert(r[0] == 4); |
37 | assert(r[1] == 5); |
38 | assert(r[2] == 6); |
39 | |
40 | return 0; |
41 | } |
42 | |