llvm-project
49 строк · 1.5 Кб
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#include <valarray>
10
11_LIBCPP_BEGIN_NAMESPACE_STD
12
13// These two symbols are part of the v1 ABI but not part of the >=v2 ABI.
14#if _LIBCPP_ABI_VERSION == 1
15template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::valarray(size_t);
16template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::~valarray();
17#endif
18
19template void valarray<size_t>::resize(size_t, size_t);
20
21void gslice::__init(size_t __start) {
22valarray<size_t> __indices(__size_.size());
23size_t __k = __size_.size() != 0;
24for (size_t __i = 0; __i < __size_.size(); ++__i)
25__k *= __size_[__i];
26__1d_.resize(__k);
27if (__1d_.size()) {
28__k = 0;
29__1d_[__k] = __start;
30while (true) {
31size_t __i = __indices.size() - 1;
32while (true) {
33if (++__indices[__i] < __size_[__i]) {
34++__k;
35__1d_[__k] = __1d_[__k - 1] + __stride_[__i];
36for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
37__1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
38break;
39} else {
40if (__i == 0)
41return;
42__indices[__i--] = 0;
43}
44}
45}
46}
47}
48
49_LIBCPP_END_NAMESPACE_STD
50