1 | // -*- C++ -*- |
2 | //===----------------------------------------------------------------------===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _LIBCPP_VALARRAY |
11 | #define _LIBCPP_VALARRAY |
12 | |
13 | /* |
14 | valarray synopsis |
15 | |
16 | namespace std |
17 | { |
18 | |
19 | template<class T> |
20 | class valarray |
21 | { |
22 | public: |
23 | typedef T value_type; |
24 | |
25 | // construct/destroy: |
26 | valarray(); |
27 | explicit valarray(size_t n); |
28 | valarray(const value_type& x, size_t n); |
29 | valarray(const value_type* px, size_t n); |
30 | valarray(const valarray& v); |
31 | valarray(valarray&& v) noexcept; |
32 | valarray(const slice_array<value_type>& sa); |
33 | valarray(const gslice_array<value_type>& ga); |
34 | valarray(const mask_array<value_type>& ma); |
35 | valarray(const indirect_array<value_type>& ia); |
36 | valarray(initializer_list<value_type> il); |
37 | ~valarray(); |
38 | |
39 | // assignment: |
40 | valarray& operator=(const valarray& v); |
41 | valarray& operator=(valarray&& v) noexcept; |
42 | valarray& operator=(initializer_list<value_type> il); |
43 | valarray& operator=(const value_type& x); |
44 | valarray& operator=(const slice_array<value_type>& sa); |
45 | valarray& operator=(const gslice_array<value_type>& ga); |
46 | valarray& operator=(const mask_array<value_type>& ma); |
47 | valarray& operator=(const indirect_array<value_type>& ia); |
48 | |
49 | // element access: |
50 | const value_type& operator[](size_t i) const; |
51 | value_type& operator[](size_t i); |
52 | |
53 | // subset operations: |
54 | valarray operator[](slice s) const; |
55 | slice_array<value_type> operator[](slice s); |
56 | valarray operator[](const gslice& gs) const; |
57 | gslice_array<value_type> operator[](const gslice& gs); |
58 | valarray operator[](const valarray<bool>& vb) const; |
59 | mask_array<value_type> operator[](const valarray<bool>& vb); |
60 | valarray operator[](const valarray<size_t>& vs) const; |
61 | indirect_array<value_type> operator[](const valarray<size_t>& vs); |
62 | |
63 | // unary operators: |
64 | valarray operator+() const; |
65 | valarray operator-() const; |
66 | valarray operator~() const; |
67 | valarray<bool> operator!() const; |
68 | |
69 | // computed assignment: |
70 | valarray& operator*= (const value_type& x); |
71 | valarray& operator/= (const value_type& x); |
72 | valarray& operator%= (const value_type& x); |
73 | valarray& operator+= (const value_type& x); |
74 | valarray& operator-= (const value_type& x); |
75 | valarray& operator^= (const value_type& x); |
76 | valarray& operator&= (const value_type& x); |
77 | valarray& operator|= (const value_type& x); |
78 | valarray& operator<<=(const value_type& x); |
79 | valarray& operator>>=(const value_type& x); |
80 | |
81 | valarray& operator*= (const valarray& v); |
82 | valarray& operator/= (const valarray& v); |
83 | valarray& operator%= (const valarray& v); |
84 | valarray& operator+= (const valarray& v); |
85 | valarray& operator-= (const valarray& v); |
86 | valarray& operator^= (const valarray& v); |
87 | valarray& operator|= (const valarray& v); |
88 | valarray& operator&= (const valarray& v); |
89 | valarray& operator<<=(const valarray& v); |
90 | valarray& operator>>=(const valarray& v); |
91 | |
92 | // member functions: |
93 | void swap(valarray& v) noexcept; |
94 | |
95 | size_t size() const; |
96 | |
97 | value_type sum() const; |
98 | value_type min() const; |
99 | value_type max() const; |
100 | |
101 | valarray shift (int i) const; |
102 | valarray cshift(int i) const; |
103 | valarray apply(value_type f(value_type)) const; |
104 | valarray apply(value_type f(const value_type&)) const; |
105 | void resize(size_t n, value_type x = value_type()); |
106 | }; |
107 | |
108 | template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>; |
109 | |
110 | class slice |
111 | { |
112 | public: |
113 | slice(); |
114 | slice(size_t start, size_t size, size_t stride); |
115 | |
116 | size_t start() const; |
117 | size_t size() const; |
118 | size_t stride() const; |
119 | |
120 | friend bool operator==(const slice& x, const slice& y); // since C++20 |
121 | }; |
122 | |
123 | template <class T> |
124 | class slice_array |
125 | { |
126 | public: |
127 | typedef T value_type; |
128 | |
129 | const slice_array& operator=(const slice_array& sa) const; |
130 | void operator= (const valarray<value_type>& v) const; |
131 | void operator*= (const valarray<value_type>& v) const; |
132 | void operator/= (const valarray<value_type>& v) const; |
133 | void operator%= (const valarray<value_type>& v) const; |
134 | void operator+= (const valarray<value_type>& v) const; |
135 | void operator-= (const valarray<value_type>& v) const; |
136 | void operator^= (const valarray<value_type>& v) const; |
137 | void operator&= (const valarray<value_type>& v) const; |
138 | void operator|= (const valarray<value_type>& v) const; |
139 | void operator<<=(const valarray<value_type>& v) const; |
140 | void operator>>=(const valarray<value_type>& v) const; |
141 | |
142 | void operator=(const value_type& x) const; |
143 | void operator=(const valarray<T>& val_arr) const; |
144 | |
145 | slice_array() = delete; |
146 | }; |
147 | |
148 | class gslice |
149 | { |
150 | public: |
151 | gslice(); |
152 | gslice(size_t start, const valarray<size_t>& size, |
153 | const valarray<size_t>& stride); |
154 | |
155 | size_t start() const; |
156 | valarray<size_t> size() const; |
157 | valarray<size_t> stride() const; |
158 | }; |
159 | |
160 | template <class T> |
161 | class gslice_array |
162 | { |
163 | public: |
164 | typedef T value_type; |
165 | |
166 | void operator= (const valarray<value_type>& v) const; |
167 | void operator*= (const valarray<value_type>& v) const; |
168 | void operator/= (const valarray<value_type>& v) const; |
169 | void operator%= (const valarray<value_type>& v) const; |
170 | void operator+= (const valarray<value_type>& v) const; |
171 | void operator-= (const valarray<value_type>& v) const; |
172 | void operator^= (const valarray<value_type>& v) const; |
173 | void operator&= (const valarray<value_type>& v) const; |
174 | void operator|= (const valarray<value_type>& v) const; |
175 | void operator<<=(const valarray<value_type>& v) const; |
176 | void operator>>=(const valarray<value_type>& v) const; |
177 | |
178 | gslice_array(const gslice_array& ga); |
179 | ~gslice_array(); |
180 | const gslice_array& operator=(const gslice_array& ga) const; |
181 | void operator=(const value_type& x) const; |
182 | |
183 | gslice_array() = delete; |
184 | }; |
185 | |
186 | template <class T> |
187 | class mask_array |
188 | { |
189 | public: |
190 | typedef T value_type; |
191 | |
192 | void operator= (const valarray<value_type>& v) const; |
193 | void operator*= (const valarray<value_type>& v) const; |
194 | void operator/= (const valarray<value_type>& v) const; |
195 | void operator%= (const valarray<value_type>& v) const; |
196 | void operator+= (const valarray<value_type>& v) const; |
197 | void operator-= (const valarray<value_type>& v) const; |
198 | void operator^= (const valarray<value_type>& v) const; |
199 | void operator&= (const valarray<value_type>& v) const; |
200 | void operator|= (const valarray<value_type>& v) const; |
201 | void operator<<=(const valarray<value_type>& v) const; |
202 | void operator>>=(const valarray<value_type>& v) const; |
203 | |
204 | mask_array(const mask_array& ma); |
205 | ~mask_array(); |
206 | const mask_array& operator=(const mask_array& ma) const; |
207 | void operator=(const value_type& x) const; |
208 | |
209 | mask_array() = delete; |
210 | }; |
211 | |
212 | template <class T> |
213 | class indirect_array |
214 | { |
215 | public: |
216 | typedef T value_type; |
217 | |
218 | void operator= (const valarray<value_type>& v) const; |
219 | void operator*= (const valarray<value_type>& v) const; |
220 | void operator/= (const valarray<value_type>& v) const; |
221 | void operator%= (const valarray<value_type>& v) const; |
222 | void operator+= (const valarray<value_type>& v) const; |
223 | void operator-= (const valarray<value_type>& v) const; |
224 | void operator^= (const valarray<value_type>& v) const; |
225 | void operator&= (const valarray<value_type>& v) const; |
226 | void operator|= (const valarray<value_type>& v) const; |
227 | void operator<<=(const valarray<value_type>& v) const; |
228 | void operator>>=(const valarray<value_type>& v) const; |
229 | |
230 | indirect_array(const indirect_array& ia); |
231 | ~indirect_array(); |
232 | const indirect_array& operator=(const indirect_array& ia) const; |
233 | void operator=(const value_type& x) const; |
234 | |
235 | indirect_array() = delete; |
236 | }; |
237 | |
238 | template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept; |
239 | |
240 | template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y); |
241 | template<class T> valarray<T> operator* (const valarray<T>& x, const T& y); |
242 | template<class T> valarray<T> operator* (const T& x, const valarray<T>& y); |
243 | |
244 | template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y); |
245 | template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y); |
246 | template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y); |
247 | |
248 | template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y); |
249 | template<class T> valarray<T> operator% (const valarray<T>& x, const T& y); |
250 | template<class T> valarray<T> operator% (const T& x, const valarray<T>& y); |
251 | |
252 | template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y); |
253 | template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y); |
254 | template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y); |
255 | |
256 | template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y); |
257 | template<class T> valarray<T> operator- (const valarray<T>& x, const T& y); |
258 | template<class T> valarray<T> operator- (const T& x, const valarray<T>& y); |
259 | |
260 | template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y); |
261 | template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y); |
262 | template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y); |
263 | |
264 | template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y); |
265 | template<class T> valarray<T> operator& (const valarray<T>& x, const T& y); |
266 | template<class T> valarray<T> operator& (const T& x, const valarray<T>& y); |
267 | |
268 | template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y); |
269 | template<class T> valarray<T> operator| (const valarray<T>& x, const T& y); |
270 | template<class T> valarray<T> operator| (const T& x, const valarray<T>& y); |
271 | |
272 | template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y); |
273 | template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y); |
274 | template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y); |
275 | |
276 | template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y); |
277 | template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y); |
278 | template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y); |
279 | |
280 | template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y); |
281 | template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y); |
282 | template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y); |
283 | |
284 | template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y); |
285 | template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y); |
286 | template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y); |
287 | |
288 | template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y); |
289 | template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y); |
290 | template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y); |
291 | |
292 | template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y); |
293 | template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y); |
294 | template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y); |
295 | |
296 | template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y); |
297 | template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y); |
298 | template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y); |
299 | |
300 | template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y); |
301 | template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y); |
302 | template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y); |
303 | |
304 | template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y); |
305 | template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y); |
306 | template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y); |
307 | |
308 | template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y); |
309 | template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y); |
310 | template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y); |
311 | |
312 | template<class T> valarray<T> abs (const valarray<T>& x); |
313 | template<class T> valarray<T> acos (const valarray<T>& x); |
314 | template<class T> valarray<T> asin (const valarray<T>& x); |
315 | template<class T> valarray<T> atan (const valarray<T>& x); |
316 | |
317 | template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y); |
318 | template<class T> valarray<T> atan2(const valarray<T>& x, const T& y); |
319 | template<class T> valarray<T> atan2(const T& x, const valarray<T>& y); |
320 | |
321 | template<class T> valarray<T> cos (const valarray<T>& x); |
322 | template<class T> valarray<T> cosh (const valarray<T>& x); |
323 | template<class T> valarray<T> exp (const valarray<T>& x); |
324 | template<class T> valarray<T> log (const valarray<T>& x); |
325 | template<class T> valarray<T> log10(const valarray<T>& x); |
326 | |
327 | template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y); |
328 | template<class T> valarray<T> pow(const valarray<T>& x, const T& y); |
329 | template<class T> valarray<T> pow(const T& x, const valarray<T>& y); |
330 | |
331 | template<class T> valarray<T> sin (const valarray<T>& x); |
332 | template<class T> valarray<T> sinh (const valarray<T>& x); |
333 | template<class T> valarray<T> sqrt (const valarray<T>& x); |
334 | template<class T> valarray<T> tan (const valarray<T>& x); |
335 | template<class T> valarray<T> tanh (const valarray<T>& x); |
336 | |
337 | template <class T> unspecified1 begin(valarray<T>& v); |
338 | template <class T> unspecified2 begin(const valarray<T>& v); |
339 | template <class T> unspecified1 end(valarray<T>& v); |
340 | template <class T> unspecified2 end(const valarray<T>& v); |
341 | |
342 | } // std |
343 | |
344 | */ |
345 | |
346 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
347 | # include <__cxx03/valarray> |
348 | #else |
349 | # include <__algorithm/copy.h> |
350 | # include <__algorithm/count.h> |
351 | # include <__algorithm/fill.h> |
352 | # include <__algorithm/max_element.h> |
353 | # include <__algorithm/min.h> |
354 | # include <__algorithm/min_element.h> |
355 | # include <__algorithm/unwrap_iter.h> |
356 | # include <__assert> |
357 | # include <__config> |
358 | # include <__cstddef/ptrdiff_t.h> |
359 | # include <__functional/operations.h> |
360 | # include <__memory/addressof.h> |
361 | # include <__memory/allocator.h> |
362 | # include <__memory/uninitialized_algorithms.h> |
363 | # include <__type_traits/decay.h> |
364 | # include <__type_traits/remove_reference.h> |
365 | # include <__utility/move.h> |
366 | # include <__utility/swap.h> |
367 | # include <cmath> |
368 | # include <version> |
369 | |
370 | // standard-mandated includes |
371 | |
372 | // [valarray.syn] |
373 | # include <initializer_list> |
374 | |
375 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
376 | # pragma GCC system_header |
377 | # endif |
378 | |
379 | _LIBCPP_PUSH_MACROS |
380 | # include <__undef_macros> |
381 | |
382 | _LIBCPP_BEGIN_NAMESPACE_STD |
383 | |
384 | template <class _Tp> |
385 | class valarray; |
386 | |
387 | class slice { |
388 | size_t __start_; |
389 | size_t __size_; |
390 | size_t __stride_; |
391 | |
392 | public: |
393 | _LIBCPP_HIDE_FROM_ABI slice() : __start_(0), __size_(0), __stride_(0) {} |
394 | |
395 | _LIBCPP_HIDE_FROM_ABI slice(size_t __start, size_t __size, size_t __stride) |
396 | : __start_(__start), __size_(__size), __stride_(__stride) {} |
397 | |
398 | _LIBCPP_HIDE_FROM_ABI size_t start() const { return __start_; } |
399 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
400 | _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; } |
401 | |
402 | # if _LIBCPP_STD_VER >= 20 |
403 | |
404 | _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) { |
405 | return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride(); |
406 | } |
407 | |
408 | # endif |
409 | }; |
410 | |
411 | template <class _Tp> |
412 | class slice_array; |
413 | class _LIBCPP_EXPORTED_FROM_ABI gslice; |
414 | template <class _Tp> |
415 | class gslice_array; |
416 | template <class _Tp> |
417 | class mask_array; |
418 | template <class _Tp> |
419 | class indirect_array; |
420 | |
421 | template <class _Tp> |
422 | _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v); |
423 | |
424 | template <class _Tp> |
425 | _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v); |
426 | |
427 | template <class _Tp> |
428 | _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v); |
429 | |
430 | template <class _Tp> |
431 | _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v); |
432 | |
433 | template <class _Op, class _A0> |
434 | struct _UnaryOp { |
435 | typedef typename _Op::__result_type __result_type; |
436 | using value_type = __decay_t<__result_type>; |
437 | |
438 | _Op __op_; |
439 | _A0 __a0_; |
440 | |
441 | _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} |
442 | |
443 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); } |
444 | |
445 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
446 | }; |
447 | |
448 | template <class _Op, class _A0, class _A1> |
449 | struct _BinaryOp { |
450 | typedef typename _Op::__result_type __result_type; |
451 | using value_type = __decay_t<__result_type>; |
452 | |
453 | _Op __op_; |
454 | _A0 __a0_; |
455 | _A1 __a1_; |
456 | |
457 | _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1) |
458 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
459 | |
460 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
461 | |
462 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
463 | }; |
464 | |
465 | template <class _Tp> |
466 | class __scalar_expr { |
467 | public: |
468 | typedef _Tp value_type; |
469 | typedef const _Tp& __result_type; |
470 | |
471 | private: |
472 | const value_type& __t_; |
473 | size_t __s_; |
474 | |
475 | public: |
476 | _LIBCPP_HIDE_FROM_ABI explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} |
477 | |
478 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t) const { return __t_; } |
479 | |
480 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __s_; } |
481 | }; |
482 | |
483 | template <class _Tp> |
484 | struct __unary_plus { |
485 | typedef _Tp __result_type; |
486 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return +__x; } |
487 | }; |
488 | |
489 | template <class _Tp> |
490 | struct __bit_not { |
491 | typedef _Tp __result_type; |
492 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; } |
493 | }; |
494 | |
495 | template <class _Tp> |
496 | struct __bit_shift_left { |
497 | typedef _Tp __result_type; |
498 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x << __y; } |
499 | }; |
500 | |
501 | template <class _Tp> |
502 | struct __bit_shift_right { |
503 | typedef _Tp __result_type; |
504 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x >> __y; } |
505 | }; |
506 | |
507 | template <class _Tp, class _Fp> |
508 | struct __apply_expr { |
509 | private: |
510 | _Fp __f_; |
511 | |
512 | public: |
513 | typedef _Tp __result_type; |
514 | |
515 | _LIBCPP_HIDE_FROM_ABI explicit __apply_expr(_Fp __f) : __f_(__f) {} |
516 | |
517 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return __f_(__x); } |
518 | }; |
519 | |
520 | template <class _Tp> |
521 | struct __abs_expr { |
522 | typedef _Tp __result_type; |
523 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::abs(__x); } |
524 | }; |
525 | |
526 | template <class _Tp> |
527 | struct __acos_expr { |
528 | typedef _Tp __result_type; |
529 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::acos(__x); } |
530 | }; |
531 | |
532 | template <class _Tp> |
533 | struct __asin_expr { |
534 | typedef _Tp __result_type; |
535 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::asin(__x); } |
536 | }; |
537 | |
538 | template <class _Tp> |
539 | struct __atan_expr { |
540 | typedef _Tp __result_type; |
541 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::atan(__x); } |
542 | }; |
543 | |
544 | template <class _Tp> |
545 | struct __atan2_expr { |
546 | typedef _Tp __result_type; |
547 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::atan2(__x, __y); } |
548 | }; |
549 | |
550 | template <class _Tp> |
551 | struct __cos_expr { |
552 | typedef _Tp __result_type; |
553 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cos(__x); } |
554 | }; |
555 | |
556 | template <class _Tp> |
557 | struct __cosh_expr { |
558 | typedef _Tp __result_type; |
559 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::cosh(__x); } |
560 | }; |
561 | |
562 | template <class _Tp> |
563 | struct __exp_expr { |
564 | typedef _Tp __result_type; |
565 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::exp(__x); } |
566 | }; |
567 | |
568 | template <class _Tp> |
569 | struct __log_expr { |
570 | typedef _Tp __result_type; |
571 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log(__x); } |
572 | }; |
573 | |
574 | template <class _Tp> |
575 | struct __log10_expr { |
576 | typedef _Tp __result_type; |
577 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::log10(__x); } |
578 | }; |
579 | |
580 | template <class _Tp> |
581 | struct __pow_expr { |
582 | typedef _Tp __result_type; |
583 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const { return std::pow(__x, __y); } |
584 | }; |
585 | |
586 | template <class _Tp> |
587 | struct __sin_expr { |
588 | typedef _Tp __result_type; |
589 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sin(__x); } |
590 | }; |
591 | |
592 | template <class _Tp> |
593 | struct __sinh_expr { |
594 | typedef _Tp __result_type; |
595 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sinh(__x); } |
596 | }; |
597 | |
598 | template <class _Tp> |
599 | struct __sqrt_expr { |
600 | typedef _Tp __result_type; |
601 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::sqrt(__x); } |
602 | }; |
603 | |
604 | template <class _Tp> |
605 | struct __tan_expr { |
606 | typedef _Tp __result_type; |
607 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tan(__x); } |
608 | }; |
609 | |
610 | template <class _Tp> |
611 | struct __tanh_expr { |
612 | typedef _Tp __result_type; |
613 | _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return std::tanh(__x); } |
614 | }; |
615 | |
616 | template <class _ValExpr> |
617 | class __slice_expr { |
618 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
619 | |
620 | public: |
621 | typedef typename _RmExpr::value_type value_type; |
622 | typedef value_type __result_type; |
623 | |
624 | private: |
625 | _ValExpr __expr_; |
626 | size_t __start_; |
627 | size_t __size_; |
628 | size_t __stride_; |
629 | |
630 | _LIBCPP_HIDE_FROM_ABI __slice_expr(const slice& __sl, const _RmExpr& __e) |
631 | : __expr_(__e), __start_(__sl.start()), __size_(__sl.size()), __stride_(__sl.stride()) {} |
632 | |
633 | public: |
634 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__start_ + __i * __stride_]; } |
635 | |
636 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
637 | |
638 | template <class> |
639 | friend class __val_expr; |
640 | template <class> |
641 | friend class valarray; |
642 | }; |
643 | |
644 | template <class _ValExpr> |
645 | class __mask_expr; |
646 | |
647 | template <class _ValExpr> |
648 | class __indirect_expr; |
649 | |
650 | template <class _ValExpr> |
651 | class __shift_expr { |
652 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
653 | |
654 | public: |
655 | typedef typename _RmExpr::value_type value_type; |
656 | typedef value_type __result_type; |
657 | |
658 | private: |
659 | _ValExpr __expr_; |
660 | size_t __size_; |
661 | ptrdiff_t __ul_; |
662 | ptrdiff_t __sn_; |
663 | ptrdiff_t __n_; |
664 | static const ptrdiff_t _Np = static_cast<ptrdiff_t>(sizeof(ptrdiff_t) * __CHAR_BIT__ - 1); |
665 | |
666 | _LIBCPP_HIDE_FROM_ABI __shift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()), __n_(__n) { |
667 | ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np); |
668 | __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np); |
669 | __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n); |
670 | } |
671 | |
672 | public: |
673 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __j) const { |
674 | ptrdiff_t __i = static_cast<ptrdiff_t>(__j); |
675 | ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; |
676 | return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m); |
677 | } |
678 | |
679 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
680 | |
681 | template <class> |
682 | friend class __val_expr; |
683 | }; |
684 | |
685 | template <class _ValExpr> |
686 | class __cshift_expr { |
687 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
688 | |
689 | public: |
690 | typedef typename _RmExpr::value_type value_type; |
691 | typedef value_type __result_type; |
692 | |
693 | private: |
694 | _ValExpr __expr_; |
695 | size_t __size_; |
696 | size_t __m_; |
697 | size_t __o1_; |
698 | size_t __o2_; |
699 | |
700 | _LIBCPP_HIDE_FROM_ABI __cshift_expr(int __n, const _RmExpr& __e) : __expr_(__e), __size_(__e.size()) { |
701 | __n %= static_cast<int>(__size_); |
702 | if (__n >= 0) { |
703 | __m_ = __size_ - __n; |
704 | __o1_ = __n; |
705 | __o2_ = __n - __size_; |
706 | } else { |
707 | __m_ = -__n; |
708 | __o1_ = __n + __size_; |
709 | __o2_ = __n; |
710 | } |
711 | } |
712 | |
713 | public: |
714 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { |
715 | if (__i < __m_) |
716 | return __expr_[__i + __o1_]; |
717 | return __expr_[__i + __o2_]; |
718 | } |
719 | |
720 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
721 | |
722 | template <class> |
723 | friend class __val_expr; |
724 | }; |
725 | |
726 | template <class _ValExpr> |
727 | class __val_expr; |
728 | |
729 | template <class _ValExpr> |
730 | struct __is_val_expr : false_type {}; |
731 | |
732 | template <class _ValExpr> |
733 | struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; |
734 | |
735 | template <class _Tp> |
736 | struct __is_val_expr<valarray<_Tp> > : true_type {}; |
737 | |
738 | template <class _Tp> |
739 | struct __is_val_expr<slice_array<_Tp> > : true_type {}; |
740 | |
741 | template <class _Tp> |
742 | struct __is_val_expr<gslice_array<_Tp> > : true_type {}; |
743 | |
744 | template <class _Tp> |
745 | struct __is_val_expr<mask_array<_Tp> > : true_type {}; |
746 | |
747 | template <class _Tp> |
748 | struct __is_val_expr<indirect_array<_Tp> > : true_type {}; |
749 | |
750 | // The functions using a __val_expr access the elements by their index. |
751 | // valarray and the libc++ lazy proxies have an operator[]. The |
752 | // Standard proxy array's don't have this operator, instead they have a |
753 | // implementation specific accessor |
754 | // __get(size_t) |
755 | // |
756 | // The functions use the non-member function |
757 | // __get(__val_expr, size_t) |
758 | // |
759 | // If the __val_expr is a specialization of __val_expr_use_member_functions it |
760 | // uses the __val_expr's member function |
761 | // __get(size_t) |
762 | // else it uses the __val_expr's member function |
763 | // operator[](size_t) |
764 | template <class _ValExpr> |
765 | struct __val_expr_use_member_functions; |
766 | |
767 | template <class> |
768 | struct __val_expr_use_member_functions : false_type {}; |
769 | |
770 | template <class _Tp> |
771 | struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {}; |
772 | |
773 | template <class _Tp> |
774 | struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {}; |
775 | |
776 | template <class _Tp> |
777 | struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {}; |
778 | |
779 | template <class _Tp> |
780 | struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {}; |
781 | |
782 | template <class _Tp> |
783 | class valarray { |
784 | public: |
785 | typedef _Tp value_type; |
786 | typedef _Tp __result_type; |
787 | |
788 | private: |
789 | value_type* __begin_; |
790 | value_type* __end_; |
791 | |
792 | public: |
793 | // construct/destroy: |
794 | _LIBCPP_HIDE_FROM_ABI valarray() : __begin_(nullptr), __end_(nullptr) {} |
795 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit valarray(size_t __n); |
796 | _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n); |
797 | valarray(const value_type* __p, size_t __n); |
798 | valarray(const valarray& __v); |
799 | # ifndef _LIBCPP_CXX03_LANG |
800 | _LIBCPP_HIDE_FROM_ABI valarray(valarray&& __v) _NOEXCEPT; |
801 | valarray(initializer_list<value_type> __il); |
802 | # endif // _LIBCPP_CXX03_LANG |
803 | valarray(const slice_array<value_type>& __sa); |
804 | valarray(const gslice_array<value_type>& __ga); |
805 | valarray(const mask_array<value_type>& __ma); |
806 | valarray(const indirect_array<value_type>& __ia); |
807 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 ~valarray(); |
808 | |
809 | // assignment: |
810 | valarray& operator=(const valarray& __v); |
811 | # ifndef _LIBCPP_CXX03_LANG |
812 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(valarray&& __v) _NOEXCEPT; |
813 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(initializer_list<value_type>); |
814 | # endif // _LIBCPP_CXX03_LANG |
815 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x); |
816 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa); |
817 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga); |
818 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const mask_array<value_type>& __ma); |
819 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const indirect_array<value_type>& __ia); |
820 | template <class _ValExpr> |
821 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v); |
822 | |
823 | // element access: |
824 | _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { |
825 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds" ); |
826 | return __begin_[__i]; |
827 | } |
828 | |
829 | _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { |
830 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds" ); |
831 | return __begin_[__i]; |
832 | } |
833 | |
834 | // subset operations: |
835 | _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; |
836 | _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s); |
837 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; |
838 | _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs); |
839 | # ifndef _LIBCPP_CXX03_LANG |
840 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; |
841 | _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs); |
842 | # endif // _LIBCPP_CXX03_LANG |
843 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; |
844 | _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb); |
845 | # ifndef _LIBCPP_CXX03_LANG |
846 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; |
847 | _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb); |
848 | # endif // _LIBCPP_CXX03_LANG |
849 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; |
850 | _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs); |
851 | # ifndef _LIBCPP_CXX03_LANG |
852 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; |
853 | _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs); |
854 | # endif // _LIBCPP_CXX03_LANG |
855 | |
856 | // unary operators: |
857 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const; |
858 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const; |
859 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const; |
860 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const; |
861 | |
862 | // computed assignment: |
863 | _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const value_type& __x); |
864 | _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const value_type& __x); |
865 | _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const value_type& __x); |
866 | _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const value_type& __x); |
867 | _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const value_type& __x); |
868 | _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const value_type& __x); |
869 | _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const value_type& __x); |
870 | _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const value_type& __x); |
871 | _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const value_type& __x); |
872 | _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const value_type& __x); |
873 | |
874 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
875 | _LIBCPP_HIDE_FROM_ABI valarray& operator*=(const _Expr& __v); |
876 | |
877 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
878 | _LIBCPP_HIDE_FROM_ABI valarray& operator/=(const _Expr& __v); |
879 | |
880 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
881 | _LIBCPP_HIDE_FROM_ABI valarray& operator%=(const _Expr& __v); |
882 | |
883 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
884 | _LIBCPP_HIDE_FROM_ABI valarray& operator+=(const _Expr& __v); |
885 | |
886 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
887 | _LIBCPP_HIDE_FROM_ABI valarray& operator-=(const _Expr& __v); |
888 | |
889 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
890 | _LIBCPP_HIDE_FROM_ABI valarray& operator^=(const _Expr& __v); |
891 | |
892 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
893 | _LIBCPP_HIDE_FROM_ABI valarray& operator|=(const _Expr& __v); |
894 | |
895 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
896 | _LIBCPP_HIDE_FROM_ABI valarray& operator&=(const _Expr& __v); |
897 | |
898 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
899 | _LIBCPP_HIDE_FROM_ABI valarray& operator<<=(const _Expr& __v); |
900 | |
901 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
902 | _LIBCPP_HIDE_FROM_ABI valarray& operator>>=(const _Expr& __v); |
903 | |
904 | // member functions: |
905 | _LIBCPP_HIDE_FROM_ABI void swap(valarray& __v) _NOEXCEPT; |
906 | |
907 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return static_cast<size_t>(__end_ - __begin_); } |
908 | |
909 | _LIBCPP_HIDE_FROM_ABI value_type sum() const; |
910 | _LIBCPP_HIDE_FROM_ABI value_type min() const; |
911 | _LIBCPP_HIDE_FROM_ABI value_type max() const; |
912 | |
913 | valarray shift(int __i) const; |
914 | valarray cshift(int __i) const; |
915 | valarray apply(value_type __f(value_type)) const; |
916 | valarray apply(value_type __f(const value_type&)) const; |
917 | void resize(size_t __n, value_type __x = value_type()); |
918 | |
919 | private: |
920 | template <class> |
921 | friend class valarray; |
922 | template <class> |
923 | friend class slice_array; |
924 | template <class> |
925 | friend class gslice_array; |
926 | template <class> |
927 | friend class mask_array; |
928 | template <class> |
929 | friend class __mask_expr; |
930 | template <class> |
931 | friend class indirect_array; |
932 | template <class> |
933 | friend class __indirect_expr; |
934 | template <class> |
935 | friend class __val_expr; |
936 | |
937 | template <class _Up> |
938 | friend _Up* begin(valarray<_Up>& __v); |
939 | |
940 | template <class _Up> |
941 | friend const _Up* begin(const valarray<_Up>& __v); |
942 | |
943 | template <class _Up> |
944 | friend _Up* end(valarray<_Up>& __v); |
945 | |
946 | template <class _Up> |
947 | friend const _Up* end(const valarray<_Up>& __v); |
948 | |
949 | _LIBCPP_HIDE_FROM_ABI void __clear(size_t __capacity); |
950 | valarray& __assign_range(const value_type* __f, const value_type* __l); |
951 | }; |
952 | |
953 | # if _LIBCPP_STD_VER >= 17 |
954 | template <class _Tp, size_t _Size> |
955 | valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>; |
956 | # endif |
957 | |
958 | template <class _Expr, |
959 | __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0> |
960 | _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) { |
961 | return __v.__get(__i); |
962 | } |
963 | |
964 | template <class _Expr, |
965 | __enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0> |
966 | _LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) { |
967 | return __v[__i]; |
968 | } |
969 | |
970 | extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t); |
971 | |
972 | template <class _Op, class _Tp> |
973 | struct _UnaryOp<_Op, valarray<_Tp> > { |
974 | typedef typename _Op::__result_type __result_type; |
975 | using value_type = __decay_t<__result_type>; |
976 | |
977 | _Op __op_; |
978 | const valarray<_Tp>& __a0_; |
979 | |
980 | _LIBCPP_HIDE_FROM_ABI _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} |
981 | |
982 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i]); } |
983 | |
984 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
985 | }; |
986 | |
987 | template <class _Op, class _Tp, class _A1> |
988 | struct _BinaryOp<_Op, valarray<_Tp>, _A1> { |
989 | typedef typename _Op::__result_type __result_type; |
990 | using value_type = __decay_t<__result_type>; |
991 | |
992 | _Op __op_; |
993 | const valarray<_Tp>& __a0_; |
994 | _A1 __a1_; |
995 | |
996 | _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1) |
997 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
998 | |
999 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
1000 | |
1001 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
1002 | }; |
1003 | |
1004 | template <class _Op, class _A0, class _Tp> |
1005 | struct _BinaryOp<_Op, _A0, valarray<_Tp> > { |
1006 | typedef typename _Op::__result_type __result_type; |
1007 | using value_type = __decay_t<__result_type>; |
1008 | |
1009 | _Op __op_; |
1010 | _A0 __a0_; |
1011 | const valarray<_Tp>& __a1_; |
1012 | |
1013 | _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1) |
1014 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
1015 | |
1016 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
1017 | |
1018 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
1019 | }; |
1020 | |
1021 | template <class _Op, class _Tp> |
1022 | struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > { |
1023 | typedef typename _Op::__result_type __result_type; |
1024 | using value_type = __decay_t<__result_type>; |
1025 | |
1026 | _Op __op_; |
1027 | const valarray<_Tp>& __a0_; |
1028 | const valarray<_Tp>& __a1_; |
1029 | |
1030 | _LIBCPP_HIDE_FROM_ABI _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1) |
1031 | : __op_(__op), __a0_(__a0), __a1_(__a1) {} |
1032 | |
1033 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __op_(__a0_[__i], __a1_[__i]); } |
1034 | |
1035 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __a0_.size(); } |
1036 | }; |
1037 | |
1038 | // slice_array |
1039 | |
1040 | template <class _Tp> |
1041 | class slice_array { |
1042 | public: |
1043 | typedef _Tp value_type; |
1044 | |
1045 | private: |
1046 | value_type* __vp_; |
1047 | size_t __size_; |
1048 | size_t __stride_; |
1049 | |
1050 | public: |
1051 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1052 | void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
1053 | |
1054 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1055 | void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
1056 | |
1057 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1058 | void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
1059 | |
1060 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1061 | void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
1062 | |
1063 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1064 | void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
1065 | |
1066 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1067 | void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
1068 | |
1069 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1070 | void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
1071 | |
1072 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1073 | void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
1074 | |
1075 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1076 | void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
1077 | |
1078 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1079 | void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
1080 | |
1081 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1082 | void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
1083 | |
1084 | slice_array(slice_array const&) = default; |
1085 | |
1086 | _LIBCPP_HIDE_FROM_ABI const slice_array& operator=(const slice_array& __sa) const; |
1087 | |
1088 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
1089 | |
1090 | _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const; |
1091 | |
1092 | // Behaves like __val_expr::operator[], which returns by value. |
1093 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
1094 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds" ); |
1095 | return __vp_[__i * __stride_]; |
1096 | } |
1097 | |
1098 | private: |
1099 | _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v) |
1100 | : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {} |
1101 | |
1102 | template <class> |
1103 | friend class valarray; |
1104 | }; |
1105 | |
1106 | template <class _Tp> |
1107 | inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const { |
1108 | value_type* __t = __vp_; |
1109 | const value_type* __s = __sa.__vp_; |
1110 | for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) |
1111 | *__t = *__s; |
1112 | return *this; |
1113 | } |
1114 | |
1115 | template <class _Tp> |
1116 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1117 | inline void slice_array<_Tp>::operator=(const _Expr& __v) const { |
1118 | value_type* __t = __vp_; |
1119 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1120 | *__t = __v[__i]; |
1121 | } |
1122 | |
1123 | template <class _Tp> |
1124 | inline void slice_array<_Tp>::operator=(const valarray<value_type>& __va) const { |
1125 | value_type* __t = __vp_; |
1126 | for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_) |
1127 | *__t = __va[__i]; |
1128 | } |
1129 | |
1130 | template <class _Tp> |
1131 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1132 | inline void slice_array<_Tp>::operator*=(const _Expr& __v) const { |
1133 | value_type* __t = __vp_; |
1134 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1135 | *__t *= __v[__i]; |
1136 | } |
1137 | |
1138 | template <class _Tp> |
1139 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1140 | inline void slice_array<_Tp>::operator/=(const _Expr& __v) const { |
1141 | value_type* __t = __vp_; |
1142 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1143 | *__t /= __v[__i]; |
1144 | } |
1145 | |
1146 | template <class _Tp> |
1147 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1148 | inline void slice_array<_Tp>::operator%=(const _Expr& __v) const { |
1149 | value_type* __t = __vp_; |
1150 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1151 | *__t %= __v[__i]; |
1152 | } |
1153 | |
1154 | template <class _Tp> |
1155 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1156 | inline void slice_array<_Tp>::operator+=(const _Expr& __v) const { |
1157 | value_type* __t = __vp_; |
1158 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1159 | *__t += __v[__i]; |
1160 | } |
1161 | |
1162 | template <class _Tp> |
1163 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1164 | inline void slice_array<_Tp>::operator-=(const _Expr& __v) const { |
1165 | value_type* __t = __vp_; |
1166 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1167 | *__t -= __v[__i]; |
1168 | } |
1169 | |
1170 | template <class _Tp> |
1171 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1172 | inline void slice_array<_Tp>::operator^=(const _Expr& __v) const { |
1173 | value_type* __t = __vp_; |
1174 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1175 | *__t ^= __v[__i]; |
1176 | } |
1177 | |
1178 | template <class _Tp> |
1179 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1180 | inline void slice_array<_Tp>::operator&=(const _Expr& __v) const { |
1181 | value_type* __t = __vp_; |
1182 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1183 | *__t &= __v[__i]; |
1184 | } |
1185 | |
1186 | template <class _Tp> |
1187 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1188 | inline void slice_array<_Tp>::operator|=(const _Expr& __v) const { |
1189 | value_type* __t = __vp_; |
1190 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1191 | *__t |= __v[__i]; |
1192 | } |
1193 | |
1194 | template <class _Tp> |
1195 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1196 | inline void slice_array<_Tp>::operator<<=(const _Expr& __v) const { |
1197 | value_type* __t = __vp_; |
1198 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1199 | *__t <<= __v[__i]; |
1200 | } |
1201 | |
1202 | template <class _Tp> |
1203 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1204 | inline void slice_array<_Tp>::operator>>=(const _Expr& __v) const { |
1205 | value_type* __t = __vp_; |
1206 | for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) |
1207 | *__t >>= __v[__i]; |
1208 | } |
1209 | |
1210 | template <class _Tp> |
1211 | inline void slice_array<_Tp>::operator=(const value_type& __x) const { |
1212 | value_type* __t = __vp_; |
1213 | for (size_t __n = __size_; __n; --__n, __t += __stride_) |
1214 | *__t = __x; |
1215 | } |
1216 | |
1217 | // gslice |
1218 | |
1219 | class _LIBCPP_EXPORTED_FROM_ABI gslice { |
1220 | valarray<size_t> __size_; |
1221 | valarray<size_t> __stride_; |
1222 | valarray<size_t> __1d_; |
1223 | |
1224 | public: |
1225 | _LIBCPP_HIDE_FROM_ABI gslice() {} |
1226 | |
1227 | _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, const valarray<size_t>& __stride) |
1228 | : __size_(__size), __stride_(__stride) { |
1229 | __init(__start); |
1230 | } |
1231 | |
1232 | # ifndef _LIBCPP_CXX03_LANG |
1233 | |
1234 | _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, valarray<size_t>&& __stride) |
1235 | : __size_(__size), __stride_(std::move(__stride)) { |
1236 | __init(__start); |
1237 | } |
1238 | |
1239 | _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, const valarray<size_t>& __stride) |
1240 | : __size_(std::move(__size)), __stride_(__stride) { |
1241 | __init(__start); |
1242 | } |
1243 | |
1244 | _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, valarray<size_t>&& __size, valarray<size_t>&& __stride) |
1245 | : __size_(std::move(__size)), __stride_(std::move(__stride)) { |
1246 | __init(__start); |
1247 | } |
1248 | |
1249 | # endif // _LIBCPP_CXX03_LANG |
1250 | |
1251 | _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; } |
1252 | |
1253 | _LIBCPP_HIDE_FROM_ABI valarray<size_t> size() const { return __size_; } |
1254 | |
1255 | _LIBCPP_HIDE_FROM_ABI valarray<size_t> stride() const { return __stride_; } |
1256 | |
1257 | private: |
1258 | void __init(size_t __start); |
1259 | |
1260 | template <class> |
1261 | friend class gslice_array; |
1262 | template <class> |
1263 | friend class valarray; |
1264 | template <class> |
1265 | friend class __val_expr; |
1266 | }; |
1267 | |
1268 | // gslice_array |
1269 | |
1270 | template <class _Tp> |
1271 | class gslice_array { |
1272 | public: |
1273 | typedef _Tp value_type; |
1274 | |
1275 | private: |
1276 | value_type* __vp_; |
1277 | valarray<size_t> __1d_; |
1278 | |
1279 | public: |
1280 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1281 | void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
1282 | |
1283 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1284 | void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
1285 | |
1286 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1287 | void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
1288 | |
1289 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1290 | void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
1291 | |
1292 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1293 | void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
1294 | |
1295 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1296 | void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
1297 | |
1298 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1299 | void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
1300 | |
1301 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1302 | void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
1303 | |
1304 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1305 | void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
1306 | |
1307 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1308 | void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
1309 | |
1310 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1311 | void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
1312 | |
1313 | _LIBCPP_HIDE_FROM_ABI const gslice_array& operator=(const gslice_array& __ga) const; |
1314 | |
1315 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
1316 | |
1317 | gslice_array(const gslice_array&) = default; |
1318 | |
1319 | // Behaves like __val_expr::operator[], which returns by value. |
1320 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
1321 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds" ); |
1322 | return __vp_[__1d_[__i]]; |
1323 | } |
1324 | |
1325 | private: |
1326 | gslice_array(const gslice& __gs, const valarray<value_type>& __v) |
1327 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {} |
1328 | |
1329 | # ifndef _LIBCPP_CXX03_LANG |
1330 | gslice_array(gslice&& __gs, const valarray<value_type>& __v) |
1331 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__gs.__1d_)) {} |
1332 | # endif // _LIBCPP_CXX03_LANG |
1333 | |
1334 | template <class> |
1335 | friend class valarray; |
1336 | }; |
1337 | |
1338 | template <class _Tp> |
1339 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1340 | inline void gslice_array<_Tp>::operator=(const _Expr& __v) const { |
1341 | typedef const size_t* _Ip; |
1342 | size_t __j = 0; |
1343 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1344 | __vp_[*__i] = __v[__j]; |
1345 | } |
1346 | |
1347 | template <class _Tp> |
1348 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1349 | inline void gslice_array<_Tp>::operator*=(const _Expr& __v) const { |
1350 | typedef const size_t* _Ip; |
1351 | size_t __j = 0; |
1352 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1353 | __vp_[*__i] *= __v[__j]; |
1354 | } |
1355 | |
1356 | template <class _Tp> |
1357 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1358 | inline void gslice_array<_Tp>::operator/=(const _Expr& __v) const { |
1359 | typedef const size_t* _Ip; |
1360 | size_t __j = 0; |
1361 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1362 | __vp_[*__i] /= __v[__j]; |
1363 | } |
1364 | |
1365 | template <class _Tp> |
1366 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1367 | inline void gslice_array<_Tp>::operator%=(const _Expr& __v) const { |
1368 | typedef const size_t* _Ip; |
1369 | size_t __j = 0; |
1370 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1371 | __vp_[*__i] %= __v[__j]; |
1372 | } |
1373 | |
1374 | template <class _Tp> |
1375 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1376 | inline void gslice_array<_Tp>::operator+=(const _Expr& __v) const { |
1377 | typedef const size_t* _Ip; |
1378 | size_t __j = 0; |
1379 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1380 | __vp_[*__i] += __v[__j]; |
1381 | } |
1382 | |
1383 | template <class _Tp> |
1384 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1385 | inline void gslice_array<_Tp>::operator-=(const _Expr& __v) const { |
1386 | typedef const size_t* _Ip; |
1387 | size_t __j = 0; |
1388 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1389 | __vp_[*__i] -= __v[__j]; |
1390 | } |
1391 | |
1392 | template <class _Tp> |
1393 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1394 | inline void gslice_array<_Tp>::operator^=(const _Expr& __v) const { |
1395 | typedef const size_t* _Ip; |
1396 | size_t __j = 0; |
1397 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1398 | __vp_[*__i] ^= __v[__j]; |
1399 | } |
1400 | |
1401 | template <class _Tp> |
1402 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1403 | inline void gslice_array<_Tp>::operator&=(const _Expr& __v) const { |
1404 | typedef const size_t* _Ip; |
1405 | size_t __j = 0; |
1406 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1407 | __vp_[*__i] &= __v[__j]; |
1408 | } |
1409 | |
1410 | template <class _Tp> |
1411 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1412 | inline void gslice_array<_Tp>::operator|=(const _Expr& __v) const { |
1413 | typedef const size_t* _Ip; |
1414 | size_t __j = 0; |
1415 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1416 | __vp_[*__i] |= __v[__j]; |
1417 | } |
1418 | |
1419 | template <class _Tp> |
1420 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1421 | inline void gslice_array<_Tp>::operator<<=(const _Expr& __v) const { |
1422 | typedef const size_t* _Ip; |
1423 | size_t __j = 0; |
1424 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1425 | __vp_[*__i] <<= __v[__j]; |
1426 | } |
1427 | |
1428 | template <class _Tp> |
1429 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1430 | inline void gslice_array<_Tp>::operator>>=(const _Expr& __v) const { |
1431 | typedef const size_t* _Ip; |
1432 | size_t __j = 0; |
1433 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) |
1434 | __vp_[*__i] >>= __v[__j]; |
1435 | } |
1436 | |
1437 | template <class _Tp> |
1438 | inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const { |
1439 | typedef const size_t* _Ip; |
1440 | const value_type* __s = __ga.__vp_; |
1441 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; __i != __e; ++__i, ++__j) |
1442 | __vp_[*__i] = __s[*__j]; |
1443 | return *this; |
1444 | } |
1445 | |
1446 | template <class _Tp> |
1447 | inline void gslice_array<_Tp>::operator=(const value_type& __x) const { |
1448 | typedef const size_t* _Ip; |
1449 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
1450 | __vp_[*__i] = __x; |
1451 | } |
1452 | |
1453 | // mask_array |
1454 | |
1455 | template <class _Tp> |
1456 | class mask_array { |
1457 | public: |
1458 | typedef _Tp value_type; |
1459 | |
1460 | private: |
1461 | value_type* __vp_; |
1462 | valarray<size_t> __1d_; |
1463 | |
1464 | public: |
1465 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1466 | void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
1467 | |
1468 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1469 | void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
1470 | |
1471 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1472 | void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
1473 | |
1474 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1475 | void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
1476 | |
1477 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1478 | void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
1479 | |
1480 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1481 | void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
1482 | |
1483 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1484 | void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
1485 | |
1486 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1487 | void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
1488 | |
1489 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1490 | void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
1491 | |
1492 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1493 | void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
1494 | |
1495 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1496 | void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
1497 | |
1498 | mask_array(const mask_array&) = default; |
1499 | |
1500 | _LIBCPP_HIDE_FROM_ABI const mask_array& operator=(const mask_array& __ma) const; |
1501 | |
1502 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
1503 | |
1504 | // Behaves like __val_expr::operator[], which returns by value. |
1505 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
1506 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds" ); |
1507 | return __vp_[__1d_[__i]]; |
1508 | } |
1509 | |
1510 | private: |
1511 | _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) |
1512 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
1513 | __1d_(static_cast<size_t>(count(first: __vb.__begin_, last: __vb.__end_, value: true))) { |
1514 | size_t __j = 0; |
1515 | for (size_t __i = 0; __i < __vb.size(); ++__i) |
1516 | if (__vb[__i]) |
1517 | __1d_[__j++] = __i; |
1518 | } |
1519 | |
1520 | template <class> |
1521 | friend class valarray; |
1522 | }; |
1523 | |
1524 | template <class _Tp> |
1525 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1526 | inline void mask_array<_Tp>::operator=(const _Expr& __v) const { |
1527 | size_t __n = __1d_.size(); |
1528 | for (size_t __i = 0; __i < __n; ++__i) |
1529 | __vp_[__1d_[__i]] = __v[__i]; |
1530 | } |
1531 | |
1532 | template <class _Tp> |
1533 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1534 | inline void mask_array<_Tp>::operator*=(const _Expr& __v) const { |
1535 | size_t __n = __1d_.size(); |
1536 | for (size_t __i = 0; __i < __n; ++__i) |
1537 | __vp_[__1d_[__i]] *= __v[__i]; |
1538 | } |
1539 | |
1540 | template <class _Tp> |
1541 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1542 | inline void mask_array<_Tp>::operator/=(const _Expr& __v) const { |
1543 | size_t __n = __1d_.size(); |
1544 | for (size_t __i = 0; __i < __n; ++__i) |
1545 | __vp_[__1d_[__i]] /= __v[__i]; |
1546 | } |
1547 | |
1548 | template <class _Tp> |
1549 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1550 | inline void mask_array<_Tp>::operator%=(const _Expr& __v) const { |
1551 | size_t __n = __1d_.size(); |
1552 | for (size_t __i = 0; __i < __n; ++__i) |
1553 | __vp_[__1d_[__i]] %= __v[__i]; |
1554 | } |
1555 | |
1556 | template <class _Tp> |
1557 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1558 | inline void mask_array<_Tp>::operator+=(const _Expr& __v) const { |
1559 | size_t __n = __1d_.size(); |
1560 | for (size_t __i = 0; __i < __n; ++__i) |
1561 | __vp_[__1d_[__i]] += __v[__i]; |
1562 | } |
1563 | |
1564 | template <class _Tp> |
1565 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1566 | inline void mask_array<_Tp>::operator-=(const _Expr& __v) const { |
1567 | size_t __n = __1d_.size(); |
1568 | for (size_t __i = 0; __i < __n; ++__i) |
1569 | __vp_[__1d_[__i]] -= __v[__i]; |
1570 | } |
1571 | |
1572 | template <class _Tp> |
1573 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1574 | inline void mask_array<_Tp>::operator^=(const _Expr& __v) const { |
1575 | size_t __n = __1d_.size(); |
1576 | for (size_t __i = 0; __i < __n; ++__i) |
1577 | __vp_[__1d_[__i]] ^= __v[__i]; |
1578 | } |
1579 | |
1580 | template <class _Tp> |
1581 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1582 | inline void mask_array<_Tp>::operator&=(const _Expr& __v) const { |
1583 | size_t __n = __1d_.size(); |
1584 | for (size_t __i = 0; __i < __n; ++__i) |
1585 | __vp_[__1d_[__i]] &= __v[__i]; |
1586 | } |
1587 | |
1588 | template <class _Tp> |
1589 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1590 | inline void mask_array<_Tp>::operator|=(const _Expr& __v) const { |
1591 | size_t __n = __1d_.size(); |
1592 | for (size_t __i = 0; __i < __n; ++__i) |
1593 | __vp_[__1d_[__i]] |= __v[__i]; |
1594 | } |
1595 | |
1596 | template <class _Tp> |
1597 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1598 | inline void mask_array<_Tp>::operator<<=(const _Expr& __v) const { |
1599 | size_t __n = __1d_.size(); |
1600 | for (size_t __i = 0; __i < __n; ++__i) |
1601 | __vp_[__1d_[__i]] <<= __v[__i]; |
1602 | } |
1603 | |
1604 | template <class _Tp> |
1605 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1606 | inline void mask_array<_Tp>::operator>>=(const _Expr& __v) const { |
1607 | size_t __n = __1d_.size(); |
1608 | for (size_t __i = 0; __i < __n; ++__i) |
1609 | __vp_[__1d_[__i]] >>= __v[__i]; |
1610 | } |
1611 | |
1612 | template <class _Tp> |
1613 | inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const { |
1614 | size_t __n = __1d_.size(); |
1615 | for (size_t __i = 0; __i < __n; ++__i) |
1616 | __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; |
1617 | return *this; |
1618 | } |
1619 | |
1620 | template <class _Tp> |
1621 | inline void mask_array<_Tp>::operator=(const value_type& __x) const { |
1622 | size_t __n = __1d_.size(); |
1623 | for (size_t __i = 0; __i < __n; ++__i) |
1624 | __vp_[__1d_[__i]] = __x; |
1625 | } |
1626 | |
1627 | template <class _ValExpr> |
1628 | class __mask_expr { |
1629 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
1630 | |
1631 | public: |
1632 | typedef typename _RmExpr::value_type value_type; |
1633 | typedef value_type __result_type; |
1634 | |
1635 | private: |
1636 | _ValExpr __expr_; |
1637 | valarray<size_t> __1d_; |
1638 | |
1639 | _LIBCPP_HIDE_FROM_ABI __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e) |
1640 | : __expr_(__e), __1d_(static_cast<size_t>(count(first: __vb.__begin_, last: __vb.__end_, value: true))) { |
1641 | size_t __j = 0; |
1642 | for (size_t __i = 0; __i < __vb.size(); ++__i) |
1643 | if (__vb[__i]) |
1644 | __1d_[__j++] = __i; |
1645 | } |
1646 | |
1647 | public: |
1648 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; } |
1649 | |
1650 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); } |
1651 | |
1652 | template <class> |
1653 | friend class __val_expr; |
1654 | template <class> |
1655 | friend class valarray; |
1656 | }; |
1657 | |
1658 | // indirect_array |
1659 | |
1660 | template <class _Tp> |
1661 | class indirect_array { |
1662 | public: |
1663 | typedef _Tp value_type; |
1664 | |
1665 | private: |
1666 | value_type* __vp_; |
1667 | valarray<size_t> __1d_; |
1668 | |
1669 | public: |
1670 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1671 | void _LIBCPP_HIDE_FROM_ABI operator=(const _Expr& __v) const; |
1672 | |
1673 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1674 | void _LIBCPP_HIDE_FROM_ABI operator*=(const _Expr& __v) const; |
1675 | |
1676 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1677 | void _LIBCPP_HIDE_FROM_ABI operator/=(const _Expr& __v) const; |
1678 | |
1679 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1680 | void _LIBCPP_HIDE_FROM_ABI operator%=(const _Expr& __v) const; |
1681 | |
1682 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1683 | void _LIBCPP_HIDE_FROM_ABI operator+=(const _Expr& __v) const; |
1684 | |
1685 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1686 | void _LIBCPP_HIDE_FROM_ABI operator-=(const _Expr& __v) const; |
1687 | |
1688 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1689 | void _LIBCPP_HIDE_FROM_ABI operator^=(const _Expr& __v) const; |
1690 | |
1691 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1692 | void _LIBCPP_HIDE_FROM_ABI operator&=(const _Expr& __v) const; |
1693 | |
1694 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1695 | void _LIBCPP_HIDE_FROM_ABI operator|=(const _Expr& __v) const; |
1696 | |
1697 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1698 | void _LIBCPP_HIDE_FROM_ABI operator<<=(const _Expr& __v) const; |
1699 | |
1700 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
1701 | void _LIBCPP_HIDE_FROM_ABI operator>>=(const _Expr& __v) const; |
1702 | |
1703 | indirect_array(const indirect_array&) = default; |
1704 | |
1705 | _LIBCPP_HIDE_FROM_ABI const indirect_array& operator=(const indirect_array& __ia) const; |
1706 | |
1707 | _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const; |
1708 | |
1709 | // Behaves like __val_expr::operator[], which returns by value. |
1710 | _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const { |
1711 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds" ); |
1712 | return __vp_[__1d_[__i]]; |
1713 | } |
1714 | |
1715 | private: |
1716 | _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) |
1717 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {} |
1718 | |
1719 | # ifndef _LIBCPP_CXX03_LANG |
1720 | |
1721 | _LIBCPP_HIDE_FROM_ABI indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v) |
1722 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__ia)) {} |
1723 | |
1724 | # endif // _LIBCPP_CXX03_LANG |
1725 | |
1726 | template <class> |
1727 | friend class valarray; |
1728 | }; |
1729 | |
1730 | template <class _Tp> |
1731 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1732 | inline void indirect_array<_Tp>::operator=(const _Expr& __v) const { |
1733 | size_t __n = __1d_.size(); |
1734 | for (size_t __i = 0; __i < __n; ++__i) |
1735 | __vp_[__1d_[__i]] = __v[__i]; |
1736 | } |
1737 | |
1738 | template <class _Tp> |
1739 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1740 | inline void indirect_array<_Tp>::operator*=(const _Expr& __v) const { |
1741 | size_t __n = __1d_.size(); |
1742 | for (size_t __i = 0; __i < __n; ++__i) |
1743 | __vp_[__1d_[__i]] *= __v[__i]; |
1744 | } |
1745 | |
1746 | template <class _Tp> |
1747 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1748 | inline void indirect_array<_Tp>::operator/=(const _Expr& __v) const { |
1749 | size_t __n = __1d_.size(); |
1750 | for (size_t __i = 0; __i < __n; ++__i) |
1751 | __vp_[__1d_[__i]] /= __v[__i]; |
1752 | } |
1753 | |
1754 | template <class _Tp> |
1755 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1756 | inline void indirect_array<_Tp>::operator%=(const _Expr& __v) const { |
1757 | size_t __n = __1d_.size(); |
1758 | for (size_t __i = 0; __i < __n; ++__i) |
1759 | __vp_[__1d_[__i]] %= __v[__i]; |
1760 | } |
1761 | |
1762 | template <class _Tp> |
1763 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1764 | inline void indirect_array<_Tp>::operator+=(const _Expr& __v) const { |
1765 | size_t __n = __1d_.size(); |
1766 | for (size_t __i = 0; __i < __n; ++__i) |
1767 | __vp_[__1d_[__i]] += __v[__i]; |
1768 | } |
1769 | |
1770 | template <class _Tp> |
1771 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1772 | inline void indirect_array<_Tp>::operator-=(const _Expr& __v) const { |
1773 | size_t __n = __1d_.size(); |
1774 | for (size_t __i = 0; __i < __n; ++__i) |
1775 | __vp_[__1d_[__i]] -= __v[__i]; |
1776 | } |
1777 | |
1778 | template <class _Tp> |
1779 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1780 | inline void indirect_array<_Tp>::operator^=(const _Expr& __v) const { |
1781 | size_t __n = __1d_.size(); |
1782 | for (size_t __i = 0; __i < __n; ++__i) |
1783 | __vp_[__1d_[__i]] ^= __v[__i]; |
1784 | } |
1785 | |
1786 | template <class _Tp> |
1787 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1788 | inline void indirect_array<_Tp>::operator&=(const _Expr& __v) const { |
1789 | size_t __n = __1d_.size(); |
1790 | for (size_t __i = 0; __i < __n; ++__i) |
1791 | __vp_[__1d_[__i]] &= __v[__i]; |
1792 | } |
1793 | |
1794 | template <class _Tp> |
1795 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1796 | inline void indirect_array<_Tp>::operator|=(const _Expr& __v) const { |
1797 | size_t __n = __1d_.size(); |
1798 | for (size_t __i = 0; __i < __n; ++__i) |
1799 | __vp_[__1d_[__i]] |= __v[__i]; |
1800 | } |
1801 | |
1802 | template <class _Tp> |
1803 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1804 | inline void indirect_array<_Tp>::operator<<=(const _Expr& __v) const { |
1805 | size_t __n = __1d_.size(); |
1806 | for (size_t __i = 0; __i < __n; ++__i) |
1807 | __vp_[__1d_[__i]] <<= __v[__i]; |
1808 | } |
1809 | |
1810 | template <class _Tp> |
1811 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
1812 | inline void indirect_array<_Tp>::operator>>=(const _Expr& __v) const { |
1813 | size_t __n = __1d_.size(); |
1814 | for (size_t __i = 0; __i < __n; ++__i) |
1815 | __vp_[__1d_[__i]] >>= __v[__i]; |
1816 | } |
1817 | |
1818 | template <class _Tp> |
1819 | inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const { |
1820 | typedef const size_t* _Ip; |
1821 | const value_type* __s = __ia.__vp_; |
1822 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; __i != __e; ++__i, ++__j) |
1823 | __vp_[*__i] = __s[*__j]; |
1824 | return *this; |
1825 | } |
1826 | |
1827 | template <class _Tp> |
1828 | inline void indirect_array<_Tp>::operator=(const value_type& __x) const { |
1829 | typedef const size_t* _Ip; |
1830 | for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) |
1831 | __vp_[*__i] = __x; |
1832 | } |
1833 | |
1834 | template <class _ValExpr> |
1835 | class __indirect_expr { |
1836 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
1837 | |
1838 | public: |
1839 | typedef typename _RmExpr::value_type value_type; |
1840 | typedef value_type __result_type; |
1841 | |
1842 | private: |
1843 | _ValExpr __expr_; |
1844 | valarray<size_t> __1d_; |
1845 | |
1846 | _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {} |
1847 | |
1848 | # ifndef _LIBCPP_CXX03_LANG |
1849 | |
1850 | _LIBCPP_HIDE_FROM_ABI __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e) |
1851 | : __expr_(__e), __1d_(std::move(__ia)) {} |
1852 | |
1853 | # endif // _LIBCPP_CXX03_LANG |
1854 | |
1855 | public: |
1856 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; } |
1857 | |
1858 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __1d_.size(); } |
1859 | |
1860 | template <class> |
1861 | friend class __val_expr; |
1862 | template <class> |
1863 | friend class valarray; |
1864 | }; |
1865 | |
1866 | template <class _ValExpr> |
1867 | class __val_expr { |
1868 | typedef __libcpp_remove_reference_t<_ValExpr> _RmExpr; |
1869 | |
1870 | _ValExpr __expr_; |
1871 | |
1872 | public: |
1873 | typedef typename _RmExpr::value_type value_type; |
1874 | typedef typename _RmExpr::__result_type __result_type; |
1875 | |
1876 | _LIBCPP_HIDE_FROM_ABI explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} |
1877 | |
1878 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__i]; } |
1879 | |
1880 | _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const { |
1881 | typedef __slice_expr<_ValExpr> _NewExpr; |
1882 | return __val_expr< _NewExpr >(_NewExpr(__s, __expr_)); |
1883 | } |
1884 | |
1885 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const { |
1886 | typedef __indirect_expr<_ValExpr> _NewExpr; |
1887 | return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_)); |
1888 | } |
1889 | |
1890 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const { |
1891 | typedef __mask_expr<_ValExpr> _NewExpr; |
1892 | return __val_expr< _NewExpr >(_NewExpr(__vb, __expr_)); |
1893 | } |
1894 | |
1895 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const { |
1896 | typedef __indirect_expr<_ValExpr> _NewExpr; |
1897 | return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_)); |
1898 | } |
1899 | |
1900 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > operator+() const { |
1901 | typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr; |
1902 | return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_)); |
1903 | } |
1904 | |
1905 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > operator-() const { |
1906 | typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr; |
1907 | return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_)); |
1908 | } |
1909 | |
1910 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > operator~() const { |
1911 | typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr; |
1912 | return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_)); |
1913 | } |
1914 | |
1915 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > operator!() const { |
1916 | typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr; |
1917 | return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_)); |
1918 | } |
1919 | |
1920 | operator valarray<__result_type>() const; |
1921 | |
1922 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __expr_.size(); } |
1923 | |
1924 | _LIBCPP_HIDE_FROM_ABI __result_type sum() const { |
1925 | size_t __n = __expr_.size(); |
1926 | __result_type __r = __n ? __expr_[0] : __result_type(); |
1927 | for (size_t __i = 1; __i < __n; ++__i) |
1928 | __r += __expr_[__i]; |
1929 | return __r; |
1930 | } |
1931 | |
1932 | _LIBCPP_HIDE_FROM_ABI __result_type min() const { |
1933 | size_t __n = size(); |
1934 | __result_type __r = __n ? (*this)[0] : __result_type(); |
1935 | for (size_t __i = 1; __i < __n; ++__i) { |
1936 | __result_type __x = __expr_[__i]; |
1937 | if (__x < __r) |
1938 | __r = __x; |
1939 | } |
1940 | return __r; |
1941 | } |
1942 | |
1943 | _LIBCPP_HIDE_FROM_ABI __result_type max() const { |
1944 | size_t __n = size(); |
1945 | __result_type __r = __n ? (*this)[0] : __result_type(); |
1946 | for (size_t __i = 1; __i < __n; ++__i) { |
1947 | __result_type __x = __expr_[__i]; |
1948 | if (__r < __x) |
1949 | __r = __x; |
1950 | } |
1951 | return __r; |
1952 | } |
1953 | |
1954 | _LIBCPP_HIDE_FROM_ABI __val_expr<__shift_expr<_ValExpr> > shift(int __i) const { |
1955 | return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_)); |
1956 | } |
1957 | |
1958 | _LIBCPP_HIDE_FROM_ABI __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const { |
1959 | return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_)); |
1960 | } |
1961 | |
1962 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(value_type)>, _ValExpr> > |
1963 | apply(value_type __f(value_type)) const { |
1964 | typedef __apply_expr<value_type, value_type (*)(value_type)> _Op; |
1965 | typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
1966 | return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
1967 | } |
1968 | |
1969 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__apply_expr<value_type, value_type (*)(const value_type&)>, _ValExpr> > |
1970 | apply(value_type __f(const value_type&)) const { |
1971 | typedef __apply_expr<value_type, value_type (*)(const value_type&)> _Op; |
1972 | typedef _UnaryOp<_Op, _ValExpr> _NewExpr; |
1973 | return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); |
1974 | } |
1975 | }; |
1976 | |
1977 | template <class _ValExpr> |
1978 | __val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const { |
1979 | valarray<__result_type> __r; |
1980 | size_t __n = __expr_.size(); |
1981 | if (__n) { |
1982 | __r.__begin_ = __r.__end_ = allocator<__result_type>().allocate(__n); |
1983 | for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) |
1984 | ::new ((void*)__r.__end_) __result_type(__expr_[__i]); |
1985 | } |
1986 | return __r; |
1987 | } |
1988 | |
1989 | // valarray |
1990 | |
1991 | template <class _Tp> |
1992 | inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) { |
1993 | if (__n) { |
1994 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
1995 | # if _LIBCPP_HAS_EXCEPTIONS |
1996 | try { |
1997 | # endif // _LIBCPP_HAS_EXCEPTIONS |
1998 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
1999 | ::new ((void*)__end_) value_type(); |
2000 | # if _LIBCPP_HAS_EXCEPTIONS |
2001 | } catch (...) { |
2002 | __clear(capacity: __n); |
2003 | throw; |
2004 | } |
2005 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2006 | } |
2007 | } |
2008 | |
2009 | template <class _Tp> |
2010 | inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(nullptr), __end_(nullptr) { |
2011 | resize(__n, __x); |
2012 | } |
2013 | |
2014 | template <class _Tp> |
2015 | valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) { |
2016 | if (__n) { |
2017 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
2018 | # if _LIBCPP_HAS_EXCEPTIONS |
2019 | try { |
2020 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2021 | for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) |
2022 | ::new ((void*)__end_) value_type(*__p); |
2023 | # if _LIBCPP_HAS_EXCEPTIONS |
2024 | } catch (...) { |
2025 | __clear(capacity: __n); |
2026 | throw; |
2027 | } |
2028 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2029 | } |
2030 | } |
2031 | |
2032 | template <class _Tp> |
2033 | valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) { |
2034 | if (__v.size()) { |
2035 | __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); |
2036 | # if _LIBCPP_HAS_EXCEPTIONS |
2037 | try { |
2038 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2039 | for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) |
2040 | ::new ((void*)__end_) value_type(*__p); |
2041 | # if _LIBCPP_HAS_EXCEPTIONS |
2042 | } catch (...) { |
2043 | __clear(capacity: __v.size()); |
2044 | throw; |
2045 | } |
2046 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2047 | } |
2048 | } |
2049 | |
2050 | # ifndef _LIBCPP_CXX03_LANG |
2051 | |
2052 | template <class _Tp> |
2053 | inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) { |
2054 | __v.__begin_ = __v.__end_ = nullptr; |
2055 | } |
2056 | |
2057 | template <class _Tp> |
2058 | valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr), __end_(nullptr) { |
2059 | const size_t __n = __il.size(); |
2060 | if (__n) { |
2061 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
2062 | # if _LIBCPP_HAS_EXCEPTIONS |
2063 | try { |
2064 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2065 | size_t __n_left = __n; |
2066 | for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) |
2067 | ::new ((void*)__end_) value_type(*__p); |
2068 | # if _LIBCPP_HAS_EXCEPTIONS |
2069 | } catch (...) { |
2070 | __clear(capacity: __n); |
2071 | throw; |
2072 | } |
2073 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2074 | } |
2075 | } |
2076 | |
2077 | # endif // _LIBCPP_CXX03_LANG |
2078 | |
2079 | template <class _Tp> |
2080 | valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) { |
2081 | const size_t __n = __sa.__size_; |
2082 | if (__n) { |
2083 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
2084 | # if _LIBCPP_HAS_EXCEPTIONS |
2085 | try { |
2086 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2087 | size_t __n_left = __n; |
2088 | for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) |
2089 | ::new ((void*)__end_) value_type(*__p); |
2090 | # if _LIBCPP_HAS_EXCEPTIONS |
2091 | } catch (...) { |
2092 | __clear(capacity: __n); |
2093 | throw; |
2094 | } |
2095 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2096 | } |
2097 | } |
2098 | |
2099 | template <class _Tp> |
2100 | valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr), __end_(nullptr) { |
2101 | const size_t __n = __ga.__1d_.size(); |
2102 | if (__n) { |
2103 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
2104 | # if _LIBCPP_HAS_EXCEPTIONS |
2105 | try { |
2106 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2107 | typedef const size_t* _Ip; |
2108 | const value_type* __s = __ga.__vp_; |
2109 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) |
2110 | ::new ((void*)__end_) value_type(__s[*__i]); |
2111 | # if _LIBCPP_HAS_EXCEPTIONS |
2112 | } catch (...) { |
2113 | __clear(capacity: __n); |
2114 | throw; |
2115 | } |
2116 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2117 | } |
2118 | } |
2119 | |
2120 | template <class _Tp> |
2121 | valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), __end_(nullptr) { |
2122 | const size_t __n = __ma.__1d_.size(); |
2123 | if (__n) { |
2124 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
2125 | # if _LIBCPP_HAS_EXCEPTIONS |
2126 | try { |
2127 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2128 | typedef const size_t* _Ip; |
2129 | const value_type* __s = __ma.__vp_; |
2130 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) |
2131 | ::new ((void*)__end_) value_type(__s[*__i]); |
2132 | # if _LIBCPP_HAS_EXCEPTIONS |
2133 | } catch (...) { |
2134 | __clear(capacity: __n); |
2135 | throw; |
2136 | } |
2137 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2138 | } |
2139 | } |
2140 | |
2141 | template <class _Tp> |
2142 | valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullptr), __end_(nullptr) { |
2143 | const size_t __n = __ia.__1d_.size(); |
2144 | if (__n) { |
2145 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
2146 | # if _LIBCPP_HAS_EXCEPTIONS |
2147 | try { |
2148 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2149 | typedef const size_t* _Ip; |
2150 | const value_type* __s = __ia.__vp_; |
2151 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) |
2152 | ::new ((void*)__end_) value_type(__s[*__i]); |
2153 | # if _LIBCPP_HAS_EXCEPTIONS |
2154 | } catch (...) { |
2155 | __clear(capacity: __n); |
2156 | throw; |
2157 | } |
2158 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2159 | } |
2160 | } |
2161 | |
2162 | template <class _Tp> |
2163 | inline valarray<_Tp>::~valarray() { |
2164 | __clear(capacity: size()); |
2165 | } |
2166 | |
2167 | template <class _Tp> |
2168 | valarray<_Tp>& valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) { |
2169 | size_t __n = __l - __f; |
2170 | if (size() != __n) { |
2171 | __clear(capacity: size()); |
2172 | __begin_ = allocator<value_type>().allocate(__n); |
2173 | __end_ = __begin_ + __n; |
2174 | std::uninitialized_copy(__f, __l, __begin_); |
2175 | } else { |
2176 | std::copy(__f, __l, __begin_); |
2177 | } |
2178 | return *this; |
2179 | } |
2180 | |
2181 | template <class _Tp> |
2182 | valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) { |
2183 | if (this != std::addressof(__v)) |
2184 | return __assign_range(f: __v.__begin_, l: __v.__end_); |
2185 | return *this; |
2186 | } |
2187 | |
2188 | # ifndef _LIBCPP_CXX03_LANG |
2189 | |
2190 | template <class _Tp> |
2191 | inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT { |
2192 | __clear(capacity: size()); |
2193 | __begin_ = __v.__begin_; |
2194 | __end_ = __v.__end_; |
2195 | __v.__begin_ = nullptr; |
2196 | __v.__end_ = nullptr; |
2197 | return *this; |
2198 | } |
2199 | |
2200 | template <class _Tp> |
2201 | inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list<value_type> __il) { |
2202 | return __assign_range(f: __il.begin(), l: __il.end()); |
2203 | } |
2204 | |
2205 | # endif // _LIBCPP_CXX03_LANG |
2206 | |
2207 | template <class _Tp> |
2208 | inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) { |
2209 | std::fill(__begin_, __end_, __x); |
2210 | return *this; |
2211 | } |
2212 | |
2213 | template <class _Tp> |
2214 | inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<value_type>& __sa) { |
2215 | value_type* __t = __begin_; |
2216 | const value_type* __s = __sa.__vp_; |
2217 | for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t) |
2218 | *__t = *__s; |
2219 | return *this; |
2220 | } |
2221 | |
2222 | template <class _Tp> |
2223 | inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) { |
2224 | typedef const size_t* _Ip; |
2225 | value_type* __t = __begin_; |
2226 | const value_type* __s = __ga.__vp_; |
2227 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__t) |
2228 | *__t = __s[*__i]; |
2229 | return *this; |
2230 | } |
2231 | |
2232 | template <class _Tp> |
2233 | inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<value_type>& __ma) { |
2234 | typedef const size_t* _Ip; |
2235 | value_type* __t = __begin_; |
2236 | const value_type* __s = __ma.__vp_; |
2237 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__t) |
2238 | *__t = __s[*__i]; |
2239 | return *this; |
2240 | } |
2241 | |
2242 | template <class _Tp> |
2243 | inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) { |
2244 | typedef const size_t* _Ip; |
2245 | value_type* __t = __begin_; |
2246 | const value_type* __s = __ia.__vp_; |
2247 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__t) |
2248 | *__t = __s[*__i]; |
2249 | return *this; |
2250 | } |
2251 | |
2252 | template <class _Tp> |
2253 | template <class _ValExpr> |
2254 | inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) { |
2255 | size_t __n = __v.size(); |
2256 | if (size() != __n) |
2257 | resize(__n); |
2258 | value_type* __t = __begin_; |
2259 | for (size_t __i = 0; __i != __n; ++__t, ++__i) |
2260 | *__t = __result_type(__v[__i]); |
2261 | return *this; |
2262 | } |
2263 | |
2264 | template <class _Tp> |
2265 | inline __val_expr<__slice_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](slice __s) const { |
2266 | return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this)); |
2267 | } |
2268 | |
2269 | template <class _Tp> |
2270 | inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) { |
2271 | return slice_array<value_type>(__s, *this); |
2272 | } |
2273 | |
2274 | template <class _Tp> |
2275 | inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const gslice& __gs) const { |
2276 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this)); |
2277 | } |
2278 | |
2279 | template <class _Tp> |
2280 | inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) { |
2281 | return gslice_array<value_type>(__gs, *this); |
2282 | } |
2283 | |
2284 | # ifndef _LIBCPP_CXX03_LANG |
2285 | |
2286 | template <class _Tp> |
2287 | inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](gslice&& __gs) const { |
2288 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this)); |
2289 | } |
2290 | |
2291 | template <class _Tp> |
2292 | inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) { |
2293 | return gslice_array<value_type>(std::move(__gs), *this); |
2294 | } |
2295 | |
2296 | # endif // _LIBCPP_CXX03_LANG |
2297 | |
2298 | template <class _Tp> |
2299 | inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const { |
2300 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this)); |
2301 | } |
2302 | |
2303 | template <class _Tp> |
2304 | inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) { |
2305 | return mask_array<value_type>(__vb, *this); |
2306 | } |
2307 | |
2308 | # ifndef _LIBCPP_CXX03_LANG |
2309 | |
2310 | template <class _Tp> |
2311 | inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<bool>&& __vb) const { |
2312 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this)); |
2313 | } |
2314 | |
2315 | template <class _Tp> |
2316 | inline mask_array<_Tp> valarray<_Tp>::operator[](valarray<bool>&& __vb) { |
2317 | return mask_array<value_type>(std::move(__vb), *this); |
2318 | } |
2319 | |
2320 | # endif // _LIBCPP_CXX03_LANG |
2321 | |
2322 | template <class _Tp> |
2323 | inline __val_expr<__indirect_expr<const valarray<_Tp>&> > |
2324 | valarray<_Tp>::operator[](const valarray<size_t>& __vs) const { |
2325 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this)); |
2326 | } |
2327 | |
2328 | template <class _Tp> |
2329 | inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __vs) { |
2330 | return indirect_array<value_type>(__vs, *this); |
2331 | } |
2332 | |
2333 | # ifndef _LIBCPP_CXX03_LANG |
2334 | |
2335 | template <class _Tp> |
2336 | inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<size_t>&& __vs) const { |
2337 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this)); |
2338 | } |
2339 | |
2340 | template <class _Tp> |
2341 | inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray<size_t>&& __vs) { |
2342 | return indirect_array<value_type>(std::move(__vs), *this); |
2343 | } |
2344 | |
2345 | # endif // _LIBCPP_CXX03_LANG |
2346 | |
2347 | template <class _Tp> |
2348 | inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const { |
2349 | using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>; |
2350 | return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this)); |
2351 | } |
2352 | |
2353 | template <class _Tp> |
2354 | inline __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator-() const { |
2355 | using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>; |
2356 | return __val_expr<_Op>(_Op(negate<_Tp>(), *this)); |
2357 | } |
2358 | |
2359 | template <class _Tp> |
2360 | inline __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator~() const { |
2361 | using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>; |
2362 | return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this)); |
2363 | } |
2364 | |
2365 | template <class _Tp> |
2366 | inline __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator!() const { |
2367 | using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>; |
2368 | return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this)); |
2369 | } |
2370 | |
2371 | template <class _Tp> |
2372 | inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) { |
2373 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2374 | *__p *= __x; |
2375 | return *this; |
2376 | } |
2377 | |
2378 | template <class _Tp> |
2379 | inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) { |
2380 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2381 | *__p /= __x; |
2382 | return *this; |
2383 | } |
2384 | |
2385 | template <class _Tp> |
2386 | inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) { |
2387 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2388 | *__p %= __x; |
2389 | return *this; |
2390 | } |
2391 | |
2392 | template <class _Tp> |
2393 | inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) { |
2394 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2395 | *__p += __x; |
2396 | return *this; |
2397 | } |
2398 | |
2399 | template <class _Tp> |
2400 | inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) { |
2401 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2402 | *__p -= __x; |
2403 | return *this; |
2404 | } |
2405 | |
2406 | template <class _Tp> |
2407 | inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) { |
2408 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2409 | *__p ^= __x; |
2410 | return *this; |
2411 | } |
2412 | |
2413 | template <class _Tp> |
2414 | inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) { |
2415 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2416 | *__p &= __x; |
2417 | return *this; |
2418 | } |
2419 | |
2420 | template <class _Tp> |
2421 | inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) { |
2422 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2423 | *__p |= __x; |
2424 | return *this; |
2425 | } |
2426 | |
2427 | template <class _Tp> |
2428 | inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) { |
2429 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2430 | *__p <<= __x; |
2431 | return *this; |
2432 | } |
2433 | |
2434 | template <class _Tp> |
2435 | inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) { |
2436 | for (value_type* __p = __begin_; __p != __end_; ++__p) |
2437 | *__p >>= __x; |
2438 | return *this; |
2439 | } |
2440 | |
2441 | template <class _Tp> |
2442 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2443 | inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) { |
2444 | size_t __i = 0; |
2445 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2446 | *__t *= std::__get(__v, __i); |
2447 | return *this; |
2448 | } |
2449 | |
2450 | template <class _Tp> |
2451 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2452 | inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) { |
2453 | size_t __i = 0; |
2454 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2455 | *__t /= std::__get(__v, __i); |
2456 | return *this; |
2457 | } |
2458 | |
2459 | template <class _Tp> |
2460 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2461 | inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) { |
2462 | size_t __i = 0; |
2463 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2464 | *__t %= std::__get(__v, __i); |
2465 | return *this; |
2466 | } |
2467 | |
2468 | template <class _Tp> |
2469 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2470 | inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) { |
2471 | size_t __i = 0; |
2472 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2473 | *__t += std::__get(__v, __i); |
2474 | return *this; |
2475 | } |
2476 | |
2477 | template <class _Tp> |
2478 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2479 | inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) { |
2480 | size_t __i = 0; |
2481 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2482 | *__t -= std::__get(__v, __i); |
2483 | return *this; |
2484 | } |
2485 | |
2486 | template <class _Tp> |
2487 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2488 | inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) { |
2489 | size_t __i = 0; |
2490 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2491 | *__t ^= std::__get(__v, __i); |
2492 | return *this; |
2493 | } |
2494 | |
2495 | template <class _Tp> |
2496 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2497 | inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) { |
2498 | size_t __i = 0; |
2499 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2500 | *__t |= std::__get(__v, __i); |
2501 | return *this; |
2502 | } |
2503 | |
2504 | template <class _Tp> |
2505 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2506 | inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) { |
2507 | size_t __i = 0; |
2508 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2509 | *__t &= std::__get(__v, __i); |
2510 | return *this; |
2511 | } |
2512 | |
2513 | template <class _Tp> |
2514 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2515 | inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) { |
2516 | size_t __i = 0; |
2517 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2518 | *__t <<= std::__get(__v, __i); |
2519 | return *this; |
2520 | } |
2521 | |
2522 | template <class _Tp> |
2523 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > |
2524 | inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) { |
2525 | size_t __i = 0; |
2526 | for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i) |
2527 | *__t >>= std::__get(__v, __i); |
2528 | return *this; |
2529 | } |
2530 | |
2531 | template <class _Tp> |
2532 | inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT { |
2533 | std::swap(__begin_, __v.__begin_); |
2534 | std::swap(__end_, __v.__end_); |
2535 | } |
2536 | |
2537 | template <class _Tp> |
2538 | inline _Tp valarray<_Tp>::sum() const { |
2539 | if (__begin_ == __end_) |
2540 | return value_type(); |
2541 | const value_type* __p = __begin_; |
2542 | _Tp __r = *__p; |
2543 | for (++__p; __p != __end_; ++__p) |
2544 | __r += *__p; |
2545 | return __r; |
2546 | } |
2547 | |
2548 | template <class _Tp> |
2549 | inline _Tp valarray<_Tp>::min() const { |
2550 | if (__begin_ == __end_) |
2551 | return value_type(); |
2552 | return *std::min_element(__begin_, __end_); |
2553 | } |
2554 | |
2555 | template <class _Tp> |
2556 | inline _Tp valarray<_Tp>::max() const { |
2557 | if (__begin_ == __end_) |
2558 | return value_type(); |
2559 | return *std::max_element(__begin_, __end_); |
2560 | } |
2561 | |
2562 | template <class _Tp> |
2563 | valarray<_Tp> valarray<_Tp>::shift(int __i) const { |
2564 | valarray<value_type> __r; |
2565 | size_t __n = size(); |
2566 | if (__n) { |
2567 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
2568 | const value_type* __sb; |
2569 | value_type* __tb; |
2570 | value_type* __te; |
2571 | if (__i >= 0) { |
2572 | __i = std::min(a: __i, b: static_cast<int>(__n)); |
2573 | __sb = __begin_ + __i; |
2574 | __tb = __r.__begin_; |
2575 | __te = __r.__begin_ + (__n - __i); |
2576 | } else { |
2577 | __i = std::min(a: -__i, b: static_cast<int>(__n)); |
2578 | __sb = __begin_; |
2579 | __tb = __r.__begin_ + __i; |
2580 | __te = __r.__begin_ + __n; |
2581 | } |
2582 | for (; __r.__end_ != __tb; ++__r.__end_) |
2583 | ::new ((void*)__r.__end_) value_type(); |
2584 | for (; __r.__end_ != __te; ++__r.__end_, ++__sb) |
2585 | ::new ((void*)__r.__end_) value_type(*__sb); |
2586 | for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_) |
2587 | ::new ((void*)__r.__end_) value_type(); |
2588 | } |
2589 | return __r; |
2590 | } |
2591 | |
2592 | template <class _Tp> |
2593 | valarray<_Tp> valarray<_Tp>::cshift(int __i) const { |
2594 | valarray<value_type> __r; |
2595 | size_t __n = size(); |
2596 | if (__n) { |
2597 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
2598 | __i %= static_cast<int>(__n); |
2599 | const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; |
2600 | for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) |
2601 | ::new ((void*)__r.__end_) value_type(*__s); |
2602 | for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s) |
2603 | ::new ((void*)__r.__end_) value_type(*__s); |
2604 | } |
2605 | return __r; |
2606 | } |
2607 | |
2608 | template <class _Tp> |
2609 | valarray<_Tp> valarray<_Tp>::apply(value_type __f(value_type)) const { |
2610 | valarray<value_type> __r; |
2611 | size_t __n = size(); |
2612 | if (__n) { |
2613 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
2614 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
2615 | ::new ((void*)__r.__end_) value_type(__f(*__p)); |
2616 | } |
2617 | return __r; |
2618 | } |
2619 | |
2620 | template <class _Tp> |
2621 | valarray<_Tp> valarray<_Tp>::apply(value_type __f(const value_type&)) const { |
2622 | valarray<value_type> __r; |
2623 | size_t __n = size(); |
2624 | if (__n) { |
2625 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); |
2626 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) |
2627 | ::new ((void*)__r.__end_) value_type(__f(*__p)); |
2628 | } |
2629 | return __r; |
2630 | } |
2631 | |
2632 | template <class _Tp> |
2633 | inline void valarray<_Tp>::__clear(size_t __capacity) { |
2634 | if (__begin_ != nullptr) { |
2635 | while (__end_ != __begin_) |
2636 | (--__end_)->~value_type(); |
2637 | allocator<value_type>().deallocate(__begin_, __capacity); |
2638 | __begin_ = __end_ = nullptr; |
2639 | } |
2640 | } |
2641 | |
2642 | template <class _Tp> |
2643 | void valarray<_Tp>::resize(size_t __n, value_type __x) { |
2644 | __clear(capacity: size()); |
2645 | if (__n) { |
2646 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
2647 | # if _LIBCPP_HAS_EXCEPTIONS |
2648 | try { |
2649 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2650 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
2651 | ::new ((void*)__end_) value_type(__x); |
2652 | # if _LIBCPP_HAS_EXCEPTIONS |
2653 | } catch (...) { |
2654 | __clear(capacity: __n); |
2655 | throw; |
2656 | } |
2657 | # endif // _LIBCPP_HAS_EXCEPTIONS |
2658 | } |
2659 | } |
2660 | |
2661 | template <class _Tp> |
2662 | inline _LIBCPP_HIDE_FROM_ABI void swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT { |
2663 | __x.swap(__y); |
2664 | } |
2665 | |
2666 | template <class _Expr1, |
2667 | class _Expr2, |
2668 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2669 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2670 | operator*(const _Expr1& __x, const _Expr2& __y) { |
2671 | typedef typename _Expr1::value_type value_type; |
2672 | typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op; |
2673 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y)); |
2674 | } |
2675 | |
2676 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2677 | inline _LIBCPP_HIDE_FROM_ABI |
2678 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2679 | operator*(const _Expr& __x, const typename _Expr::value_type& __y) { |
2680 | typedef typename _Expr::value_type value_type; |
2681 | typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2682 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2683 | } |
2684 | |
2685 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2686 | inline _LIBCPP_HIDE_FROM_ABI |
2687 | __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2688 | operator*(const typename _Expr::value_type& __x, const _Expr& __y) { |
2689 | typedef typename _Expr::value_type value_type; |
2690 | typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2691 | return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2692 | } |
2693 | |
2694 | template <class _Expr1, |
2695 | class _Expr2, |
2696 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2697 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2698 | operator/(const _Expr1& __x, const _Expr2& __y) { |
2699 | typedef typename _Expr1::value_type value_type; |
2700 | typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op; |
2701 | return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y)); |
2702 | } |
2703 | |
2704 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2705 | inline _LIBCPP_HIDE_FROM_ABI |
2706 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2707 | operator/(const _Expr& __x, const typename _Expr::value_type& __y) { |
2708 | typedef typename _Expr::value_type value_type; |
2709 | typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2710 | return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2711 | } |
2712 | |
2713 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2714 | inline _LIBCPP_HIDE_FROM_ABI |
2715 | __val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2716 | operator/(const typename _Expr::value_type& __x, const _Expr& __y) { |
2717 | typedef typename _Expr::value_type value_type; |
2718 | typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2719 | return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2720 | } |
2721 | |
2722 | template <class _Expr1, |
2723 | class _Expr2, |
2724 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2725 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2726 | operator%(const _Expr1& __x, const _Expr2& __y) { |
2727 | typedef typename _Expr1::value_type value_type; |
2728 | typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op; |
2729 | return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y)); |
2730 | } |
2731 | |
2732 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2733 | inline _LIBCPP_HIDE_FROM_ABI |
2734 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2735 | operator%(const _Expr& __x, const typename _Expr::value_type& __y) { |
2736 | typedef typename _Expr::value_type value_type; |
2737 | typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2738 | return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2739 | } |
2740 | |
2741 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2742 | inline _LIBCPP_HIDE_FROM_ABI |
2743 | __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2744 | operator%(const typename _Expr::value_type& __x, const _Expr& __y) { |
2745 | typedef typename _Expr::value_type value_type; |
2746 | typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2747 | return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2748 | } |
2749 | |
2750 | template <class _Expr1, |
2751 | class _Expr2, |
2752 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2753 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2754 | operator+(const _Expr1& __x, const _Expr2& __y) { |
2755 | typedef typename _Expr1::value_type value_type; |
2756 | typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op; |
2757 | return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y)); |
2758 | } |
2759 | |
2760 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2761 | inline _LIBCPP_HIDE_FROM_ABI |
2762 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2763 | operator+(const _Expr& __x, const typename _Expr::value_type& __y) { |
2764 | typedef typename _Expr::value_type value_type; |
2765 | typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2766 | return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2767 | } |
2768 | |
2769 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2770 | inline _LIBCPP_HIDE_FROM_ABI |
2771 | __val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2772 | operator+(const typename _Expr::value_type& __x, const _Expr& __y) { |
2773 | typedef typename _Expr::value_type value_type; |
2774 | typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2775 | return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2776 | } |
2777 | |
2778 | template <class _Expr1, |
2779 | class _Expr2, |
2780 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2781 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2782 | operator-(const _Expr1& __x, const _Expr2& __y) { |
2783 | typedef typename _Expr1::value_type value_type; |
2784 | typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op; |
2785 | return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y)); |
2786 | } |
2787 | |
2788 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2789 | inline _LIBCPP_HIDE_FROM_ABI |
2790 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2791 | operator-(const _Expr& __x, const typename _Expr::value_type& __y) { |
2792 | typedef typename _Expr::value_type value_type; |
2793 | typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2794 | return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2795 | } |
2796 | |
2797 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2798 | inline _LIBCPP_HIDE_FROM_ABI |
2799 | __val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2800 | operator-(const typename _Expr::value_type& __x, const _Expr& __y) { |
2801 | typedef typename _Expr::value_type value_type; |
2802 | typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2803 | return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2804 | } |
2805 | |
2806 | template <class _Expr1, |
2807 | class _Expr2, |
2808 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2809 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2810 | operator^(const _Expr1& __x, const _Expr2& __y) { |
2811 | typedef typename _Expr1::value_type value_type; |
2812 | typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op; |
2813 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y)); |
2814 | } |
2815 | |
2816 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2817 | inline _LIBCPP_HIDE_FROM_ABI |
2818 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2819 | operator^(const _Expr& __x, const typename _Expr::value_type& __y) { |
2820 | typedef typename _Expr::value_type value_type; |
2821 | typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2822 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2823 | } |
2824 | |
2825 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2826 | inline _LIBCPP_HIDE_FROM_ABI |
2827 | __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2828 | operator^(const typename _Expr::value_type& __x, const _Expr& __y) { |
2829 | typedef typename _Expr::value_type value_type; |
2830 | typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2831 | return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2832 | } |
2833 | |
2834 | template <class _Expr1, |
2835 | class _Expr2, |
2836 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2837 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2838 | operator&(const _Expr1& __x, const _Expr2& __y) { |
2839 | typedef typename _Expr1::value_type value_type; |
2840 | typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op; |
2841 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y)); |
2842 | } |
2843 | |
2844 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2845 | inline _LIBCPP_HIDE_FROM_ABI |
2846 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2847 | operator&(const _Expr& __x, const typename _Expr::value_type& __y) { |
2848 | typedef typename _Expr::value_type value_type; |
2849 | typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2850 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2851 | } |
2852 | |
2853 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2854 | inline _LIBCPP_HIDE_FROM_ABI |
2855 | __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2856 | operator&(const typename _Expr::value_type& __x, const _Expr& __y) { |
2857 | typedef typename _Expr::value_type value_type; |
2858 | typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2859 | return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2860 | } |
2861 | |
2862 | template <class _Expr1, |
2863 | class _Expr2, |
2864 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2865 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2866 | operator|(const _Expr1& __x, const _Expr2& __y) { |
2867 | typedef typename _Expr1::value_type value_type; |
2868 | typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op; |
2869 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y)); |
2870 | } |
2871 | |
2872 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2873 | inline _LIBCPP_HIDE_FROM_ABI |
2874 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2875 | operator|(const _Expr& __x, const typename _Expr::value_type& __y) { |
2876 | typedef typename _Expr::value_type value_type; |
2877 | typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2878 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2879 | } |
2880 | |
2881 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2882 | inline _LIBCPP_HIDE_FROM_ABI |
2883 | __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2884 | operator|(const typename _Expr::value_type& __x, const _Expr& __y) { |
2885 | typedef typename _Expr::value_type value_type; |
2886 | typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2887 | return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2888 | } |
2889 | |
2890 | template <class _Expr1, |
2891 | class _Expr2, |
2892 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2893 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2894 | operator<<(const _Expr1& __x, const _Expr2& __y) { |
2895 | typedef typename _Expr1::value_type value_type; |
2896 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op; |
2897 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y)); |
2898 | } |
2899 | |
2900 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2901 | inline _LIBCPP_HIDE_FROM_ABI |
2902 | __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2903 | operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { |
2904 | typedef typename _Expr::value_type value_type; |
2905 | typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2906 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2907 | } |
2908 | |
2909 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2910 | inline _LIBCPP_HIDE_FROM_ABI |
2911 | __val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2912 | operator<<(const typename _Expr::value_type& __x, const _Expr& __y) { |
2913 | typedef typename _Expr::value_type value_type; |
2914 | typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2915 | return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2916 | } |
2917 | |
2918 | template <class _Expr1, |
2919 | class _Expr2, |
2920 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2921 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2922 | operator>>(const _Expr1& __x, const _Expr2& __y) { |
2923 | typedef typename _Expr1::value_type value_type; |
2924 | typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op; |
2925 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y)); |
2926 | } |
2927 | |
2928 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2929 | inline _LIBCPP_HIDE_FROM_ABI __val_expr< |
2930 | _BinaryOp<__bit_shift_right<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2931 | operator>>(const _Expr& __x, const typename _Expr::value_type& __y) { |
2932 | typedef typename _Expr::value_type value_type; |
2933 | typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2934 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2935 | } |
2936 | |
2937 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2938 | inline _LIBCPP_HIDE_FROM_ABI |
2939 | __val_expr< _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2940 | operator>>(const typename _Expr::value_type& __x, const _Expr& __y) { |
2941 | typedef typename _Expr::value_type value_type; |
2942 | typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2943 | return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2944 | } |
2945 | |
2946 | template <class _Expr1, |
2947 | class _Expr2, |
2948 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2949 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2950 | operator&&(const _Expr1& __x, const _Expr2& __y) { |
2951 | typedef typename _Expr1::value_type value_type; |
2952 | typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op; |
2953 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y)); |
2954 | } |
2955 | |
2956 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2957 | inline _LIBCPP_HIDE_FROM_ABI |
2958 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2959 | operator&&(const _Expr& __x, const typename _Expr::value_type& __y) { |
2960 | typedef typename _Expr::value_type value_type; |
2961 | typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2962 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2963 | } |
2964 | |
2965 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2966 | inline _LIBCPP_HIDE_FROM_ABI |
2967 | __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2968 | operator&&(const typename _Expr::value_type& __x, const _Expr& __y) { |
2969 | typedef typename _Expr::value_type value_type; |
2970 | typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2971 | return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
2972 | } |
2973 | |
2974 | template <class _Expr1, |
2975 | class _Expr2, |
2976 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
2977 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > |
2978 | operator||(const _Expr1& __x, const _Expr2& __y) { |
2979 | typedef typename _Expr1::value_type value_type; |
2980 | typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op; |
2981 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y)); |
2982 | } |
2983 | |
2984 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2985 | inline _LIBCPP_HIDE_FROM_ABI |
2986 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
2987 | operator||(const _Expr& __x, const typename _Expr::value_type& __y) { |
2988 | typedef typename _Expr::value_type value_type; |
2989 | typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
2990 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
2991 | } |
2992 | |
2993 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
2994 | inline _LIBCPP_HIDE_FROM_ABI |
2995 | __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
2996 | operator||(const typename _Expr::value_type& __x, const _Expr& __y) { |
2997 | typedef typename _Expr::value_type value_type; |
2998 | typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
2999 | return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3000 | } |
3001 | |
3002 | template <class _Expr1, |
3003 | class _Expr2, |
3004 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3005 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3006 | operator==(const _Expr1& __x, const _Expr2& __y) { |
3007 | typedef typename _Expr1::value_type value_type; |
3008 | typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op; |
3009 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y)); |
3010 | } |
3011 | |
3012 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3013 | inline _LIBCPP_HIDE_FROM_ABI |
3014 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3015 | operator==(const _Expr& __x, const typename _Expr::value_type& __y) { |
3016 | typedef typename _Expr::value_type value_type; |
3017 | typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3018 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3019 | } |
3020 | |
3021 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3022 | inline _LIBCPP_HIDE_FROM_ABI |
3023 | __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3024 | operator==(const typename _Expr::value_type& __x, const _Expr& __y) { |
3025 | typedef typename _Expr::value_type value_type; |
3026 | typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3027 | return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3028 | } |
3029 | |
3030 | template <class _Expr1, |
3031 | class _Expr2, |
3032 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3033 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3034 | operator!=(const _Expr1& __x, const _Expr2& __y) { |
3035 | typedef typename _Expr1::value_type value_type; |
3036 | typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op; |
3037 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y)); |
3038 | } |
3039 | |
3040 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3041 | inline _LIBCPP_HIDE_FROM_ABI |
3042 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3043 | operator!=(const _Expr& __x, const typename _Expr::value_type& __y) { |
3044 | typedef typename _Expr::value_type value_type; |
3045 | typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3046 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3047 | } |
3048 | |
3049 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3050 | inline _LIBCPP_HIDE_FROM_ABI |
3051 | __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3052 | operator!=(const typename _Expr::value_type& __x, const _Expr& __y) { |
3053 | typedef typename _Expr::value_type value_type; |
3054 | typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3055 | return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3056 | } |
3057 | |
3058 | template <class _Expr1, |
3059 | class _Expr2, |
3060 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3061 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3062 | operator<(const _Expr1& __x, const _Expr2& __y) { |
3063 | typedef typename _Expr1::value_type value_type; |
3064 | typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op; |
3065 | return __val_expr<_Op>(_Op(less<value_type>(), __x, __y)); |
3066 | } |
3067 | |
3068 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3069 | inline _LIBCPP_HIDE_FROM_ABI |
3070 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3071 | operator<(const _Expr& __x, const typename _Expr::value_type& __y) { |
3072 | typedef typename _Expr::value_type value_type; |
3073 | typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3074 | return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3075 | } |
3076 | |
3077 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3078 | inline _LIBCPP_HIDE_FROM_ABI |
3079 | __val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3080 | operator<(const typename _Expr::value_type& __x, const _Expr& __y) { |
3081 | typedef typename _Expr::value_type value_type; |
3082 | typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3083 | return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3084 | } |
3085 | |
3086 | template <class _Expr1, |
3087 | class _Expr2, |
3088 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3089 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3090 | operator>(const _Expr1& __x, const _Expr2& __y) { |
3091 | typedef typename _Expr1::value_type value_type; |
3092 | typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op; |
3093 | return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y)); |
3094 | } |
3095 | |
3096 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3097 | inline _LIBCPP_HIDE_FROM_ABI |
3098 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3099 | operator>(const _Expr& __x, const typename _Expr::value_type& __y) { |
3100 | typedef typename _Expr::value_type value_type; |
3101 | typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3102 | return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3103 | } |
3104 | |
3105 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3106 | inline _LIBCPP_HIDE_FROM_ABI |
3107 | __val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3108 | operator>(const typename _Expr::value_type& __x, const _Expr& __y) { |
3109 | typedef typename _Expr::value_type value_type; |
3110 | typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3111 | return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3112 | } |
3113 | |
3114 | template <class _Expr1, |
3115 | class _Expr2, |
3116 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3117 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3118 | operator<=(const _Expr1& __x, const _Expr2& __y) { |
3119 | typedef typename _Expr1::value_type value_type; |
3120 | typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op; |
3121 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y)); |
3122 | } |
3123 | |
3124 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3125 | inline _LIBCPP_HIDE_FROM_ABI |
3126 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3127 | operator<=(const _Expr& __x, const typename _Expr::value_type& __y) { |
3128 | typedef typename _Expr::value_type value_type; |
3129 | typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3130 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3131 | } |
3132 | |
3133 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3134 | inline _LIBCPP_HIDE_FROM_ABI |
3135 | __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3136 | operator<=(const typename _Expr::value_type& __x, const _Expr& __y) { |
3137 | typedef typename _Expr::value_type value_type; |
3138 | typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3139 | return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3140 | } |
3141 | |
3142 | template <class _Expr1, |
3143 | class _Expr2, |
3144 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3145 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3146 | operator>=(const _Expr1& __x, const _Expr2& __y) { |
3147 | typedef typename _Expr1::value_type value_type; |
3148 | typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op; |
3149 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y)); |
3150 | } |
3151 | |
3152 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3153 | inline _LIBCPP_HIDE_FROM_ABI |
3154 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3155 | operator>=(const _Expr& __x, const typename _Expr::value_type& __y) { |
3156 | typedef typename _Expr::value_type value_type; |
3157 | typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3158 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3159 | } |
3160 | |
3161 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3162 | inline _LIBCPP_HIDE_FROM_ABI |
3163 | __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3164 | operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { |
3165 | typedef typename _Expr::value_type value_type; |
3166 | typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3167 | return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3168 | } |
3169 | |
3170 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3171 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > |
3172 | abs(const _Expr& __x) { |
3173 | typedef typename _Expr::value_type value_type; |
3174 | typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; |
3175 | return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x)); |
3176 | } |
3177 | |
3178 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3179 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > |
3180 | acos(const _Expr& __x) { |
3181 | typedef typename _Expr::value_type value_type; |
3182 | typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; |
3183 | return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x)); |
3184 | } |
3185 | |
3186 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3187 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > |
3188 | asin(const _Expr& __x) { |
3189 | typedef typename _Expr::value_type value_type; |
3190 | typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; |
3191 | return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x)); |
3192 | } |
3193 | |
3194 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3195 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > |
3196 | atan(const _Expr& __x) { |
3197 | typedef typename _Expr::value_type value_type; |
3198 | typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; |
3199 | return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x)); |
3200 | } |
3201 | |
3202 | template <class _Expr1, |
3203 | class _Expr2, |
3204 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3205 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3206 | atan2(const _Expr1& __x, const _Expr2& __y) { |
3207 | typedef typename _Expr1::value_type value_type; |
3208 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; |
3209 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); |
3210 | } |
3211 | |
3212 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3213 | inline _LIBCPP_HIDE_FROM_ABI |
3214 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3215 | atan2(const _Expr& __x, const typename _Expr::value_type& __y) { |
3216 | typedef typename _Expr::value_type value_type; |
3217 | typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3218 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3219 | } |
3220 | |
3221 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3222 | inline _LIBCPP_HIDE_FROM_ABI |
3223 | __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3224 | atan2(const typename _Expr::value_type& __x, const _Expr& __y) { |
3225 | typedef typename _Expr::value_type value_type; |
3226 | typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3227 | return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3228 | } |
3229 | |
3230 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3231 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > |
3232 | cos(const _Expr& __x) { |
3233 | typedef typename _Expr::value_type value_type; |
3234 | typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; |
3235 | return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x)); |
3236 | } |
3237 | |
3238 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3239 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > |
3240 | cosh(const _Expr& __x) { |
3241 | typedef typename _Expr::value_type value_type; |
3242 | typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; |
3243 | return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x)); |
3244 | } |
3245 | |
3246 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3247 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > |
3248 | exp(const _Expr& __x) { |
3249 | typedef typename _Expr::value_type value_type; |
3250 | typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; |
3251 | return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x)); |
3252 | } |
3253 | |
3254 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3255 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > |
3256 | log(const _Expr& __x) { |
3257 | typedef typename _Expr::value_type value_type; |
3258 | typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; |
3259 | return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x)); |
3260 | } |
3261 | |
3262 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3263 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > |
3264 | log10(const _Expr& __x) { |
3265 | typedef typename _Expr::value_type value_type; |
3266 | typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; |
3267 | return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x)); |
3268 | } |
3269 | |
3270 | template <class _Expr1, |
3271 | class _Expr2, |
3272 | __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> |
3273 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > |
3274 | pow(const _Expr1& __x, const _Expr2& __y) { |
3275 | typedef typename _Expr1::value_type value_type; |
3276 | typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; |
3277 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); |
3278 | } |
3279 | |
3280 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3281 | inline _LIBCPP_HIDE_FROM_ABI |
3282 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > |
3283 | pow(const _Expr& __x, const typename _Expr::value_type& __y) { |
3284 | typedef typename _Expr::value_type value_type; |
3285 | typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; |
3286 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size()))); |
3287 | } |
3288 | |
3289 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3290 | inline _LIBCPP_HIDE_FROM_ABI |
3291 | __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > |
3292 | pow(const typename _Expr::value_type& __x, const _Expr& __y) { |
3293 | typedef typename _Expr::value_type value_type; |
3294 | typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; |
3295 | return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y)); |
3296 | } |
3297 | |
3298 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3299 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > |
3300 | sin(const _Expr& __x) { |
3301 | typedef typename _Expr::value_type value_type; |
3302 | typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; |
3303 | return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x)); |
3304 | } |
3305 | |
3306 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3307 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > |
3308 | sinh(const _Expr& __x) { |
3309 | typedef typename _Expr::value_type value_type; |
3310 | typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; |
3311 | return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x)); |
3312 | } |
3313 | |
3314 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3315 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > |
3316 | sqrt(const _Expr& __x) { |
3317 | typedef typename _Expr::value_type value_type; |
3318 | typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; |
3319 | return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x)); |
3320 | } |
3321 | |
3322 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3323 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > |
3324 | tan(const _Expr& __x) { |
3325 | typedef typename _Expr::value_type value_type; |
3326 | typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; |
3327 | return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x)); |
3328 | } |
3329 | |
3330 | template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> |
3331 | inline _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > |
3332 | tanh(const _Expr& __x) { |
3333 | typedef typename _Expr::value_type value_type; |
3334 | typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; |
3335 | return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x)); |
3336 | } |
3337 | |
3338 | template <class _Tp> |
3339 | inline _LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v) { |
3340 | return __v.__begin_; |
3341 | } |
3342 | |
3343 | template <class _Tp> |
3344 | inline _LIBCPP_HIDE_FROM_ABI const _Tp* begin(const valarray<_Tp>& __v) { |
3345 | return __v.__begin_; |
3346 | } |
3347 | |
3348 | template <class _Tp> |
3349 | inline _LIBCPP_HIDE_FROM_ABI _Tp* end(valarray<_Tp>& __v) { |
3350 | return __v.__end_; |
3351 | } |
3352 | |
3353 | template <class _Tp> |
3354 | inline _LIBCPP_HIDE_FROM_ABI const _Tp* end(const valarray<_Tp>& __v) { |
3355 | return __v.__end_; |
3356 | } |
3357 | |
3358 | _LIBCPP_END_NAMESPACE_STD |
3359 | |
3360 | _LIBCPP_POP_MACROS |
3361 | |
3362 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
3363 | # include <algorithm> |
3364 | # include <concepts> |
3365 | # include <cstdlib> |
3366 | # include <cstring> |
3367 | # include <functional> |
3368 | # include <stdexcept> |
3369 | # include <type_traits> |
3370 | # endif |
3371 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
3372 | |
3373 | #endif // _LIBCPP_VALARRAY |
3374 | |