blob: f8e19acdb7197df3420ef602d58325d5b071a9f3 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===-------------------------- valarray ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_VALARRAY
12#define _LIBCPP_VALARRAY
13
14/*
15 valarray synopsis
16
17namespace std
18{
19
20template<class T>
21class valarray
22{
23public:
24 typedef T value_type;
25
26 // construct/destroy:
27 valarray();
28 explicit valarray(size_t n);
29 valarray(const value_type& x, size_t n);
30 valarray(const value_type* px, size_t n);
31 valarray(const valarray& v);
Howard Hinnantbd143082012-07-21 00:51:28 +000032 valarray(valarray&& v) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000033 valarray(const slice_array<value_type>& sa);
34 valarray(const gslice_array<value_type>& ga);
35 valarray(const mask_array<value_type>& ma);
36 valarray(const indirect_array<value_type>& ia);
37 valarray(initializer_list<value_type> il);
38 ~valarray();
39
40 // assignment:
41 valarray& operator=(const valarray& v);
Howard Hinnantbd143082012-07-21 00:51:28 +000042 valarray& operator=(valarray&& v) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000043 valarray& operator=(initializer_list<value_type> il);
44 valarray& operator=(const value_type& x);
45 valarray& operator=(const slice_array<value_type>& sa);
46 valarray& operator=(const gslice_array<value_type>& ga);
47 valarray& operator=(const mask_array<value_type>& ma);
48 valarray& operator=(const indirect_array<value_type>& ia);
49
50 // element access:
51 const value_type& operator[](size_t i) const;
52 value_type& operator[](size_t i);
53
54 // subset operations:
55 valarray operator[](slice s) const;
56 slice_array<value_type> operator[](slice s);
57 valarray operator[](const gslice& gs) const;
58 gslice_array<value_type> operator[](const gslice& gs);
59 valarray operator[](const valarray<bool>& vb) const;
60 mask_array<value_type> operator[](const valarray<bool>& vb);
61 valarray operator[](const valarray<size_t>& vs) const;
62 indirect_array<value_type> operator[](const valarray<size_t>& vs);
63
64 // unary operators:
65 valarray operator+() const;
66 valarray operator-() const;
67 valarray operator~() const;
68 valarray<bool> operator!() const;
69
70 // computed assignment:
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 valarray& operator>>=(const value_type& x);
81
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 valarray& operator>>=(const valarray& v);
92
93 // member functions:
Howard Hinnantbd143082012-07-21 00:51:28 +000094 void swap(valarray& v) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000095
96 size_t size() const;
97
98 value_type sum() const;
99 value_type min() const;
100 value_type max() const;
101
102 valarray shift (int i) const;
103 valarray cshift(int i) const;
104 valarray apply(value_type f(value_type)) const;
105 valarray apply(value_type f(const value_type&)) const;
106 void resize(size_t n, value_type x = value_type());
107};
108
109class slice
110{
111public:
112 slice();
113 slice(size_t start, size_t size, size_t stride);
114
115 size_t start() const;
116 size_t size() const;
117 size_t stride() const;
118};
119
120template <class T>
121class slice_array
122{
123public:
124 typedef T value_type;
125
126 const slice_array& operator=(const slice_array& sa) const;
127 void operator= (const valarray<value_type>& v) const;
128 void operator*= (const valarray<value_type>& v) const;
129 void operator/= (const valarray<value_type>& v) 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
139 void operator=(const value_type& x) const;
140
141 slice_array() = delete;
142};
143
144class gslice
145{
146public:
147 gslice();
148 gslice(size_t start, const valarray<size_t>& size,
149 const valarray<size_t>& stride);
150
151 size_t start() const;
152 valarray<size_t> size() const;
153 valarray<size_t> stride() const;
154};
155
156template <class T>
157class gslice_array
158{
159public:
160 typedef T value_type;
161
162 void operator= (const valarray<value_type>& v) const;
163 void operator*= (const valarray<value_type>& v) const;
164 void operator/= (const valarray<value_type>& v) const;
165 void operator%= (const valarray<value_type>& v) const;
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
174 gslice_array(const gslice_array& ga);
175 ~gslice_array();
176 const gslice_array& operator=(const gslice_array& ga) const;
177 void operator=(const value_type& x) const;
178
179 gslice_array() = delete;
180};
181
182template <class T>
183class mask_array
184{
185public:
186 typedef T value_type;
187
188 void operator= (const valarray<value_type>& v) const;
189 void operator*= (const valarray<value_type>& v) const;
190 void operator/= (const valarray<value_type>& v) const;
191 void operator%= (const valarray<value_type>& v) const;
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
200 mask_array(const mask_array& ma);
201 ~mask_array();
202 const mask_array& operator=(const mask_array& ma) const;
203 void operator=(const value_type& x) const;
204
205 mask_array() = delete;
206};
207
208template <class T>
209class indirect_array
210{
211public:
212 typedef T value_type;
213
214 void operator= (const valarray<value_type>& v) const;
215 void operator*= (const valarray<value_type>& v) const;
216 void operator/= (const valarray<value_type>& v) const;
217 void operator%= (const valarray<value_type>& v) const;
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
226 indirect_array(const indirect_array& ia);
227 ~indirect_array();
228 const indirect_array& operator=(const indirect_array& ia) const;
229 void operator=(const value_type& x) const;
230
231 indirect_array() = delete;
232};
233
Howard Hinnantbd143082012-07-21 00:51:28 +0000234template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000235
236template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
237template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
238template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
239
240template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
241template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
242template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
243
244template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
245template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
246template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
247
248template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
249template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
250template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
251
252template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
253template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
254template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
255
256template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
257template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
258template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
259
260template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
261template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
262template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
263
264template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
265template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
266template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
267
268template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
269template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
270template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
271
272template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
273template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
274template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
275
276template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
277template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
278template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
279
280template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
281template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
282template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
283
284template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
285template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
286template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
287
288template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
289template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
290template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
291
292template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
293template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
294template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
295
296template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
297template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
298template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
299
300template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
301template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
302template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
303
304template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
305template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
306template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
307
308template<class T> valarray<T> abs (const valarray<T>& x);
309template<class T> valarray<T> acos (const valarray<T>& x);
310template<class T> valarray<T> asin (const valarray<T>& x);
311template<class T> valarray<T> atan (const valarray<T>& x);
312
313template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
314template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
315template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
316
317template<class T> valarray<T> cos (const valarray<T>& x);
318template<class T> valarray<T> cosh (const valarray<T>& x);
319template<class T> valarray<T> exp (const valarray<T>& x);
320template<class T> valarray<T> log (const valarray<T>& x);
321template<class T> valarray<T> log10(const valarray<T>& x);
322
323template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
324template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
325template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
326
327template<class T> valarray<T> sin (const valarray<T>& x);
328template<class T> valarray<T> sinh (const valarray<T>& x);
329template<class T> valarray<T> sqrt (const valarray<T>& x);
330template<class T> valarray<T> tan (const valarray<T>& x);
331template<class T> valarray<T> tanh (const valarray<T>& x);
332
333template <class T> unspecified1 begin(valarray<T>& v);
334template <class T> unspecified2 begin(const valarray<T>& v);
335template <class T> unspecified1 end(valarray<T>& v);
336template <class T> unspecified2 end(const valarray<T>& v);
337
338} // std
339
340*/
341
342#include <__config>
343#include <cstddef>
344#include <cmath>
345#include <initializer_list>
346#include <algorithm>
347#include <functional>
Richard Smith73c1fce2014-06-04 19:54:15 +0000348#include <new>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000349
Howard Hinnant66c6f972011-11-29 16:45:27 +0000350#include <__undef_min_max>
351
Howard Hinnant08e17472011-10-17 20:05:10 +0000352#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000353#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000354#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000355
356_LIBCPP_BEGIN_NAMESPACE_STD
357
Eric Fiselierc3589a82017-01-04 23:56:00 +0000358template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000359
Eric Fiselierc3589a82017-01-04 23:56:00 +0000360class _LIBCPP_TEMPLATE_VIS slice
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000361{
362 size_t __start_;
363 size_t __size_;
364 size_t __stride_;
365public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000366 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000367 slice()
368 : __start_(0),
369 __size_(0),
370 __stride_(0)
371 {}
372
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000373 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000374 slice(size_t __start, size_t __size, size_t __stride)
375 : __start_(__start),
376 __size_(__size),
377 __stride_(__stride)
378 {}
379
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000380 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
381 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
382 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000383};
384
Eric Fiselierc3589a82017-01-04 23:56:00 +0000385template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
Howard Hinnant83eade62013-03-06 23:30:19 +0000386class _LIBCPP_TYPE_VIS gslice;
Eric Fiselierc3589a82017-01-04 23:56:00 +0000387template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
388template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
389template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000390
391template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000392_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000393_Tp*
394begin(valarray<_Tp>& __v);
395
396template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000397_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000398const _Tp*
399begin(const valarray<_Tp>& __v);
400
401template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000402_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000403_Tp*
404end(valarray<_Tp>& __v);
405
406template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000407_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000408const _Tp*
409end(const valarray<_Tp>& __v);
410
411template <class _Op, class _A0>
412struct _UnaryOp
413{
414 typedef typename _Op::result_type result_type;
415 typedef typename _A0::value_type value_type;
416
417 _Op __op_;
418 _A0 __a0_;
419
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000420 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000421 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
422
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000423 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000424 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
425
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000426 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000427 size_t size() const {return __a0_.size();}
428};
429
430template <class _Op, class _A0, class _A1>
431struct _BinaryOp
432{
433 typedef typename _Op::result_type result_type;
434 typedef typename _A0::value_type value_type;
435
436 _Op __op_;
437 _A0 __a0_;
438 _A1 __a1_;
439
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000440 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000441 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
442 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
443
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000444 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000445 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
446
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000447 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000448 size_t size() const {return __a0_.size();}
449};
450
451template <class _Tp>
452class __scalar_expr
453{
454public:
455 typedef _Tp value_type;
456 typedef const _Tp& result_type;
457private:
458 const value_type& __t_;
459 size_t __s_;
460public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000461 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000462 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
463
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000464 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000465 result_type operator[](size_t) const {return __t_;}
466
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000467 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000468 size_t size() const {return __s_;}
469};
470
471template <class _Tp>
472struct __unary_plus : unary_function<_Tp, _Tp>
473{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000474 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000475 _Tp operator()(const _Tp& __x) const
476 {return +__x;}
477};
478
479template <class _Tp>
480struct __bit_not : unary_function<_Tp, _Tp>
481{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000482 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000483 _Tp operator()(const _Tp& __x) const
484 {return ~__x;}
485};
486
487template <class _Tp>
488struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
489{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000490 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000491 _Tp operator()(const _Tp& __x, const _Tp& __y) const
492 {return __x << __y;}
493};
494
495template <class _Tp>
496struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
497{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000498 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000499 _Tp operator()(const _Tp& __x, const _Tp& __y) const
500 {return __x >> __y;}
501};
502
Howard Hinnant99968442011-11-29 18:15:50 +0000503template <class _Tp, class _Fp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000504struct __apply_expr : unary_function<_Tp, _Tp>
505{
506private:
Howard Hinnant99968442011-11-29 18:15:50 +0000507 _Fp __f_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000508public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000509 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:50 +0000510 explicit __apply_expr(_Fp __f) : __f_(__f) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000511
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000512 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000513 _Tp operator()(const _Tp& __x) const
514 {return __f_(__x);}
515};
516
517template <class _Tp>
518struct __abs_expr : unary_function<_Tp, _Tp>
519{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000520 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000521 _Tp operator()(const _Tp& __x) const
522 {return abs(__x);}
523};
524
525template <class _Tp>
526struct __acos_expr : unary_function<_Tp, _Tp>
527{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000528 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000529 _Tp operator()(const _Tp& __x) const
530 {return acos(__x);}
531};
532
533template <class _Tp>
534struct __asin_expr : unary_function<_Tp, _Tp>
535{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000536 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000537 _Tp operator()(const _Tp& __x) const
538 {return asin(__x);}
539};
540
541template <class _Tp>
542struct __atan_expr : unary_function<_Tp, _Tp>
543{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000544 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000545 _Tp operator()(const _Tp& __x) const
546 {return atan(__x);}
547};
548
549template <class _Tp>
550struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
551{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000552 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000553 _Tp operator()(const _Tp& __x, const _Tp& __y) const
554 {return atan2(__x, __y);}
555};
556
557template <class _Tp>
558struct __cos_expr : unary_function<_Tp, _Tp>
559{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000560 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000561 _Tp operator()(const _Tp& __x) const
562 {return cos(__x);}
563};
564
565template <class _Tp>
566struct __cosh_expr : unary_function<_Tp, _Tp>
567{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000568 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000569 _Tp operator()(const _Tp& __x) const
570 {return cosh(__x);}
571};
572
573template <class _Tp>
574struct __exp_expr : unary_function<_Tp, _Tp>
575{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000576 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000577 _Tp operator()(const _Tp& __x) const
578 {return exp(__x);}
579};
580
581template <class _Tp>
582struct __log_expr : unary_function<_Tp, _Tp>
583{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000584 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000585 _Tp operator()(const _Tp& __x) const
586 {return log(__x);}
587};
588
589template <class _Tp>
590struct __log10_expr : unary_function<_Tp, _Tp>
591{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000592 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000593 _Tp operator()(const _Tp& __x) const
594 {return log10(__x);}
595};
596
597template <class _Tp>
598struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
599{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000600 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000601 _Tp operator()(const _Tp& __x, const _Tp& __y) const
602 {return pow(__x, __y);}
603};
604
605template <class _Tp>
606struct __sin_expr : unary_function<_Tp, _Tp>
607{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000608 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000609 _Tp operator()(const _Tp& __x) const
610 {return sin(__x);}
611};
612
613template <class _Tp>
614struct __sinh_expr : unary_function<_Tp, _Tp>
615{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000616 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000617 _Tp operator()(const _Tp& __x) const
618 {return sinh(__x);}
619};
620
621template <class _Tp>
622struct __sqrt_expr : unary_function<_Tp, _Tp>
623{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000624 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000625 _Tp operator()(const _Tp& __x) const
626 {return sqrt(__x);}
627};
628
629template <class _Tp>
630struct __tan_expr : unary_function<_Tp, _Tp>
631{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000632 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000633 _Tp operator()(const _Tp& __x) const
634 {return tan(__x);}
635};
636
637template <class _Tp>
638struct __tanh_expr : unary_function<_Tp, _Tp>
639{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000640 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000641 _Tp operator()(const _Tp& __x) const
642 {return tanh(__x);}
643};
644
645template <class _ValExpr>
646class __slice_expr
647{
648 typedef typename remove_reference<_ValExpr>::type _RmExpr;
649public:
650 typedef typename _RmExpr::value_type value_type;
651 typedef value_type result_type;
652
653private:
654 _ValExpr __expr_;
655 size_t __start_;
656 size_t __size_;
657 size_t __stride_;
658
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000659 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000660 __slice_expr(const slice& __sl, const _RmExpr& __e)
661 : __expr_(__e),
662 __start_(__sl.start()),
663 __size_(__sl.size()),
664 __stride_(__sl.stride())
665 {}
666public:
667
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000668 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000669 result_type operator[](size_t __i) const
670 {return __expr_[__start_ + __i * __stride_];}
671
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000672 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000673 size_t size() const {return __size_;}
674
Eric Fiselierc3589a82017-01-04 23:56:00 +0000675 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000676};
677
678template <class _ValExpr>
679class __mask_expr;
680
681template <class _ValExpr>
682class __indirect_expr;
683
684template <class _ValExpr>
685class __shift_expr
686{
687 typedef typename remove_reference<_ValExpr>::type _RmExpr;
688public:
689 typedef typename _RmExpr::value_type value_type;
690 typedef value_type result_type;
691
692private:
693 _ValExpr __expr_;
694 size_t __size_;
695 ptrdiff_t __ul_;
696 ptrdiff_t __sn_;
697 ptrdiff_t __n_;
Howard Hinnant99968442011-11-29 18:15:50 +0000698 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000699 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
700
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000701 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000702 __shift_expr(int __n, const _RmExpr& __e)
703 : __expr_(__e),
704 __size_(__e.size()),
705 __n_(__n)
706 {
Howard Hinnant99968442011-11-29 18:15:50 +0000707 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
708 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000709 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
710 }
711public:
712
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000713 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000714 result_type operator[](size_t __j) const
715 {
Howard Hinnantec3773c2011-12-01 20:21:04 +0000716 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
Howard Hinnant99968442011-11-29 18:15:50 +0000717 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000718 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
719 }
720
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000721 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000722 size_t size() const {return __size_;}
723
724 template <class> friend class __val_expr;
725};
726
727template <class _ValExpr>
728class __cshift_expr
729{
730 typedef typename remove_reference<_ValExpr>::type _RmExpr;
731public:
732 typedef typename _RmExpr::value_type value_type;
733 typedef value_type result_type;
734
735private:
736 _ValExpr __expr_;
737 size_t __size_;
738 size_t __m_;
739 size_t __o1_;
740 size_t __o2_;
741
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000742 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000743 __cshift_expr(int __n, const _RmExpr& __e)
744 : __expr_(__e),
745 __size_(__e.size())
746 {
747 __n %= static_cast<int>(__size_);
748 if (__n >= 0)
749 {
750 __m_ = __size_ - __n;
751 __o1_ = __n;
752 __o2_ = __n - __size_;
753 }
754 else
755 {
756 __m_ = -__n;
757 __o1_ = __n + __size_;
758 __o2_ = __n;
759 }
760 }
761public:
762
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000763 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000764 result_type operator[](size_t __i) const
765 {
766 if (__i < __m_)
767 return __expr_[__i + __o1_];
768 return __expr_[__i + __o2_];
769 }
770
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000771 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000772 size_t size() const {return __size_;}
773
774 template <class> friend class __val_expr;
775};
776
777template<class _ValExpr>
778class __val_expr;
779
780template<class _ValExpr>
781struct __is_val_expr : false_type {};
782
783template<class _ValExpr>
784struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
785
786template<class _Tp>
787struct __is_val_expr<valarray<_Tp> > : true_type {};
788
789template<class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +0000790class _LIBCPP_TEMPLATE_VIS valarray
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000791{
792public:
793 typedef _Tp value_type;
794 typedef _Tp result_type;
795
796private:
797 value_type* __begin_;
798 value_type* __end_;
799
800public:
801 // construct/destroy:
Douglas Gregor0855dde2012-05-19 07:14:17 +0000802 _LIBCPP_INLINE_VISIBILITY
803 valarray() : __begin_(0), __end_(0) {}
Eric Fiselierb6a049f2016-09-16 00:13:55 +0000804 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
805 explicit valarray(size_t __n);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000806 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000807 valarray(const value_type& __x, size_t __n);
808 valarray(const value_type* __p, size_t __n);
809 valarray(const valarray& __v);
Eric Fiselier97db5172017-04-19 00:23:45 +0000810#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000811 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd143082012-07-21 00:51:28 +0000812 valarray(valarray&& __v) _NOEXCEPT;
Douglas Gregor0855dde2012-05-19 07:14:17 +0000813 valarray(initializer_list<value_type> __il);
Eric Fiselier97db5172017-04-19 00:23:45 +0000814#endif // _LIBCPP_CXX03_LANG
Douglas Gregor0855dde2012-05-19 07:14:17 +0000815 valarray(const slice_array<value_type>& __sa);
816 valarray(const gslice_array<value_type>& __ga);
817 valarray(const mask_array<value_type>& __ma);
818 valarray(const indirect_array<value_type>& __ia);
Eric Fiselierb6a049f2016-09-16 00:13:55 +0000819 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000820 ~valarray();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000821
822 // assignment:
Douglas Gregor0855dde2012-05-19 07:14:17 +0000823 valarray& operator=(const valarray& __v);
Eric Fiselier97db5172017-04-19 00:23:45 +0000824#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000825 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd143082012-07-21 00:51:28 +0000826 valarray& operator=(valarray&& __v) _NOEXCEPT;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000827 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000828 valarray& operator=(initializer_list<value_type>);
Eric Fiselier97db5172017-04-19 00:23:45 +0000829#endif // _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000830 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000831 valarray& operator=(const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000832 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000833 valarray& operator=(const slice_array<value_type>& __sa);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000834 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000835 valarray& operator=(const gslice_array<value_type>& __ga);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000836 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000837 valarray& operator=(const mask_array<value_type>& __ma);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000838 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000839 valarray& operator=(const indirect_array<value_type>& __ia);
Howard Hinnantdb866632011-07-27 23:19:59 +0000840 template <class _ValExpr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000841 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantdb866632011-07-27 23:19:59 +0000842 valarray& operator=(const __val_expr<_ValExpr>& __v);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000843
844 // element access:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000845 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000846 const value_type& operator[](size_t __i) const {return __begin_[__i];}
847
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000848 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000849 value_type& operator[](size_t __i) {return __begin_[__i];}
850
851 // subset operations:
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000852 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000853 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000854 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000855 slice_array<value_type> operator[](slice __s);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000856 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000857 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000858 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000859 gslice_array<value_type> operator[](const gslice& __gs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000860#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000861 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000862 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000863 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000864 gslice_array<value_type> operator[](gslice&& __gs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000865#endif // _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000866 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000867 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000868 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000869 mask_array<value_type> operator[](const valarray<bool>& __vb);
Eric Fiselier97db5172017-04-19 00:23:45 +0000870#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000871 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000872 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000873 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000874 mask_array<value_type> operator[](valarray<bool>&& __vb);
Eric Fiselier97db5172017-04-19 00:23:45 +0000875#endif // _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000876 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000877 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000878 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000879 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000880#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000881 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000882 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000883 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000884 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000885#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000886
887 // unary operators:
Douglas Gregor0855dde2012-05-19 07:14:17 +0000888 valarray operator+() const;
889 valarray operator-() const;
890 valarray operator~() const;
891 valarray<bool> operator!() const;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000892
893 // computed assignment:
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000894 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000895 valarray& operator*= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000896 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000897 valarray& operator/= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000898 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000899 valarray& operator%= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000900 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000901 valarray& operator+= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000902 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000903 valarray& operator-= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000904 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000905 valarray& operator^= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000906 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000907 valarray& operator&= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000908 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000909 valarray& operator|= (const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000910 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000911 valarray& operator<<=(const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000912 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000913 valarray& operator>>=(const value_type& __x);
914
915 template <class _Expr>
916 typename enable_if
917 <
918 __is_val_expr<_Expr>::value,
919 valarray&
920 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000921 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000922 operator*= (const _Expr& __v);
923
924 template <class _Expr>
925 typename enable_if
926 <
927 __is_val_expr<_Expr>::value,
928 valarray&
929 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000930 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000931 operator/= (const _Expr& __v);
932
933 template <class _Expr>
934 typename enable_if
935 <
936 __is_val_expr<_Expr>::value,
937 valarray&
938 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000939 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000940 operator%= (const _Expr& __v);
941
942 template <class _Expr>
943 typename enable_if
944 <
945 __is_val_expr<_Expr>::value,
946 valarray&
947 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000948 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000949 operator+= (const _Expr& __v);
950
951 template <class _Expr>
952 typename enable_if
953 <
954 __is_val_expr<_Expr>::value,
955 valarray&
956 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000957 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000958 operator-= (const _Expr& __v);
959
960 template <class _Expr>
961 typename enable_if
962 <
963 __is_val_expr<_Expr>::value,
964 valarray&
965 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000966 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000967 operator^= (const _Expr& __v);
968
969 template <class _Expr>
970 typename enable_if
971 <
972 __is_val_expr<_Expr>::value,
973 valarray&
974 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000975 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000976 operator|= (const _Expr& __v);
977
978 template <class _Expr>
979 typename enable_if
980 <
981 __is_val_expr<_Expr>::value,
982 valarray&
983 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000984 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000985 operator&= (const _Expr& __v);
986
987 template <class _Expr>
988 typename enable_if
989 <
990 __is_val_expr<_Expr>::value,
991 valarray&
992 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000993 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000994 operator<<= (const _Expr& __v);
995
996 template <class _Expr>
997 typename enable_if
998 <
999 __is_val_expr<_Expr>::value,
1000 valarray&
1001 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001002 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001003 operator>>= (const _Expr& __v);
1004
1005 // member functions:
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001006 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd143082012-07-21 00:51:28 +00001007 void swap(valarray& __v) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001008
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001009 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantec3773c2011-12-01 20:21:04 +00001010 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001011
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001012 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +00001013 value_type sum() const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001014 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +00001015 value_type min() const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001016 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +00001017 value_type max() const;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001018
Douglas Gregor0855dde2012-05-19 07:14:17 +00001019 valarray shift (int __i) const;
1020 valarray cshift(int __i) const;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001021 valarray apply(value_type __f(value_type)) const;
1022 valarray apply(value_type __f(const value_type&)) const;
1023 void resize(size_t __n, value_type __x = value_type());
1024
1025private:
Eric Fiselierc3589a82017-01-04 23:56:00 +00001026 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
1027 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
1028 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
1029 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001030 template <class> friend class __mask_expr;
Eric Fiselierc3589a82017-01-04 23:56:00 +00001031 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001032 template <class> friend class __indirect_expr;
1033 template <class> friend class __val_expr;
1034
1035 template <class _Up>
1036 friend
1037 _Up*
1038 begin(valarray<_Up>& __v);
Howard Hinnant324bb032010-08-22 00:02:43 +00001039
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001040 template <class _Up>
1041 friend
1042 const _Up*
1043 begin(const valarray<_Up>& __v);
Howard Hinnant324bb032010-08-22 00:02:43 +00001044
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001045 template <class _Up>
1046 friend
1047 _Up*
1048 end(valarray<_Up>& __v);
Howard Hinnant324bb032010-08-22 00:02:43 +00001049
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001050 template <class _Up>
1051 friend
1052 const _Up*
1053 end(const valarray<_Up>& __v);
1054};
1055
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001056_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
1057_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
1058_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1059
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001060template <class _Op, class _Tp>
1061struct _UnaryOp<_Op, valarray<_Tp> >
1062{
1063 typedef typename _Op::result_type result_type;
1064 typedef _Tp value_type;
1065
1066 _Op __op_;
1067 const valarray<_Tp>& __a0_;
1068
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001069 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001070 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1071
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001072 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001073 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1074
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001075 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001076 size_t size() const {return __a0_.size();}
1077};
1078
1079template <class _Op, class _Tp, class _A1>
1080struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1081{
1082 typedef typename _Op::result_type result_type;
1083 typedef _Tp value_type;
1084
1085 _Op __op_;
1086 const valarray<_Tp>& __a0_;
1087 _A1 __a1_;
1088
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001089 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001090 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1091 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1092
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001093 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001094 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1095
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001096 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001097 size_t size() const {return __a0_.size();}
1098};
1099
1100template <class _Op, class _A0, class _Tp>
1101struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1102{
1103 typedef typename _Op::result_type result_type;
1104 typedef _Tp value_type;
1105
1106 _Op __op_;
1107 _A0 __a0_;
1108 const valarray<_Tp>& __a1_;
1109
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001110 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001111 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1112 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1113
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001114 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001115 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1116
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001117 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001118 size_t size() const {return __a0_.size();}
1119};
1120
1121template <class _Op, class _Tp>
1122struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1123{
1124 typedef typename _Op::result_type result_type;
1125 typedef _Tp value_type;
1126
1127 _Op __op_;
1128 const valarray<_Tp>& __a0_;
1129 const valarray<_Tp>& __a1_;
1130
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001131 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001132 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1133 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1134
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001135 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001136 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1137
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001138 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001139 size_t size() const {return __a0_.size();}
1140};
1141
1142// slice_array
1143
1144template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00001145class _LIBCPP_TEMPLATE_VIS slice_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001146{
1147public:
1148 typedef _Tp value_type;
1149
1150private:
1151 value_type* __vp_;
1152 size_t __size_;
1153 size_t __stride_;
1154
1155public:
1156 template <class _Expr>
1157 typename enable_if
1158 <
1159 __is_val_expr<_Expr>::value,
1160 void
1161 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001162 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001163 operator=(const _Expr& __v) const;
1164
1165 template <class _Expr>
1166 typename enable_if
1167 <
1168 __is_val_expr<_Expr>::value,
1169 void
1170 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001171 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001172 operator*=(const _Expr& __v) const;
1173
1174 template <class _Expr>
1175 typename enable_if
1176 <
1177 __is_val_expr<_Expr>::value,
1178 void
1179 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001180 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001181 operator/=(const _Expr& __v) const;
1182
1183 template <class _Expr>
1184 typename enable_if
1185 <
1186 __is_val_expr<_Expr>::value,
1187 void
1188 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001189 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001190 operator%=(const _Expr& __v) const;
1191
1192 template <class _Expr>
1193 typename enable_if
1194 <
1195 __is_val_expr<_Expr>::value,
1196 void
1197 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001198 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001199 operator+=(const _Expr& __v) const;
1200
1201 template <class _Expr>
1202 typename enable_if
1203 <
1204 __is_val_expr<_Expr>::value,
1205 void
1206 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001207 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001208 operator-=(const _Expr& __v) const;
1209
1210 template <class _Expr>
1211 typename enable_if
1212 <
1213 __is_val_expr<_Expr>::value,
1214 void
1215 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001216 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001217 operator^=(const _Expr& __v) const;
1218
1219 template <class _Expr>
1220 typename enable_if
1221 <
1222 __is_val_expr<_Expr>::value,
1223 void
1224 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001225 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001226 operator&=(const _Expr& __v) const;
1227
1228 template <class _Expr>
1229 typename enable_if
1230 <
1231 __is_val_expr<_Expr>::value,
1232 void
1233 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001234 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001235 operator|=(const _Expr& __v) const;
1236
1237 template <class _Expr>
1238 typename enable_if
1239 <
1240 __is_val_expr<_Expr>::value,
1241 void
1242 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001243 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001244 operator<<=(const _Expr& __v) const;
1245
1246 template <class _Expr>
1247 typename enable_if
1248 <
1249 __is_val_expr<_Expr>::value,
1250 void
1251 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001252 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001253 operator>>=(const _Expr& __v) const;
1254
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001255 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001256 const slice_array& operator=(const slice_array& __sa) const;
1257
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001258 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001259 void operator=(const value_type& __x) const;
1260
1261private:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001262 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001263 slice_array(const slice& __sl, const valarray<value_type>& __v)
1264 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1265 __size_(__sl.size()),
1266 __stride_(__sl.stride())
1267 {}
1268
1269 template <class> friend class valarray;
1270 template <class> friend class sliceExpr;
1271};
1272
1273template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001274inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001275const slice_array<_Tp>&
1276slice_array<_Tp>::operator=(const slice_array& __sa) const
1277{
1278 value_type* __t = __vp_;
1279 const value_type* __s = __sa.__vp_;
1280 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1281 *__t = *__s;
Eric Fiselierf4124612014-08-12 00:06:58 +00001282 return *this;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001283}
1284
1285template <class _Tp>
1286template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001287inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001288typename enable_if
1289<
1290 __is_val_expr<_Expr>::value,
1291 void
1292>::type
1293slice_array<_Tp>::operator=(const _Expr& __v) const
1294{
1295 value_type* __t = __vp_;
1296 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1297 *__t = __v[__i];
1298}
1299
1300template <class _Tp>
1301template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001302inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001303typename enable_if
1304<
1305 __is_val_expr<_Expr>::value,
1306 void
1307>::type
1308slice_array<_Tp>::operator*=(const _Expr& __v) const
1309{
1310 value_type* __t = __vp_;
1311 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1312 *__t *= __v[__i];
1313}
1314
1315template <class _Tp>
1316template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001317inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001318typename enable_if
1319<
1320 __is_val_expr<_Expr>::value,
1321 void
1322>::type
1323slice_array<_Tp>::operator/=(const _Expr& __v) const
1324{
1325 value_type* __t = __vp_;
1326 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1327 *__t /= __v[__i];
1328}
1329
1330template <class _Tp>
1331template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001332inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001333typename enable_if
1334<
1335 __is_val_expr<_Expr>::value,
1336 void
1337>::type
1338slice_array<_Tp>::operator%=(const _Expr& __v) const
1339{
1340 value_type* __t = __vp_;
1341 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1342 *__t %= __v[__i];
1343}
1344
1345template <class _Tp>
1346template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001347inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001348typename enable_if
1349<
1350 __is_val_expr<_Expr>::value,
1351 void
1352>::type
1353slice_array<_Tp>::operator+=(const _Expr& __v) const
1354{
1355 value_type* __t = __vp_;
1356 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1357 *__t += __v[__i];
1358}
1359
1360template <class _Tp>
1361template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001362inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001363typename enable_if
1364<
1365 __is_val_expr<_Expr>::value,
1366 void
1367>::type
1368slice_array<_Tp>::operator-=(const _Expr& __v) const
1369{
1370 value_type* __t = __vp_;
1371 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1372 *__t -= __v[__i];
1373}
1374
1375template <class _Tp>
1376template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001377inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001378typename enable_if
1379<
1380 __is_val_expr<_Expr>::value,
1381 void
1382>::type
1383slice_array<_Tp>::operator^=(const _Expr& __v) const
1384{
1385 value_type* __t = __vp_;
1386 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1387 *__t ^= __v[__i];
1388}
1389
1390template <class _Tp>
1391template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001392inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001393typename enable_if
1394<
1395 __is_val_expr<_Expr>::value,
1396 void
1397>::type
1398slice_array<_Tp>::operator&=(const _Expr& __v) const
1399{
1400 value_type* __t = __vp_;
1401 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1402 *__t &= __v[__i];
1403}
1404
1405template <class _Tp>
1406template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001407inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001408typename enable_if
1409<
1410 __is_val_expr<_Expr>::value,
1411 void
1412>::type
1413slice_array<_Tp>::operator|=(const _Expr& __v) const
1414{
1415 value_type* __t = __vp_;
1416 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1417 *__t |= __v[__i];
1418}
1419
1420template <class _Tp>
1421template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001422inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001423typename enable_if
1424<
1425 __is_val_expr<_Expr>::value,
1426 void
1427>::type
1428slice_array<_Tp>::operator<<=(const _Expr& __v) const
1429{
1430 value_type* __t = __vp_;
1431 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1432 *__t <<= __v[__i];
1433}
1434
1435template <class _Tp>
1436template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001437inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001438typename enable_if
1439<
1440 __is_val_expr<_Expr>::value,
1441 void
1442>::type
1443slice_array<_Tp>::operator>>=(const _Expr& __v) const
1444{
1445 value_type* __t = __vp_;
1446 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1447 *__t >>= __v[__i];
1448}
1449
1450template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001451inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001452void
1453slice_array<_Tp>::operator=(const value_type& __x) const
1454{
1455 value_type* __t = __vp_;
1456 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1457 *__t = __x;
1458}
1459
1460// gslice
1461
Howard Hinnant83eade62013-03-06 23:30:19 +00001462class _LIBCPP_TYPE_VIS gslice
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001463{
1464 valarray<size_t> __size_;
1465 valarray<size_t> __stride_;
1466 valarray<size_t> __1d_;
Howard Hinnant324bb032010-08-22 00:02:43 +00001467
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001468public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001469 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001470 gslice() {}
Douglas Gregor0855dde2012-05-19 07:14:17 +00001471
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001472 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001473 gslice(size_t __start, const valarray<size_t>& __size,
1474 const valarray<size_t>& __stride)
1475 : __size_(__size),
1476 __stride_(__stride)
1477 {__init(__start);}
1478
Eric Fiselier97db5172017-04-19 00:23:45 +00001479#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001480
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001481 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001482 gslice(size_t __start, const valarray<size_t>& __size,
1483 valarray<size_t>&& __stride)
1484 : __size_(__size),
1485 __stride_(move(__stride))
1486 {__init(__start);}
1487
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001488 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001489 gslice(size_t __start, valarray<size_t>&& __size,
1490 const valarray<size_t>& __stride)
1491 : __size_(move(__size)),
1492 __stride_(__stride)
1493 {__init(__start);}
1494
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001495 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001496 gslice(size_t __start, valarray<size_t>&& __size,
1497 valarray<size_t>&& __stride)
1498 : __size_(move(__size)),
1499 __stride_(move(__stride))
1500 {__init(__start);}
1501
Eric Fiselier97db5172017-04-19 00:23:45 +00001502#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001503
1504// gslice(const gslice&) = default;
1505// gslice(gslice&&) = default;
1506// gslice& operator=(const gslice&) = default;
1507// gslice& operator=(gslice&&) = default;
1508
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001509 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001510 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1511
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001512 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001513 valarray<size_t> size() const {return __size_;}
1514
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001515 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001516 valarray<size_t> stride() const {return __stride_;}
1517
1518private:
1519 void __init(size_t __start);
1520
1521 template <class> friend class gslice_array;
1522 template <class> friend class valarray;
1523 template <class> friend class __val_expr;
1524};
1525
1526// gslice_array
1527
1528template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00001529class _LIBCPP_TEMPLATE_VIS gslice_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001530{
1531public:
1532 typedef _Tp value_type;
1533
1534private:
1535 value_type* __vp_;
1536 valarray<size_t> __1d_;
1537
1538public:
1539 template <class _Expr>
1540 typename enable_if
1541 <
1542 __is_val_expr<_Expr>::value,
1543 void
1544 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001545 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001546 operator=(const _Expr& __v) const;
1547
1548 template <class _Expr>
1549 typename enable_if
1550 <
1551 __is_val_expr<_Expr>::value,
1552 void
1553 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001554 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001555 operator*=(const _Expr& __v) const;
1556
1557 template <class _Expr>
1558 typename enable_if
1559 <
1560 __is_val_expr<_Expr>::value,
1561 void
1562 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001563 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001564 operator/=(const _Expr& __v) const;
1565
1566 template <class _Expr>
1567 typename enable_if
1568 <
1569 __is_val_expr<_Expr>::value,
1570 void
1571 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001572 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001573 operator%=(const _Expr& __v) const;
1574
1575 template <class _Expr>
1576 typename enable_if
1577 <
1578 __is_val_expr<_Expr>::value,
1579 void
1580 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001581 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001582 operator+=(const _Expr& __v) const;
1583
1584 template <class _Expr>
1585 typename enable_if
1586 <
1587 __is_val_expr<_Expr>::value,
1588 void
1589 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001590 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001591 operator-=(const _Expr& __v) const;
1592
1593 template <class _Expr>
1594 typename enable_if
1595 <
1596 __is_val_expr<_Expr>::value,
1597 void
1598 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001599 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001600 operator^=(const _Expr& __v) const;
1601
1602 template <class _Expr>
1603 typename enable_if
1604 <
1605 __is_val_expr<_Expr>::value,
1606 void
1607 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001608 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001609 operator&=(const _Expr& __v) const;
1610
1611 template <class _Expr>
1612 typename enable_if
1613 <
1614 __is_val_expr<_Expr>::value,
1615 void
1616 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001617 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001618 operator|=(const _Expr& __v) const;
1619
1620 template <class _Expr>
1621 typename enable_if
1622 <
1623 __is_val_expr<_Expr>::value,
1624 void
1625 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001626 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001627 operator<<=(const _Expr& __v) const;
1628
1629 template <class _Expr>
1630 typename enable_if
1631 <
1632 __is_val_expr<_Expr>::value,
1633 void
1634 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001635 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001636 operator>>=(const _Expr& __v) const;
1637
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001638 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001639 const gslice_array& operator=(const gslice_array& __ga) const;
1640
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001641 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001642 void operator=(const value_type& __x) const;
1643
1644// gslice_array(const gslice_array&) = default;
1645// gslice_array(gslice_array&&) = default;
1646// gslice_array& operator=(const gslice_array&) = default;
1647// gslice_array& operator=(gslice_array&&) = default;
1648
1649private:
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001650 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1651 : __vp_(const_cast<value_type*>(__v.__begin_)),
1652 __1d_(__gs.__1d_)
1653 {}
1654
Eric Fiselier97db5172017-04-19 00:23:45 +00001655#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001656 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1657 : __vp_(const_cast<value_type*>(__v.__begin_)),
1658 __1d_(move(__gs.__1d_))
1659 {}
Eric Fiselier97db5172017-04-19 00:23:45 +00001660#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001661
1662 template <class> friend class valarray;
1663};
1664
1665template <class _Tp>
1666template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001667inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001668typename enable_if
1669<
1670 __is_val_expr<_Expr>::value,
1671 void
1672>::type
1673gslice_array<_Tp>::operator=(const _Expr& __v) const
1674{
1675 typedef const size_t* _Ip;
1676 size_t __j = 0;
1677 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1678 __vp_[*__i] = __v[__j];
1679}
1680
1681template <class _Tp>
1682template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001683inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001684typename enable_if
1685<
1686 __is_val_expr<_Expr>::value,
1687 void
1688>::type
1689gslice_array<_Tp>::operator*=(const _Expr& __v) const
1690{
1691 typedef const size_t* _Ip;
1692 size_t __j = 0;
1693 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1694 __vp_[*__i] *= __v[__j];
1695}
1696
1697template <class _Tp>
1698template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001699inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001700typename enable_if
1701<
1702 __is_val_expr<_Expr>::value,
1703 void
1704>::type
1705gslice_array<_Tp>::operator/=(const _Expr& __v) const
1706{
1707 typedef const size_t* _Ip;
1708 size_t __j = 0;
1709 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1710 __vp_[*__i] /= __v[__j];
1711}
1712
1713template <class _Tp>
1714template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001715inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001716typename enable_if
1717<
1718 __is_val_expr<_Expr>::value,
1719 void
1720>::type
1721gslice_array<_Tp>::operator%=(const _Expr& __v) const
1722{
1723 typedef const size_t* _Ip;
1724 size_t __j = 0;
1725 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1726 __vp_[*__i] %= __v[__j];
1727}
1728
1729template <class _Tp>
1730template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001731inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001732typename enable_if
1733<
1734 __is_val_expr<_Expr>::value,
1735 void
1736>::type
1737gslice_array<_Tp>::operator+=(const _Expr& __v) const
1738{
1739 typedef const size_t* _Ip;
1740 size_t __j = 0;
1741 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1742 __vp_[*__i] += __v[__j];
1743}
1744
1745template <class _Tp>
1746template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001747inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001748typename enable_if
1749<
1750 __is_val_expr<_Expr>::value,
1751 void
1752>::type
1753gslice_array<_Tp>::operator-=(const _Expr& __v) const
1754{
1755 typedef const size_t* _Ip;
1756 size_t __j = 0;
1757 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1758 __vp_[*__i] -= __v[__j];
1759}
1760
1761template <class _Tp>
1762template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001763inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001764typename enable_if
1765<
1766 __is_val_expr<_Expr>::value,
1767 void
1768>::type
1769gslice_array<_Tp>::operator^=(const _Expr& __v) const
1770{
1771 typedef const size_t* _Ip;
1772 size_t __j = 0;
1773 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1774 __vp_[*__i] ^= __v[__j];
1775}
1776
1777template <class _Tp>
1778template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001779inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001780typename enable_if
1781<
1782 __is_val_expr<_Expr>::value,
1783 void
1784>::type
1785gslice_array<_Tp>::operator&=(const _Expr& __v) const
1786{
1787 typedef const size_t* _Ip;
1788 size_t __j = 0;
1789 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1790 __vp_[*__i] &= __v[__j];
1791}
1792
1793template <class _Tp>
1794template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001795inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001796typename enable_if
1797<
1798 __is_val_expr<_Expr>::value,
1799 void
1800>::type
1801gslice_array<_Tp>::operator|=(const _Expr& __v) const
1802{
1803 typedef const size_t* _Ip;
1804 size_t __j = 0;
1805 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1806 __vp_[*__i] |= __v[__j];
1807}
1808
1809template <class _Tp>
1810template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001811inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001812typename enable_if
1813<
1814 __is_val_expr<_Expr>::value,
1815 void
1816>::type
1817gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1818{
1819 typedef const size_t* _Ip;
1820 size_t __j = 0;
1821 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1822 __vp_[*__i] <<= __v[__j];
1823}
1824
1825template <class _Tp>
1826template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001827inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001828typename enable_if
1829<
1830 __is_val_expr<_Expr>::value,
1831 void
1832>::type
1833gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1834{
1835 typedef const size_t* _Ip;
1836 size_t __j = 0;
1837 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1838 __vp_[*__i] >>= __v[__j];
1839}
1840
1841template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001842inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001843const gslice_array<_Tp>&
1844gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1845{
1846 typedef const size_t* _Ip;
1847 const value_type* __s = __ga.__vp_;
1848 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1849 __i != __e; ++__i, ++__j)
1850 __vp_[*__i] = __s[*__j];
1851 return *this;
1852}
1853
1854template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001855inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001856void
1857gslice_array<_Tp>::operator=(const value_type& __x) const
1858{
1859 typedef const size_t* _Ip;
1860 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1861 __vp_[*__i] = __x;
1862}
1863
1864// mask_array
1865
1866template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00001867class _LIBCPP_TEMPLATE_VIS mask_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001868{
1869public:
1870 typedef _Tp value_type;
1871
1872private:
1873 value_type* __vp_;
1874 valarray<size_t> __1d_;
1875
1876public:
1877 template <class _Expr>
1878 typename enable_if
1879 <
1880 __is_val_expr<_Expr>::value,
1881 void
1882 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001883 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001884 operator=(const _Expr& __v) const;
1885
1886 template <class _Expr>
1887 typename enable_if
1888 <
1889 __is_val_expr<_Expr>::value,
1890 void
1891 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001892 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001893 operator*=(const _Expr& __v) const;
1894
1895 template <class _Expr>
1896 typename enable_if
1897 <
1898 __is_val_expr<_Expr>::value,
1899 void
1900 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001901 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001902 operator/=(const _Expr& __v) const;
1903
1904 template <class _Expr>
1905 typename enable_if
1906 <
1907 __is_val_expr<_Expr>::value,
1908 void
1909 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001910 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001911 operator%=(const _Expr& __v) const;
1912
1913 template <class _Expr>
1914 typename enable_if
1915 <
1916 __is_val_expr<_Expr>::value,
1917 void
1918 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001919 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001920 operator+=(const _Expr& __v) const;
1921
1922 template <class _Expr>
1923 typename enable_if
1924 <
1925 __is_val_expr<_Expr>::value,
1926 void
1927 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001928 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001929 operator-=(const _Expr& __v) const;
1930
1931 template <class _Expr>
1932 typename enable_if
1933 <
1934 __is_val_expr<_Expr>::value,
1935 void
1936 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001937 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001938 operator^=(const _Expr& __v) const;
1939
1940 template <class _Expr>
1941 typename enable_if
1942 <
1943 __is_val_expr<_Expr>::value,
1944 void
1945 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001946 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001947 operator&=(const _Expr& __v) const;
1948
1949 template <class _Expr>
1950 typename enable_if
1951 <
1952 __is_val_expr<_Expr>::value,
1953 void
1954 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001955 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001956 operator|=(const _Expr& __v) const;
1957
1958 template <class _Expr>
1959 typename enable_if
1960 <
1961 __is_val_expr<_Expr>::value,
1962 void
1963 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001964 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001965 operator<<=(const _Expr& __v) const;
1966
1967 template <class _Expr>
1968 typename enable_if
1969 <
1970 __is_val_expr<_Expr>::value,
1971 void
1972 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001973 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001974 operator>>=(const _Expr& __v) const;
1975
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001976 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001977 const mask_array& operator=(const mask_array& __ma) const;
1978
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001979 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001980 void operator=(const value_type& __x) const;
1981
1982// mask_array(const mask_array&) = default;
1983// mask_array(mask_array&&) = default;
1984// mask_array& operator=(const mask_array&) = default;
1985// mask_array& operator=(mask_array&&) = default;
1986
1987private:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001988 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001989 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1990 : __vp_(const_cast<value_type*>(__v.__begin_)),
Howard Hinnantec3773c2011-12-01 20:21:04 +00001991 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001992 {
1993 size_t __j = 0;
1994 for (size_t __i = 0; __i < __vb.size(); ++__i)
1995 if (__vb[__i])
1996 __1d_[__j++] = __i;
1997 }
1998
1999 template <class> friend class valarray;
2000};
2001
2002template <class _Tp>
2003template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002004inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002005typename enable_if
2006<
2007 __is_val_expr<_Expr>::value,
2008 void
2009>::type
2010mask_array<_Tp>::operator=(const _Expr& __v) const
2011{
2012 size_t __n = __1d_.size();
2013 for (size_t __i = 0; __i < __n; ++__i)
2014 __vp_[__1d_[__i]] = __v[__i];
2015}
2016
2017template <class _Tp>
2018template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002019inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002020typename enable_if
2021<
2022 __is_val_expr<_Expr>::value,
2023 void
2024>::type
2025mask_array<_Tp>::operator*=(const _Expr& __v) const
2026{
2027 size_t __n = __1d_.size();
2028 for (size_t __i = 0; __i < __n; ++__i)
2029 __vp_[__1d_[__i]] *= __v[__i];
2030}
2031
2032template <class _Tp>
2033template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002034inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002035typename enable_if
2036<
2037 __is_val_expr<_Expr>::value,
2038 void
2039>::type
2040mask_array<_Tp>::operator/=(const _Expr& __v) const
2041{
2042 size_t __n = __1d_.size();
2043 for (size_t __i = 0; __i < __n; ++__i)
2044 __vp_[__1d_[__i]] /= __v[__i];
2045}
2046
2047template <class _Tp>
2048template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002049inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002050typename enable_if
2051<
2052 __is_val_expr<_Expr>::value,
2053 void
2054>::type
2055mask_array<_Tp>::operator%=(const _Expr& __v) const
2056{
2057 size_t __n = __1d_.size();
2058 for (size_t __i = 0; __i < __n; ++__i)
2059 __vp_[__1d_[__i]] %= __v[__i];
2060}
2061
2062template <class _Tp>
2063template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002064inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002065typename enable_if
2066<
2067 __is_val_expr<_Expr>::value,
2068 void
2069>::type
2070mask_array<_Tp>::operator+=(const _Expr& __v) const
2071{
2072 size_t __n = __1d_.size();
2073 for (size_t __i = 0; __i < __n; ++__i)
2074 __vp_[__1d_[__i]] += __v[__i];
2075}
2076
2077template <class _Tp>
2078template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002079inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002080typename enable_if
2081<
2082 __is_val_expr<_Expr>::value,
2083 void
2084>::type
2085mask_array<_Tp>::operator-=(const _Expr& __v) const
2086{
2087 size_t __n = __1d_.size();
2088 for (size_t __i = 0; __i < __n; ++__i)
2089 __vp_[__1d_[__i]] -= __v[__i];
2090}
2091
2092template <class _Tp>
2093template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002094inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002095typename enable_if
2096<
2097 __is_val_expr<_Expr>::value,
2098 void
2099>::type
2100mask_array<_Tp>::operator^=(const _Expr& __v) const
2101{
2102 size_t __n = __1d_.size();
2103 for (size_t __i = 0; __i < __n; ++__i)
2104 __vp_[__1d_[__i]] ^= __v[__i];
2105}
2106
2107template <class _Tp>
2108template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002109inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002110typename enable_if
2111<
2112 __is_val_expr<_Expr>::value,
2113 void
2114>::type
2115mask_array<_Tp>::operator&=(const _Expr& __v) const
2116{
2117 size_t __n = __1d_.size();
2118 for (size_t __i = 0; __i < __n; ++__i)
2119 __vp_[__1d_[__i]] &= __v[__i];
2120}
2121
2122template <class _Tp>
2123template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002124inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002125typename enable_if
2126<
2127 __is_val_expr<_Expr>::value,
2128 void
2129>::type
2130mask_array<_Tp>::operator|=(const _Expr& __v) const
2131{
2132 size_t __n = __1d_.size();
2133 for (size_t __i = 0; __i < __n; ++__i)
2134 __vp_[__1d_[__i]] |= __v[__i];
2135}
2136
2137template <class _Tp>
2138template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002139inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002140typename enable_if
2141<
2142 __is_val_expr<_Expr>::value,
2143 void
2144>::type
2145mask_array<_Tp>::operator<<=(const _Expr& __v) const
2146{
2147 size_t __n = __1d_.size();
2148 for (size_t __i = 0; __i < __n; ++__i)
2149 __vp_[__1d_[__i]] <<= __v[__i];
2150}
2151
2152template <class _Tp>
2153template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002154inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002155typename enable_if
2156<
2157 __is_val_expr<_Expr>::value,
2158 void
2159>::type
2160mask_array<_Tp>::operator>>=(const _Expr& __v) const
2161{
2162 size_t __n = __1d_.size();
2163 for (size_t __i = 0; __i < __n; ++__i)
2164 __vp_[__1d_[__i]] >>= __v[__i];
2165}
2166
2167template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002168inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002169const mask_array<_Tp>&
2170mask_array<_Tp>::operator=(const mask_array& __ma) const
2171{
2172 size_t __n = __1d_.size();
2173 for (size_t __i = 0; __i < __n; ++__i)
2174 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
Eric Fiselierf4124612014-08-12 00:06:58 +00002175 return *this;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002176}
2177
2178template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002179inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002180void
2181mask_array<_Tp>::operator=(const value_type& __x) const
2182{
2183 size_t __n = __1d_.size();
2184 for (size_t __i = 0; __i < __n; ++__i)
2185 __vp_[__1d_[__i]] = __x;
2186}
2187
2188template <class _ValExpr>
2189class __mask_expr
2190{
2191 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2192public:
2193 typedef typename _RmExpr::value_type value_type;
2194 typedef value_type result_type;
2195
2196private:
2197 _ValExpr __expr_;
2198 valarray<size_t> __1d_;
2199
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002200 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002201 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2202 : __expr_(__e),
Howard Hinnantec3773c2011-12-01 20:21:04 +00002203 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002204 {
2205 size_t __j = 0;
2206 for (size_t __i = 0; __i < __vb.size(); ++__i)
2207 if (__vb[__i])
2208 __1d_[__j++] = __i;
2209 }
2210
2211public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002212 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002213 result_type operator[](size_t __i) const
2214 {return __expr_[__1d_[__i]];}
2215
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002216 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002217 size_t size() const {return __1d_.size();}
2218
2219 template <class> friend class valarray;
2220};
2221
2222// indirect_array
2223
2224template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00002225class _LIBCPP_TEMPLATE_VIS indirect_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002226{
2227public:
2228 typedef _Tp value_type;
2229
2230private:
2231 value_type* __vp_;
2232 valarray<size_t> __1d_;
2233
2234public:
2235 template <class _Expr>
2236 typename enable_if
2237 <
2238 __is_val_expr<_Expr>::value,
2239 void
2240 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002241 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002242 operator=(const _Expr& __v) const;
2243
2244 template <class _Expr>
2245 typename enable_if
2246 <
2247 __is_val_expr<_Expr>::value,
2248 void
2249 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002250 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002251 operator*=(const _Expr& __v) const;
2252
2253 template <class _Expr>
2254 typename enable_if
2255 <
2256 __is_val_expr<_Expr>::value,
2257 void
2258 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002259 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002260 operator/=(const _Expr& __v) const;
2261
2262 template <class _Expr>
2263 typename enable_if
2264 <
2265 __is_val_expr<_Expr>::value,
2266 void
2267 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002268 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002269 operator%=(const _Expr& __v) const;
2270
2271 template <class _Expr>
2272 typename enable_if
2273 <
2274 __is_val_expr<_Expr>::value,
2275 void
2276 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002277 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002278 operator+=(const _Expr& __v) const;
2279
2280 template <class _Expr>
2281 typename enable_if
2282 <
2283 __is_val_expr<_Expr>::value,
2284 void
2285 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002286 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002287 operator-=(const _Expr& __v) const;
2288
2289 template <class _Expr>
2290 typename enable_if
2291 <
2292 __is_val_expr<_Expr>::value,
2293 void
2294 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002295 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002296 operator^=(const _Expr& __v) const;
2297
2298 template <class _Expr>
2299 typename enable_if
2300 <
2301 __is_val_expr<_Expr>::value,
2302 void
2303 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002304 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002305 operator&=(const _Expr& __v) const;
2306
2307 template <class _Expr>
2308 typename enable_if
2309 <
2310 __is_val_expr<_Expr>::value,
2311 void
2312 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002313 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002314 operator|=(const _Expr& __v) const;
2315
2316 template <class _Expr>
2317 typename enable_if
2318 <
2319 __is_val_expr<_Expr>::value,
2320 void
2321 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002322 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002323 operator<<=(const _Expr& __v) const;
2324
2325 template <class _Expr>
2326 typename enable_if
2327 <
2328 __is_val_expr<_Expr>::value,
2329 void
2330 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002331 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002332 operator>>=(const _Expr& __v) const;
2333
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002334 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002335 const indirect_array& operator=(const indirect_array& __ia) const;
2336
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002337 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002338 void operator=(const value_type& __x) const;
2339
2340// indirect_array(const indirect_array&) = default;
2341// indirect_array(indirect_array&&) = default;
2342// indirect_array& operator=(const indirect_array&) = default;
2343// indirect_array& operator=(indirect_array&&) = default;
2344
2345private:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002346 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002347 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2348 : __vp_(const_cast<value_type*>(__v.__begin_)),
2349 __1d_(__ia)
2350 {}
2351
Eric Fiselier97db5172017-04-19 00:23:45 +00002352#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002353
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002354 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002355 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2356 : __vp_(const_cast<value_type*>(__v.__begin_)),
2357 __1d_(move(__ia))
2358 {}
2359
Eric Fiselier97db5172017-04-19 00:23:45 +00002360#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002361
2362 template <class> friend class valarray;
2363};
2364
2365template <class _Tp>
2366template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002367inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002368typename enable_if
2369<
2370 __is_val_expr<_Expr>::value,
2371 void
2372>::type
2373indirect_array<_Tp>::operator=(const _Expr& __v) const
2374{
2375 size_t __n = __1d_.size();
2376 for (size_t __i = 0; __i < __n; ++__i)
2377 __vp_[__1d_[__i]] = __v[__i];
2378}
2379
2380template <class _Tp>
2381template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002382inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002383typename enable_if
2384<
2385 __is_val_expr<_Expr>::value,
2386 void
2387>::type
2388indirect_array<_Tp>::operator*=(const _Expr& __v) const
2389{
2390 size_t __n = __1d_.size();
2391 for (size_t __i = 0; __i < __n; ++__i)
2392 __vp_[__1d_[__i]] *= __v[__i];
2393}
2394
2395template <class _Tp>
2396template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002397inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002398typename enable_if
2399<
2400 __is_val_expr<_Expr>::value,
2401 void
2402>::type
2403indirect_array<_Tp>::operator/=(const _Expr& __v) const
2404{
2405 size_t __n = __1d_.size();
2406 for (size_t __i = 0; __i < __n; ++__i)
2407 __vp_[__1d_[__i]] /= __v[__i];
2408}
2409
2410template <class _Tp>
2411template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002412inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002413typename enable_if
2414<
2415 __is_val_expr<_Expr>::value,
2416 void
2417>::type
2418indirect_array<_Tp>::operator%=(const _Expr& __v) const
2419{
2420 size_t __n = __1d_.size();
2421 for (size_t __i = 0; __i < __n; ++__i)
2422 __vp_[__1d_[__i]] %= __v[__i];
2423}
2424
2425template <class _Tp>
2426template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002427inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002428typename enable_if
2429<
2430 __is_val_expr<_Expr>::value,
2431 void
2432>::type
2433indirect_array<_Tp>::operator+=(const _Expr& __v) const
2434{
2435 size_t __n = __1d_.size();
2436 for (size_t __i = 0; __i < __n; ++__i)
2437 __vp_[__1d_[__i]] += __v[__i];
2438}
2439
2440template <class _Tp>
2441template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002442inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002443typename enable_if
2444<
2445 __is_val_expr<_Expr>::value,
2446 void
2447>::type
2448indirect_array<_Tp>::operator-=(const _Expr& __v) const
2449{
2450 size_t __n = __1d_.size();
2451 for (size_t __i = 0; __i < __n; ++__i)
2452 __vp_[__1d_[__i]] -= __v[__i];
2453}
2454
2455template <class _Tp>
2456template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002457inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002458typename enable_if
2459<
2460 __is_val_expr<_Expr>::value,
2461 void
2462>::type
2463indirect_array<_Tp>::operator^=(const _Expr& __v) const
2464{
2465 size_t __n = __1d_.size();
2466 for (size_t __i = 0; __i < __n; ++__i)
2467 __vp_[__1d_[__i]] ^= __v[__i];
2468}
2469
2470template <class _Tp>
2471template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002472inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002473typename enable_if
2474<
2475 __is_val_expr<_Expr>::value,
2476 void
2477>::type
2478indirect_array<_Tp>::operator&=(const _Expr& __v) const
2479{
2480 size_t __n = __1d_.size();
2481 for (size_t __i = 0; __i < __n; ++__i)
2482 __vp_[__1d_[__i]] &= __v[__i];
2483}
2484
2485template <class _Tp>
2486template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002487inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002488typename enable_if
2489<
2490 __is_val_expr<_Expr>::value,
2491 void
2492>::type
2493indirect_array<_Tp>::operator|=(const _Expr& __v) const
2494{
2495 size_t __n = __1d_.size();
2496 for (size_t __i = 0; __i < __n; ++__i)
2497 __vp_[__1d_[__i]] |= __v[__i];
2498}
2499
2500template <class _Tp>
2501template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002502inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002503typename enable_if
2504<
2505 __is_val_expr<_Expr>::value,
2506 void
2507>::type
2508indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2509{
2510 size_t __n = __1d_.size();
2511 for (size_t __i = 0; __i < __n; ++__i)
2512 __vp_[__1d_[__i]] <<= __v[__i];
2513}
2514
2515template <class _Tp>
2516template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002517inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002518typename enable_if
2519<
2520 __is_val_expr<_Expr>::value,
2521 void
2522>::type
2523indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2524{
2525 size_t __n = __1d_.size();
2526 for (size_t __i = 0; __i < __n; ++__i)
2527 __vp_[__1d_[__i]] >>= __v[__i];
2528}
2529
2530template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002531inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002532const indirect_array<_Tp>&
2533indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2534{
2535 typedef const size_t* _Ip;
2536 const value_type* __s = __ia.__vp_;
2537 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2538 __i != __e; ++__i, ++__j)
2539 __vp_[*__i] = __s[*__j];
2540 return *this;
2541}
2542
2543template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002544inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002545void
2546indirect_array<_Tp>::operator=(const value_type& __x) const
2547{
2548 typedef const size_t* _Ip;
2549 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2550 __vp_[*__i] = __x;
2551}
2552
2553template <class _ValExpr>
2554class __indirect_expr
2555{
2556 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2557public:
2558 typedef typename _RmExpr::value_type value_type;
2559 typedef value_type result_type;
2560
2561private:
2562 _ValExpr __expr_;
2563 valarray<size_t> __1d_;
2564
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002565 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002566 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2567 : __expr_(__e),
2568 __1d_(__ia)
2569 {}
2570
Eric Fiselier97db5172017-04-19 00:23:45 +00002571#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002572
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002573 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002574 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2575 : __expr_(__e),
2576 __1d_(move(__ia))
2577 {}
2578
Eric Fiselier97db5172017-04-19 00:23:45 +00002579#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002580
2581public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002582 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002583 result_type operator[](size_t __i) const
2584 {return __expr_[__1d_[__i]];}
2585
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002586 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002587 size_t size() const {return __1d_.size();}
2588
Eric Fiselierc3589a82017-01-04 23:56:00 +00002589 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002590};
2591
2592template<class _ValExpr>
2593class __val_expr
2594{
2595 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2596
2597 _ValExpr __expr_;
2598public:
2599 typedef typename _RmExpr::value_type value_type;
2600 typedef typename _RmExpr::result_type result_type;
2601
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002603 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2604
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002605 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002606 result_type operator[](size_t __i) const
2607 {return __expr_[__i];}
2608
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002609 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002610 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2611 {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2612
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002613 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002614 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2615 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2616
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002617 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002618 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2619 {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2620
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002621 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002622 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2623 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2624
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002625 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002626 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2627 operator+() const
2628 {
2629 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2630 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2631 }
2632
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002633 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002634 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2635 operator-() const
2636 {
2637 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2638 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2639 }
2640
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002641 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002642 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2643 operator~() const
2644 {
2645 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2646 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2647 }
2648
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002649 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002650 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2651 operator!() const
2652 {
2653 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2654 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2655 }
2656
2657 operator valarray<result_type>() const;
2658
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002659 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002660 size_t size() const {return __expr_.size();}
2661
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002662 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002663 result_type sum() const
2664 {
2665 size_t __n = __expr_.size();
2666 result_type __r = __n ? __expr_[0] : result_type();
2667 for (size_t __i = 1; __i < __n; ++__i)
2668 __r += __expr_[__i];
2669 return __r;
2670 }
2671
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002672 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002673 result_type min() const
2674 {
2675 size_t __n = size();
2676 result_type __r = __n ? (*this)[0] : result_type();
2677 for (size_t __i = 1; __i < __n; ++__i)
2678 {
2679 result_type __x = __expr_[__i];
2680 if (__x < __r)
2681 __r = __x;
2682 }
2683 return __r;
2684 }
2685
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002686 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002687 result_type max() const
2688 {
2689 size_t __n = size();
2690 result_type __r = __n ? (*this)[0] : result_type();
2691 for (size_t __i = 1; __i < __n; ++__i)
2692 {
2693 result_type __x = __expr_[__i];
2694 if (__r < __x)
2695 __r = __x;
2696 }
2697 return __r;
2698 }
2699
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002700 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002701 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2702 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2703
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002704 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002705 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2706 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2707
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002708 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002709 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2710 apply(value_type __f(value_type)) const
2711 {
2712 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2713 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2714 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2715 }
2716
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002717 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002718 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2719 apply(value_type __f(const value_type&)) const
2720 {
2721 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2722 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2723 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2724 }
2725};
2726
2727template<class _ValExpr>
Howard Hinnantd8851432013-09-13 23:27:42 +00002728__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002729{
2730 valarray<result_type> __r;
2731 size_t __n = __expr_.size();
2732 if (__n)
2733 {
2734 __r.__begin_ =
2735 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00002736 static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002737 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2738 ::new (__r.__end_) result_type(__expr_[__i]);
2739 }
2740 return __r;
2741}
2742
2743// valarray
2744
2745template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002746inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002747valarray<_Tp>::valarray(size_t __n)
2748 : __begin_(0),
2749 __end_(0)
2750{
2751 resize(__n);
2752}
2753
2754template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002755inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002756valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2757 : __begin_(0),
2758 __end_(0)
2759{
2760 resize(__n, __x);
2761}
2762
2763template <class _Tp>
2764valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2765 : __begin_(0),
2766 __end_(0)
2767{
2768 if (__n)
2769 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002770 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002771#ifndef _LIBCPP_NO_EXCEPTIONS
2772 try
2773 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002774#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002775 for (; __n; ++__end_, ++__p, --__n)
2776 ::new (__end_) value_type(*__p);
2777#ifndef _LIBCPP_NO_EXCEPTIONS
2778 }
2779 catch (...)
2780 {
2781 resize(0);
2782 throw;
2783 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002784#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002785 }
2786}
2787
2788template <class _Tp>
2789valarray<_Tp>::valarray(const valarray& __v)
2790 : __begin_(0),
2791 __end_(0)
2792{
2793 if (__v.size())
2794 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002795 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002796#ifndef _LIBCPP_NO_EXCEPTIONS
2797 try
2798 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002799#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002800 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2801 ::new (__end_) value_type(*__p);
2802#ifndef _LIBCPP_NO_EXCEPTIONS
2803 }
2804 catch (...)
2805 {
2806 resize(0);
2807 throw;
2808 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002809#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002810 }
2811}
2812
Eric Fiselier97db5172017-04-19 00:23:45 +00002813#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002814
2815template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002816inline
Howard Hinnantbd143082012-07-21 00:51:28 +00002817valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002818 : __begin_(__v.__begin_),
2819 __end_(__v.__end_)
2820{
2821 __v.__begin_ = __v.__end_ = nullptr;
2822}
2823
2824template <class _Tp>
2825valarray<_Tp>::valarray(initializer_list<value_type> __il)
2826 : __begin_(0),
2827 __end_(0)
2828{
2829 size_t __n = __il.size();
2830 if (__n)
2831 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002832 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002833#ifndef _LIBCPP_NO_EXCEPTIONS
2834 try
2835 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002836#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002837 for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2838 ::new (__end_) value_type(*__p);
2839#ifndef _LIBCPP_NO_EXCEPTIONS
2840 }
2841 catch (...)
2842 {
2843 resize(0);
2844 throw;
2845 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002846#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002847 }
2848}
2849
Eric Fiselier97db5172017-04-19 00:23:45 +00002850#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002851
2852template <class _Tp>
2853valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2854 : __begin_(0),
2855 __end_(0)
2856{
2857 size_t __n = __sa.__size_;
2858 if (__n)
2859 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002860 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002861#ifndef _LIBCPP_NO_EXCEPTIONS
2862 try
2863 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002864#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002865 for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2866 ::new (__end_) value_type(*__p);
2867#ifndef _LIBCPP_NO_EXCEPTIONS
2868 }
2869 catch (...)
2870 {
2871 resize(0);
2872 throw;
2873 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002874#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002875 }
2876}
2877
2878template <class _Tp>
2879valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2880 : __begin_(0),
2881 __end_(0)
2882{
2883 size_t __n = __ga.__1d_.size();
2884 if (__n)
2885 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002886 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002887#ifndef _LIBCPP_NO_EXCEPTIONS
2888 try
2889 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002890#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002891 typedef const size_t* _Ip;
2892 const value_type* __s = __ga.__vp_;
2893 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2894 __i != __e; ++__i, ++__end_)
2895 ::new (__end_) value_type(__s[*__i]);
2896#ifndef _LIBCPP_NO_EXCEPTIONS
2897 }
2898 catch (...)
2899 {
2900 resize(0);
2901 throw;
2902 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002903#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002904 }
2905}
2906
2907template <class _Tp>
2908valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2909 : __begin_(0),
2910 __end_(0)
2911{
2912 size_t __n = __ma.__1d_.size();
2913 if (__n)
2914 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002915 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002916#ifndef _LIBCPP_NO_EXCEPTIONS
2917 try
2918 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002919#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002920 typedef const size_t* _Ip;
2921 const value_type* __s = __ma.__vp_;
2922 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2923 __i != __e; ++__i, ++__end_)
2924 ::new (__end_) value_type(__s[*__i]);
2925#ifndef _LIBCPP_NO_EXCEPTIONS
2926 }
2927 catch (...)
2928 {
2929 resize(0);
2930 throw;
2931 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002932#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002933 }
2934}
2935
2936template <class _Tp>
2937valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2938 : __begin_(0),
2939 __end_(0)
2940{
2941 size_t __n = __ia.__1d_.size();
2942 if (__n)
2943 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002944 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002945#ifndef _LIBCPP_NO_EXCEPTIONS
2946 try
2947 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002948#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002949 typedef const size_t* _Ip;
2950 const value_type* __s = __ia.__vp_;
2951 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2952 __i != __e; ++__i, ++__end_)
2953 ::new (__end_) value_type(__s[*__i]);
2954#ifndef _LIBCPP_NO_EXCEPTIONS
2955 }
2956 catch (...)
2957 {
2958 resize(0);
2959 throw;
2960 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002961#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002962 }
2963}
2964
2965template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002966inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002967valarray<_Tp>::~valarray()
2968{
2969 resize(0);
2970}
2971
2972template <class _Tp>
2973valarray<_Tp>&
2974valarray<_Tp>::operator=(const valarray& __v)
2975{
2976 if (this != &__v)
2977 {
2978 if (size() != __v.size())
2979 resize(__v.size());
Howard Hinnant0949eed2011-06-30 21:18:19 +00002980 _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002981 }
2982 return *this;
2983}
2984
Eric Fiselier97db5172017-04-19 00:23:45 +00002985#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002986
2987template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002988inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002989valarray<_Tp>&
Howard Hinnantbd143082012-07-21 00:51:28 +00002990valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002991{
2992 resize(0);
2993 __begin_ = __v.__begin_;
2994 __end_ = __v.__end_;
2995 __v.__begin_ = nullptr;
2996 __v.__end_ = nullptr;
2997 return *this;
2998}
2999
3000template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003001inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003002valarray<_Tp>&
3003valarray<_Tp>::operator=(initializer_list<value_type> __il)
3004{
3005 if (size() != __il.size())
3006 resize(__il.size());
Howard Hinnant0949eed2011-06-30 21:18:19 +00003007 _VSTD::copy(__il.begin(), __il.end(), __begin_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003008 return *this;
3009}
3010
Eric Fiselier97db5172017-04-19 00:23:45 +00003011#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003012
3013template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003014inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003015valarray<_Tp>&
3016valarray<_Tp>::operator=(const value_type& __x)
3017{
Howard Hinnant0949eed2011-06-30 21:18:19 +00003018 _VSTD::fill(__begin_, __end_, __x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003019 return *this;
3020}
3021
3022template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003023inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003024valarray<_Tp>&
3025valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
3026{
3027 value_type* __t = __begin_;
3028 const value_type* __s = __sa.__vp_;
3029 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
3030 *__t = *__s;
3031 return *this;
3032}
3033
3034template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003035inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003036valarray<_Tp>&
3037valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
3038{
3039 typedef const size_t* _Ip;
3040 value_type* __t = __begin_;
3041 const value_type* __s = __ga.__vp_;
3042 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
3043 __i != __e; ++__i, ++__t)
3044 *__t = __s[*__i];
3045 return *this;
3046}
3047
3048template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003049inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003050valarray<_Tp>&
3051valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
3052{
3053 typedef const size_t* _Ip;
3054 value_type* __t = __begin_;
3055 const value_type* __s = __ma.__vp_;
3056 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
3057 __i != __e; ++__i, ++__t)
3058 *__t = __s[*__i];
3059 return *this;
3060}
3061
3062template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003063inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003064valarray<_Tp>&
3065valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
3066{
3067 typedef const size_t* _Ip;
3068 value_type* __t = __begin_;
3069 const value_type* __s = __ia.__vp_;
3070 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
3071 __i != __e; ++__i, ++__t)
3072 *__t = __s[*__i];
3073 return *this;
3074}
3075
3076template <class _Tp>
Howard Hinnantdb866632011-07-27 23:19:59 +00003077template <class _ValExpr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003078inline
Howard Hinnantdb866632011-07-27 23:19:59 +00003079valarray<_Tp>&
3080valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
3081{
3082 size_t __n = __v.size();
3083 if (size() != __n)
3084 resize(__n);
3085 value_type* __t = __begin_;
3086 for (size_t __i = 0; __i != __n; ++__t, ++__i)
3087 *__t = result_type(__v[__i]);
3088 return *this;
3089}
3090
3091template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003092inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003093__val_expr<__slice_expr<const valarray<_Tp>&> >
3094valarray<_Tp>::operator[](slice __s) const
3095{
3096 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3097}
3098
3099template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003100inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003101slice_array<_Tp>
3102valarray<_Tp>::operator[](slice __s)
3103{
3104 return slice_array<value_type>(__s, *this);
3105}
3106
3107template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003108inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003109__val_expr<__indirect_expr<const valarray<_Tp>&> >
3110valarray<_Tp>::operator[](const gslice& __gs) const
3111{
3112 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3113}
3114
3115template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003116inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003117gslice_array<_Tp>
3118valarray<_Tp>::operator[](const gslice& __gs)
3119{
3120 return gslice_array<value_type>(__gs, *this);
3121}
3122
Eric Fiselier97db5172017-04-19 00:23:45 +00003123#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003124
3125template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003126inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003127__val_expr<__indirect_expr<const valarray<_Tp>&> >
3128valarray<_Tp>::operator[](gslice&& __gs) const
3129{
3130 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3131}
3132
3133template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003134inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003135gslice_array<_Tp>
3136valarray<_Tp>::operator[](gslice&& __gs)
3137{
3138 return gslice_array<value_type>(move(__gs), *this);
3139}
3140
Eric Fiselier97db5172017-04-19 00:23:45 +00003141#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003142
3143template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003144inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003145__val_expr<__mask_expr<const valarray<_Tp>&> >
3146valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3147{
3148 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3149}
3150
3151template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003152inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003153mask_array<_Tp>
3154valarray<_Tp>::operator[](const valarray<bool>& __vb)
3155{
3156 return mask_array<value_type>(__vb, *this);
3157}
3158
Eric Fiselier97db5172017-04-19 00:23:45 +00003159#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003160
3161template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003162inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003163__val_expr<__mask_expr<const valarray<_Tp>&> >
3164valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3165{
3166 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3167}
3168
3169template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003170inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003171mask_array<_Tp>
3172valarray<_Tp>::operator[](valarray<bool>&& __vb)
3173{
3174 return mask_array<value_type>(move(__vb), *this);
3175}
3176
Eric Fiselier97db5172017-04-19 00:23:45 +00003177#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003178
3179template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003180inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003181__val_expr<__indirect_expr<const valarray<_Tp>&> >
3182valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3183{
3184 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3185}
3186
3187template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003188inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003189indirect_array<_Tp>
3190valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3191{
3192 return indirect_array<value_type>(__vs, *this);
3193}
3194
Eric Fiselier97db5172017-04-19 00:23:45 +00003195#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003196
3197template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003198inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003199__val_expr<__indirect_expr<const valarray<_Tp>&> >
3200valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3201{
3202 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3203}
3204
3205template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003206inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003207indirect_array<_Tp>
3208valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3209{
3210 return indirect_array<value_type>(move(__vs), *this);
3211}
3212
Eric Fiselier97db5172017-04-19 00:23:45 +00003213#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003214
3215template <class _Tp>
3216valarray<_Tp>
3217valarray<_Tp>::operator+() const
3218{
3219 valarray<value_type> __r;
3220 size_t __n = size();
3221 if (__n)
3222 {
3223 __r.__begin_ =
3224 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003225 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003226 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3227 ::new (__r.__end_) value_type(+*__p);
3228 }
3229 return __r;
3230}
3231
3232template <class _Tp>
3233valarray<_Tp>
3234valarray<_Tp>::operator-() const
3235{
3236 valarray<value_type> __r;
3237 size_t __n = size();
3238 if (__n)
3239 {
3240 __r.__begin_ =
3241 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003242 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003243 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3244 ::new (__r.__end_) value_type(-*__p);
3245 }
3246 return __r;
3247}
3248
3249template <class _Tp>
3250valarray<_Tp>
3251valarray<_Tp>::operator~() const
3252{
3253 valarray<value_type> __r;
3254 size_t __n = size();
3255 if (__n)
3256 {
3257 __r.__begin_ =
3258 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003259 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003260 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3261 ::new (__r.__end_) value_type(~*__p);
3262 }
3263 return __r;
3264}
3265
3266template <class _Tp>
3267valarray<bool>
3268valarray<_Tp>::operator!() const
3269{
3270 valarray<bool> __r;
3271 size_t __n = size();
3272 if (__n)
3273 {
3274 __r.__begin_ =
3275 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003276 static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003277 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3278 ::new (__r.__end_) bool(!*__p);
3279 }
3280 return __r;
3281}
3282
3283template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003284inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003285valarray<_Tp>&
3286valarray<_Tp>::operator*=(const value_type& __x)
3287{
3288 for (value_type* __p = __begin_; __p != __end_; ++__p)
3289 *__p *= __x;
3290 return *this;
3291}
3292
3293template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003294inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003295valarray<_Tp>&
3296valarray<_Tp>::operator/=(const value_type& __x)
3297{
3298 for (value_type* __p = __begin_; __p != __end_; ++__p)
3299 *__p /= __x;
3300 return *this;
3301}
3302
3303template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003304inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003305valarray<_Tp>&
3306valarray<_Tp>::operator%=(const value_type& __x)
3307{
3308 for (value_type* __p = __begin_; __p != __end_; ++__p)
3309 *__p %= __x;
3310 return *this;
3311}
3312
3313template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003314inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003315valarray<_Tp>&
3316valarray<_Tp>::operator+=(const value_type& __x)
3317{
3318 for (value_type* __p = __begin_; __p != __end_; ++__p)
3319 *__p += __x;
3320 return *this;
3321}
3322
3323template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003324inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003325valarray<_Tp>&
3326valarray<_Tp>::operator-=(const value_type& __x)
3327{
3328 for (value_type* __p = __begin_; __p != __end_; ++__p)
3329 *__p -= __x;
3330 return *this;
3331}
3332
3333template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003334inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003335valarray<_Tp>&
3336valarray<_Tp>::operator^=(const value_type& __x)
3337{
3338 for (value_type* __p = __begin_; __p != __end_; ++__p)
3339 *__p ^= __x;
3340 return *this;
3341}
3342
3343template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003344inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003345valarray<_Tp>&
3346valarray<_Tp>::operator&=(const value_type& __x)
3347{
3348 for (value_type* __p = __begin_; __p != __end_; ++__p)
3349 *__p &= __x;
3350 return *this;
3351}
3352
3353template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003354inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003355valarray<_Tp>&
3356valarray<_Tp>::operator|=(const value_type& __x)
3357{
3358 for (value_type* __p = __begin_; __p != __end_; ++__p)
3359 *__p |= __x;
3360 return *this;
3361}
3362
3363template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003364inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003365valarray<_Tp>&
3366valarray<_Tp>::operator<<=(const value_type& __x)
3367{
3368 for (value_type* __p = __begin_; __p != __end_; ++__p)
3369 *__p <<= __x;
3370 return *this;
3371}
3372
3373template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003374inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003375valarray<_Tp>&
3376valarray<_Tp>::operator>>=(const value_type& __x)
3377{
3378 for (value_type* __p = __begin_; __p != __end_; ++__p)
3379 *__p >>= __x;
3380 return *this;
3381}
3382
3383template <class _Tp>
3384template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003385inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003386typename enable_if
3387<
3388 __is_val_expr<_Expr>::value,
3389 valarray<_Tp>&
3390>::type
3391valarray<_Tp>::operator*=(const _Expr& __v)
3392{
3393 size_t __i = 0;
3394 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3395 *__t *= __v[__i];
3396 return *this;
3397}
3398
3399template <class _Tp>
3400template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003401inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003402typename enable_if
3403<
3404 __is_val_expr<_Expr>::value,
3405 valarray<_Tp>&
3406>::type
3407valarray<_Tp>::operator/=(const _Expr& __v)
3408{
3409 size_t __i = 0;
3410 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3411 *__t /= __v[__i];
3412 return *this;
3413}
3414
3415template <class _Tp>
3416template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003417inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003418typename enable_if
3419<
3420 __is_val_expr<_Expr>::value,
3421 valarray<_Tp>&
3422>::type
3423valarray<_Tp>::operator%=(const _Expr& __v)
3424{
3425 size_t __i = 0;
3426 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3427 *__t %= __v[__i];
3428 return *this;
3429}
3430
3431template <class _Tp>
3432template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003433inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003434typename enable_if
3435<
3436 __is_val_expr<_Expr>::value,
3437 valarray<_Tp>&
3438>::type
3439valarray<_Tp>::operator+=(const _Expr& __v)
3440{
3441 size_t __i = 0;
3442 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3443 *__t += __v[__i];
3444 return *this;
3445}
3446
3447template <class _Tp>
3448template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003449inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003450typename enable_if
3451<
3452 __is_val_expr<_Expr>::value,
3453 valarray<_Tp>&
3454>::type
3455valarray<_Tp>::operator-=(const _Expr& __v)
3456{
3457 size_t __i = 0;
3458 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3459 *__t -= __v[__i];
3460 return *this;
3461}
3462
3463template <class _Tp>
3464template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003465inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003466typename enable_if
3467<
3468 __is_val_expr<_Expr>::value,
3469 valarray<_Tp>&
3470>::type
3471valarray<_Tp>::operator^=(const _Expr& __v)
3472{
3473 size_t __i = 0;
3474 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3475 *__t ^= __v[__i];
3476 return *this;
3477}
3478
3479template <class _Tp>
3480template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003481inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003482typename enable_if
3483<
3484 __is_val_expr<_Expr>::value,
3485 valarray<_Tp>&
3486>::type
3487valarray<_Tp>::operator|=(const _Expr& __v)
3488{
3489 size_t __i = 0;
3490 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3491 *__t |= __v[__i];
3492 return *this;
3493}
3494
3495template <class _Tp>
3496template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003497inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003498typename enable_if
3499<
3500 __is_val_expr<_Expr>::value,
3501 valarray<_Tp>&
3502>::type
3503valarray<_Tp>::operator&=(const _Expr& __v)
3504{
3505 size_t __i = 0;
3506 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3507 *__t &= __v[__i];
3508 return *this;
3509}
3510
3511template <class _Tp>
3512template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003513inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003514typename enable_if
3515<
3516 __is_val_expr<_Expr>::value,
3517 valarray<_Tp>&
3518>::type
3519valarray<_Tp>::operator<<=(const _Expr& __v)
3520{
3521 size_t __i = 0;
3522 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3523 *__t <<= __v[__i];
3524 return *this;
3525}
3526
3527template <class _Tp>
3528template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003529inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003530typename enable_if
3531<
3532 __is_val_expr<_Expr>::value,
3533 valarray<_Tp>&
3534>::type
3535valarray<_Tp>::operator>>=(const _Expr& __v)
3536{
3537 size_t __i = 0;
3538 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3539 *__t >>= __v[__i];
3540 return *this;
3541}
3542
3543template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003544inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003545void
Howard Hinnantbd143082012-07-21 00:51:28 +00003546valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003547{
Howard Hinnant0949eed2011-06-30 21:18:19 +00003548 _VSTD::swap(__begin_, __v.__begin_);
3549 _VSTD::swap(__end_, __v.__end_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003550}
3551
3552template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003553inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003554_Tp
3555valarray<_Tp>::sum() const
3556{
3557 if (__begin_ == __end_)
3558 return value_type();
3559 const value_type* __p = __begin_;
3560 _Tp __r = *__p;
3561 for (++__p; __p != __end_; ++__p)
3562 __r += *__p;
3563 return __r;
3564}
3565
3566template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003567inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003568_Tp
3569valarray<_Tp>::min() const
3570{
3571 if (__begin_ == __end_)
3572 return value_type();
Howard Hinnant0949eed2011-06-30 21:18:19 +00003573 return *_VSTD::min_element(__begin_, __end_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003574}
3575
3576template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003577inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003578_Tp
3579valarray<_Tp>::max() const
3580{
3581 if (__begin_ == __end_)
3582 return value_type();
Howard Hinnant0949eed2011-06-30 21:18:19 +00003583 return *_VSTD::max_element(__begin_, __end_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003584}
3585
3586template <class _Tp>
3587valarray<_Tp>
3588valarray<_Tp>::shift(int __i) const
3589{
3590 valarray<value_type> __r;
3591 size_t __n = size();
3592 if (__n)
3593 {
3594 __r.__begin_ =
3595 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003596 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003597 const value_type* __sb;
3598 value_type* __tb;
3599 value_type* __te;
3600 if (__i >= 0)
3601 {
Howard Hinnant0949eed2011-06-30 21:18:19 +00003602 __i = _VSTD::min(__i, static_cast<int>(__n));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003603 __sb = __begin_ + __i;
3604 __tb = __r.__begin_;
3605 __te = __r.__begin_ + (__n - __i);
3606 }
3607 else
3608 {
Howard Hinnant0949eed2011-06-30 21:18:19 +00003609 __i = _VSTD::min(-__i, static_cast<int>(__n));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003610 __sb = __begin_;
3611 __tb = __r.__begin_ + __i;
3612 __te = __r.__begin_ + __n;
3613 }
3614 for (; __r.__end_ != __tb; ++__r.__end_)
3615 ::new (__r.__end_) value_type();
3616 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3617 ::new (__r.__end_) value_type(*__sb);
3618 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3619 ::new (__r.__end_) value_type();
3620 }
3621 return __r;
3622}
3623
3624template <class _Tp>
3625valarray<_Tp>
3626valarray<_Tp>::cshift(int __i) const
3627{
3628 valarray<value_type> __r;
3629 size_t __n = size();
3630 if (__n)
3631 {
3632 __r.__begin_ =
3633 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003634 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003635 __i %= static_cast<int>(__n);
3636 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3637 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3638 ::new (__r.__end_) value_type(*__s);
3639 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3640 ::new (__r.__end_) value_type(*__s);
3641 }
3642 return __r;
3643}
3644
3645template <class _Tp>
3646valarray<_Tp>
3647valarray<_Tp>::apply(value_type __f(value_type)) const
3648{
3649 valarray<value_type> __r;
3650 size_t __n = size();
3651 if (__n)
3652 {
3653 __r.__begin_ =
3654 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003655 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003656 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3657 ::new (__r.__end_) value_type(__f(*__p));
3658 }
3659 return __r;
3660}
3661
3662template <class _Tp>
3663valarray<_Tp>
3664valarray<_Tp>::apply(value_type __f(const value_type&)) const
3665{
3666 valarray<value_type> __r;
3667 size_t __n = size();
3668 if (__n)
3669 {
3670 __r.__begin_ =
3671 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003672 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003673 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3674 ::new (__r.__end_) value_type(__f(*__p));
3675 }
3676 return __r;
3677}
3678
3679template <class _Tp>
3680void
3681valarray<_Tp>::resize(size_t __n, value_type __x)
3682{
3683 if (__begin_ != nullptr)
3684 {
3685 while (__end_ != __begin_)
3686 (--__end_)->~value_type();
Eric Fiselier32b19c32017-01-07 03:01:24 +00003687 _VSTD::__libcpp_deallocate(__begin_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003688 __begin_ = __end_ = nullptr;
3689 }
3690 if (__n)
3691 {
Richard Smith73c1fce2014-06-04 19:54:15 +00003692 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003693#ifndef _LIBCPP_NO_EXCEPTIONS
3694 try
3695 {
Howard Hinnant324bb032010-08-22 00:02:43 +00003696#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003697 for (; __n; --__n, ++__end_)
3698 ::new (__end_) value_type(__x);
3699#ifndef _LIBCPP_NO_EXCEPTIONS
3700 }
3701 catch (...)
3702 {
3703 resize(0);
3704 throw;
3705 }
Howard Hinnant324bb032010-08-22 00:02:43 +00003706#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003707 }
3708}
3709
3710template<class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003711inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003712void
Howard Hinnantbd143082012-07-21 00:51:28 +00003713swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003714{
3715 __x.swap(__y);
3716}
3717
3718template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003719inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003720typename enable_if
3721<
3722 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3723 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3724>::type
3725operator*(const _Expr1& __x, const _Expr2& __y)
3726{
3727 typedef typename _Expr1::value_type value_type;
3728 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3729 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3730}
3731
3732template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003733inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003734typename enable_if
3735<
3736 __is_val_expr<_Expr>::value,
3737 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3738 _Expr, __scalar_expr<typename _Expr::value_type> > >
3739>::type
3740operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3741{
3742 typedef typename _Expr::value_type value_type;
3743 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3744 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3745 __x, __scalar_expr<value_type>(__y, __x.size())));
3746}
3747
3748template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003749inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003750typename enable_if
3751<
3752 __is_val_expr<_Expr>::value,
3753 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3754 __scalar_expr<typename _Expr::value_type>, _Expr> >
3755>::type
3756operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3757{
3758 typedef typename _Expr::value_type value_type;
3759 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3760 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3761 __scalar_expr<value_type>(__x, __y.size()), __y));
3762}
3763
3764template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003765inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003766typename enable_if
3767<
3768 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3769 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3770>::type
3771operator/(const _Expr1& __x, const _Expr2& __y)
3772{
3773 typedef typename _Expr1::value_type value_type;
3774 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3775 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3776}
3777
3778template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003779inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003780typename enable_if
3781<
3782 __is_val_expr<_Expr>::value,
3783 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3784 _Expr, __scalar_expr<typename _Expr::value_type> > >
3785>::type
3786operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3787{
3788 typedef typename _Expr::value_type value_type;
3789 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3790 return __val_expr<_Op>(_Op(divides<value_type>(),
3791 __x, __scalar_expr<value_type>(__y, __x.size())));
3792}
3793
3794template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003795inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003796typename enable_if
3797<
3798 __is_val_expr<_Expr>::value,
3799 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3800 __scalar_expr<typename _Expr::value_type>, _Expr> >
3801>::type
3802operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3803{
3804 typedef typename _Expr::value_type value_type;
3805 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3806 return __val_expr<_Op>(_Op(divides<value_type>(),
3807 __scalar_expr<value_type>(__x, __y.size()), __y));
3808}
3809
3810template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003811inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003812typename enable_if
3813<
3814 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3815 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3816>::type
3817operator%(const _Expr1& __x, const _Expr2& __y)
3818{
3819 typedef typename _Expr1::value_type value_type;
3820 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3821 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3822}
3823
3824template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003825inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003826typename enable_if
3827<
3828 __is_val_expr<_Expr>::value,
3829 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3830 _Expr, __scalar_expr<typename _Expr::value_type> > >
3831>::type
3832operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3833{
3834 typedef typename _Expr::value_type value_type;
3835 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3836 return __val_expr<_Op>(_Op(modulus<value_type>(),
3837 __x, __scalar_expr<value_type>(__y, __x.size())));
3838}
3839
3840template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003841inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003842typename enable_if
3843<
3844 __is_val_expr<_Expr>::value,
3845 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3846 __scalar_expr<typename _Expr::value_type>, _Expr> >
3847>::type
3848operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3849{
3850 typedef typename _Expr::value_type value_type;
3851 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3852 return __val_expr<_Op>(_Op(modulus<value_type>(),
3853 __scalar_expr<value_type>(__x, __y.size()), __y));
3854}
3855
3856template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003857inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003858typename enable_if
3859<
3860 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3861 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3862>::type
3863operator+(const _Expr1& __x, const _Expr2& __y)
3864{
3865 typedef typename _Expr1::value_type value_type;
3866 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3867 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3868}
3869
3870template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003871inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003872typename enable_if
3873<
3874 __is_val_expr<_Expr>::value,
3875 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3876 _Expr, __scalar_expr<typename _Expr::value_type> > >
3877>::type
3878operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3879{
3880 typedef typename _Expr::value_type value_type;
3881 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3882 return __val_expr<_Op>(_Op(plus<value_type>(),
3883 __x, __scalar_expr<value_type>(__y, __x.size())));
3884}
3885
3886template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003887inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003888typename enable_if
3889<
3890 __is_val_expr<_Expr>::value,
3891 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3892 __scalar_expr<typename _Expr::value_type>, _Expr> >
3893>::type
3894operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3895{
3896 typedef typename _Expr::value_type value_type;
3897 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3898 return __val_expr<_Op>(_Op(plus<value_type>(),
3899 __scalar_expr<value_type>(__x, __y.size()), __y));
3900}
3901
3902template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003903inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003904typename enable_if
3905<
3906 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3907 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3908>::type
3909operator-(const _Expr1& __x, const _Expr2& __y)
3910{
3911 typedef typename _Expr1::value_type value_type;
3912 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3913 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3914}
3915
3916template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003917inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003918typename enable_if
3919<
3920 __is_val_expr<_Expr>::value,
3921 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3922 _Expr, __scalar_expr<typename _Expr::value_type> > >
3923>::type
3924operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3925{
3926 typedef typename _Expr::value_type value_type;
3927 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3928 return __val_expr<_Op>(_Op(minus<value_type>(),
3929 __x, __scalar_expr<value_type>(__y, __x.size())));
3930}
3931
3932template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003933inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003934typename enable_if
3935<
3936 __is_val_expr<_Expr>::value,
3937 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3938 __scalar_expr<typename _Expr::value_type>, _Expr> >
3939>::type
3940operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3941{
3942 typedef typename _Expr::value_type value_type;
3943 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3944 return __val_expr<_Op>(_Op(minus<value_type>(),
3945 __scalar_expr<value_type>(__x, __y.size()), __y));
3946}
3947
3948template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003949inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003950typename enable_if
3951<
3952 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3953 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3954>::type
3955operator^(const _Expr1& __x, const _Expr2& __y)
3956{
3957 typedef typename _Expr1::value_type value_type;
3958 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3959 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3960}
3961
3962template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003963inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003964typename enable_if
3965<
3966 __is_val_expr<_Expr>::value,
3967 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3968 _Expr, __scalar_expr<typename _Expr::value_type> > >
3969>::type
3970operator^(const _Expr& __x, const typename _Expr::value_type& __y)
3971{
3972 typedef typename _Expr::value_type value_type;
3973 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3974 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3975 __x, __scalar_expr<value_type>(__y, __x.size())));
3976}
3977
3978template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003979inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003980typename enable_if
3981<
3982 __is_val_expr<_Expr>::value,
3983 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3984 __scalar_expr<typename _Expr::value_type>, _Expr> >
3985>::type
3986operator^(const typename _Expr::value_type& __x, const _Expr& __y)
3987{
3988 typedef typename _Expr::value_type value_type;
3989 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3990 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3991 __scalar_expr<value_type>(__x, __y.size()), __y));
3992}
3993
3994template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003995inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003996typename enable_if
3997<
3998 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3999 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4000>::type
4001operator&(const _Expr1& __x, const _Expr2& __y)
4002{
4003 typedef typename _Expr1::value_type value_type;
4004 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
4005 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
4006}
4007
4008template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004009inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004010typename enable_if
4011<
4012 __is_val_expr<_Expr>::value,
4013 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4014 _Expr, __scalar_expr<typename _Expr::value_type> > >
4015>::type
4016operator&(const _Expr& __x, const typename _Expr::value_type& __y)
4017{
4018 typedef typename _Expr::value_type value_type;
4019 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4020 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4021 __x, __scalar_expr<value_type>(__y, __x.size())));
4022}
4023
4024template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004025inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004026typename enable_if
4027<
4028 __is_val_expr<_Expr>::value,
4029 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4030 __scalar_expr<typename _Expr::value_type>, _Expr> >
4031>::type
4032operator&(const typename _Expr::value_type& __x, const _Expr& __y)
4033{
4034 typedef typename _Expr::value_type value_type;
4035 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4036 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4037 __scalar_expr<value_type>(__x, __y.size()), __y));
4038}
4039
4040template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004041inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004042typename enable_if
4043<
4044 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4045 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4046>::type
4047operator|(const _Expr1& __x, const _Expr2& __y)
4048{
4049 typedef typename _Expr1::value_type value_type;
4050 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
4051 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
4052}
4053
4054template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004055inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004056typename enable_if
4057<
4058 __is_val_expr<_Expr>::value,
4059 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4060 _Expr, __scalar_expr<typename _Expr::value_type> > >
4061>::type
4062operator|(const _Expr& __x, const typename _Expr::value_type& __y)
4063{
4064 typedef typename _Expr::value_type value_type;
4065 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4066 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4067 __x, __scalar_expr<value_type>(__y, __x.size())));
4068}
4069
4070template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004071inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004072typename enable_if
4073<
4074 __is_val_expr<_Expr>::value,
4075 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4076 __scalar_expr<typename _Expr::value_type>, _Expr> >
4077>::type
4078operator|(const typename _Expr::value_type& __x, const _Expr& __y)
4079{
4080 typedef typename _Expr::value_type value_type;
4081 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4082 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4083 __scalar_expr<value_type>(__x, __y.size()), __y));
4084}
4085
4086template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004087inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004088typename enable_if
4089<
4090 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4091 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4092>::type
4093operator<<(const _Expr1& __x, const _Expr2& __y)
4094{
4095 typedef typename _Expr1::value_type value_type;
4096 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4097 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4098}
4099
4100template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004101inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004102typename enable_if
4103<
4104 __is_val_expr<_Expr>::value,
4105 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4106 _Expr, __scalar_expr<typename _Expr::value_type> > >
4107>::type
4108operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4109{
4110 typedef typename _Expr::value_type value_type;
4111 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4112 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4113 __x, __scalar_expr<value_type>(__y, __x.size())));
4114}
4115
4116template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004117inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004118typename enable_if
4119<
4120 __is_val_expr<_Expr>::value,
4121 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4122 __scalar_expr<typename _Expr::value_type>, _Expr> >
4123>::type
4124operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4125{
4126 typedef typename _Expr::value_type value_type;
4127 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4128 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4129 __scalar_expr<value_type>(__x, __y.size()), __y));
4130}
4131
4132template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004133inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004134typename enable_if
4135<
4136 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4137 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4138>::type
4139operator>>(const _Expr1& __x, const _Expr2& __y)
4140{
4141 typedef typename _Expr1::value_type value_type;
4142 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4143 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4144}
4145
4146template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004147inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004148typename enable_if
4149<
4150 __is_val_expr<_Expr>::value,
4151 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4152 _Expr, __scalar_expr<typename _Expr::value_type> > >
4153>::type
4154operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4155{
4156 typedef typename _Expr::value_type value_type;
4157 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4158 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4159 __x, __scalar_expr<value_type>(__y, __x.size())));
4160}
4161
4162template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004163inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004164typename enable_if
4165<
4166 __is_val_expr<_Expr>::value,
4167 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4168 __scalar_expr<typename _Expr::value_type>, _Expr> >
4169>::type
4170operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4171{
4172 typedef typename _Expr::value_type value_type;
4173 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4174 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4175 __scalar_expr<value_type>(__x, __y.size()), __y));
4176}
4177
4178template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004179inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004180typename enable_if
4181<
4182 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4183 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4184>::type
4185operator&&(const _Expr1& __x, const _Expr2& __y)
4186{
4187 typedef typename _Expr1::value_type value_type;
4188 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4189 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4190}
4191
4192template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004193inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004194typename enable_if
4195<
4196 __is_val_expr<_Expr>::value,
4197 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4198 _Expr, __scalar_expr<typename _Expr::value_type> > >
4199>::type
4200operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4201{
4202 typedef typename _Expr::value_type value_type;
4203 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4204 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4205 __x, __scalar_expr<value_type>(__y, __x.size())));
4206}
4207
4208template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004209inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004210typename enable_if
4211<
4212 __is_val_expr<_Expr>::value,
4213 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4214 __scalar_expr<typename _Expr::value_type>, _Expr> >
4215>::type
4216operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4217{
4218 typedef typename _Expr::value_type value_type;
4219 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4220 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4221 __scalar_expr<value_type>(__x, __y.size()), __y));
4222}
4223
4224template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004225inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004226typename enable_if
4227<
4228 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4229 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4230>::type
4231operator||(const _Expr1& __x, const _Expr2& __y)
4232{
4233 typedef typename _Expr1::value_type value_type;
4234 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4235 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4236}
4237
4238template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004239inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004240typename enable_if
4241<
4242 __is_val_expr<_Expr>::value,
4243 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4244 _Expr, __scalar_expr<typename _Expr::value_type> > >
4245>::type
4246operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4247{
4248 typedef typename _Expr::value_type value_type;
4249 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4250 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4251 __x, __scalar_expr<value_type>(__y, __x.size())));
4252}
4253
4254template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004255inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004256typename enable_if
4257<
4258 __is_val_expr<_Expr>::value,
4259 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4260 __scalar_expr<typename _Expr::value_type>, _Expr> >
4261>::type
4262operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4263{
4264 typedef typename _Expr::value_type value_type;
4265 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4266 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4267 __scalar_expr<value_type>(__x, __y.size()), __y));
4268}
4269
4270template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004271inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004272typename enable_if
4273<
4274 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4275 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4276>::type
4277operator==(const _Expr1& __x, const _Expr2& __y)
4278{
4279 typedef typename _Expr1::value_type value_type;
4280 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4281 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4282}
4283
4284template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004285inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004286typename enable_if
4287<
4288 __is_val_expr<_Expr>::value,
4289 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4290 _Expr, __scalar_expr<typename _Expr::value_type> > >
4291>::type
4292operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4293{
4294 typedef typename _Expr::value_type value_type;
4295 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4296 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4297 __x, __scalar_expr<value_type>(__y, __x.size())));
4298}
4299
4300template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004301inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004302typename enable_if
4303<
4304 __is_val_expr<_Expr>::value,
4305 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4306 __scalar_expr<typename _Expr::value_type>, _Expr> >
4307>::type
4308operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4309{
4310 typedef typename _Expr::value_type value_type;
4311 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4312 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4313 __scalar_expr<value_type>(__x, __y.size()), __y));
4314}
4315
4316template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004317inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004318typename enable_if
4319<
4320 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4321 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4322>::type
4323operator!=(const _Expr1& __x, const _Expr2& __y)
4324{
4325 typedef typename _Expr1::value_type value_type;
4326 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4327 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4328}
4329
4330template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004331inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004332typename enable_if
4333<
4334 __is_val_expr<_Expr>::value,
4335 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4336 _Expr, __scalar_expr<typename _Expr::value_type> > >
4337>::type
4338operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4339{
4340 typedef typename _Expr::value_type value_type;
4341 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4342 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4343 __x, __scalar_expr<value_type>(__y, __x.size())));
4344}
4345
4346template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004347inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004348typename enable_if
4349<
4350 __is_val_expr<_Expr>::value,
4351 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4352 __scalar_expr<typename _Expr::value_type>, _Expr> >
4353>::type
4354operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4355{
4356 typedef typename _Expr::value_type value_type;
4357 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4358 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4359 __scalar_expr<value_type>(__x, __y.size()), __y));
4360}
4361
4362template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004363inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004364typename enable_if
4365<
4366 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4367 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4368>::type
4369operator<(const _Expr1& __x, const _Expr2& __y)
4370{
4371 typedef typename _Expr1::value_type value_type;
4372 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4373 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4374}
4375
4376template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004377inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004378typename enable_if
4379<
4380 __is_val_expr<_Expr>::value,
4381 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4382 _Expr, __scalar_expr<typename _Expr::value_type> > >
4383>::type
4384operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4385{
4386 typedef typename _Expr::value_type value_type;
4387 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4388 return __val_expr<_Op>(_Op(less<value_type>(),
4389 __x, __scalar_expr<value_type>(__y, __x.size())));
4390}
4391
4392template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004393inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004394typename enable_if
4395<
4396 __is_val_expr<_Expr>::value,
4397 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4398 __scalar_expr<typename _Expr::value_type>, _Expr> >
4399>::type
4400operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4401{
4402 typedef typename _Expr::value_type value_type;
4403 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4404 return __val_expr<_Op>(_Op(less<value_type>(),
4405 __scalar_expr<value_type>(__x, __y.size()), __y));
4406}
4407
4408template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004409inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004410typename enable_if
4411<
4412 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4413 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4414>::type
4415operator>(const _Expr1& __x, const _Expr2& __y)
4416{
4417 typedef typename _Expr1::value_type value_type;
4418 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4419 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4420}
4421
4422template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004423inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004424typename enable_if
4425<
4426 __is_val_expr<_Expr>::value,
4427 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4428 _Expr, __scalar_expr<typename _Expr::value_type> > >
4429>::type
4430operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4431{
4432 typedef typename _Expr::value_type value_type;
4433 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4434 return __val_expr<_Op>(_Op(greater<value_type>(),
4435 __x, __scalar_expr<value_type>(__y, __x.size())));
4436}
4437
4438template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004439inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004440typename enable_if
4441<
4442 __is_val_expr<_Expr>::value,
4443 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4444 __scalar_expr<typename _Expr::value_type>, _Expr> >
4445>::type
4446operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4447{
4448 typedef typename _Expr::value_type value_type;
4449 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4450 return __val_expr<_Op>(_Op(greater<value_type>(),
4451 __scalar_expr<value_type>(__x, __y.size()), __y));
4452}
4453
4454template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004455inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004456typename enable_if
4457<
4458 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4459 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4460>::type
4461operator<=(const _Expr1& __x, const _Expr2& __y)
4462{
4463 typedef typename _Expr1::value_type value_type;
4464 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4465 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4466}
4467
4468template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004469inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004470typename enable_if
4471<
4472 __is_val_expr<_Expr>::value,
4473 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4474 _Expr, __scalar_expr<typename _Expr::value_type> > >
4475>::type
4476operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4477{
4478 typedef typename _Expr::value_type value_type;
4479 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4480 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4481 __x, __scalar_expr<value_type>(__y, __x.size())));
4482}
4483
4484template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004485inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004486typename enable_if
4487<
4488 __is_val_expr<_Expr>::value,
4489 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4490 __scalar_expr<typename _Expr::value_type>, _Expr> >
4491>::type
4492operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4493{
4494 typedef typename _Expr::value_type value_type;
4495 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4496 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4497 __scalar_expr<value_type>(__x, __y.size()), __y));
4498}
4499
4500template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004501inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004502typename enable_if
4503<
4504 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4505 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4506>::type
4507operator>=(const _Expr1& __x, const _Expr2& __y)
4508{
4509 typedef typename _Expr1::value_type value_type;
4510 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4511 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4512}
4513
4514template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004515inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004516typename enable_if
4517<
4518 __is_val_expr<_Expr>::value,
4519 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4520 _Expr, __scalar_expr<typename _Expr::value_type> > >
4521>::type
4522operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4523{
4524 typedef typename _Expr::value_type value_type;
4525 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4526 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4527 __x, __scalar_expr<value_type>(__y, __x.size())));
4528}
4529
4530template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004531inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004532typename enable_if
4533<
4534 __is_val_expr<_Expr>::value,
4535 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4536 __scalar_expr<typename _Expr::value_type>, _Expr> >
4537>::type
4538operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4539{
4540 typedef typename _Expr::value_type value_type;
4541 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4542 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4543 __scalar_expr<value_type>(__x, __y.size()), __y));
4544}
4545
4546template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004547inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004548typename enable_if
4549<
4550 __is_val_expr<_Expr>::value,
4551 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4552>::type
4553abs(const _Expr& __x)
4554{
4555 typedef typename _Expr::value_type value_type;
4556 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4557 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4558}
4559
4560template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004561inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004562typename enable_if
4563<
4564 __is_val_expr<_Expr>::value,
4565 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4566>::type
4567acos(const _Expr& __x)
4568{
4569 typedef typename _Expr::value_type value_type;
4570 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4571 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4572}
4573
4574template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004575inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004576typename enable_if
4577<
4578 __is_val_expr<_Expr>::value,
4579 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4580>::type
4581asin(const _Expr& __x)
4582{
4583 typedef typename _Expr::value_type value_type;
4584 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4585 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4586}
4587
4588template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004589inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004590typename enable_if
4591<
4592 __is_val_expr<_Expr>::value,
4593 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4594>::type
4595atan(const _Expr& __x)
4596{
4597 typedef typename _Expr::value_type value_type;
4598 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4599 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4600}
4601
4602template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004603inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004604typename enable_if
4605<
4606 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4607 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4608>::type
4609atan2(const _Expr1& __x, const _Expr2& __y)
4610{
4611 typedef typename _Expr1::value_type value_type;
4612 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4613 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4614}
4615
4616template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004617inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004618typename enable_if
4619<
4620 __is_val_expr<_Expr>::value,
4621 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4622 _Expr, __scalar_expr<typename _Expr::value_type> > >
4623>::type
4624atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4625{
4626 typedef typename _Expr::value_type value_type;
4627 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4628 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4629 __x, __scalar_expr<value_type>(__y, __x.size())));
4630}
4631
4632template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004633inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004634typename enable_if
4635<
4636 __is_val_expr<_Expr>::value,
4637 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4638 __scalar_expr<typename _Expr::value_type>, _Expr> >
4639>::type
4640atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4641{
4642 typedef typename _Expr::value_type value_type;
4643 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4644 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4645 __scalar_expr<value_type>(__x, __y.size()), __y));
4646}
4647
4648template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004649inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004650typename enable_if
4651<
4652 __is_val_expr<_Expr>::value,
4653 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4654>::type
4655cos(const _Expr& __x)
4656{
4657 typedef typename _Expr::value_type value_type;
4658 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4659 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4660}
4661
4662template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004663inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004664typename enable_if
4665<
4666 __is_val_expr<_Expr>::value,
4667 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4668>::type
4669cosh(const _Expr& __x)
4670{
4671 typedef typename _Expr::value_type value_type;
4672 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4673 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4674}
4675
4676template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004677inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004678typename enable_if
4679<
4680 __is_val_expr<_Expr>::value,
4681 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4682>::type
4683exp(const _Expr& __x)
4684{
4685 typedef typename _Expr::value_type value_type;
4686 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4687 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4688}
4689
4690template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004691inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004692typename enable_if
4693<
4694 __is_val_expr<_Expr>::value,
4695 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4696>::type
4697log(const _Expr& __x)
4698{
4699 typedef typename _Expr::value_type value_type;
4700 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4701 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4702}
4703
4704template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004705inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004706typename enable_if
4707<
4708 __is_val_expr<_Expr>::value,
4709 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4710>::type
4711log10(const _Expr& __x)
4712{
4713 typedef typename _Expr::value_type value_type;
4714 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4715 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4716}
4717
4718template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004719inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004720typename enable_if
4721<
4722 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4723 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4724>::type
4725pow(const _Expr1& __x, const _Expr2& __y)
4726{
4727 typedef typename _Expr1::value_type value_type;
4728 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4729 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4730}
4731
4732template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004733inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004734typename enable_if
4735<
4736 __is_val_expr<_Expr>::value,
4737 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4738 _Expr, __scalar_expr<typename _Expr::value_type> > >
4739>::type
4740pow(const _Expr& __x, const typename _Expr::value_type& __y)
4741{
4742 typedef typename _Expr::value_type value_type;
4743 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4744 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4745 __x, __scalar_expr<value_type>(__y, __x.size())));
4746}
4747
4748template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004749inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004750typename enable_if
4751<
4752 __is_val_expr<_Expr>::value,
4753 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4754 __scalar_expr<typename _Expr::value_type>, _Expr> >
4755>::type
4756pow(const typename _Expr::value_type& __x, const _Expr& __y)
4757{
4758 typedef typename _Expr::value_type value_type;
4759 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4760 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4761 __scalar_expr<value_type>(__x, __y.size()), __y));
4762}
4763
4764template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004765inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004766typename enable_if
4767<
4768 __is_val_expr<_Expr>::value,
4769 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4770>::type
4771sin(const _Expr& __x)
4772{
4773 typedef typename _Expr::value_type value_type;
4774 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4775 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4776}
4777
4778template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004779inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004780typename enable_if
4781<
4782 __is_val_expr<_Expr>::value,
4783 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4784>::type
4785sinh(const _Expr& __x)
4786{
4787 typedef typename _Expr::value_type value_type;
4788 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4789 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4790}
4791
4792template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004793inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004794typename enable_if
4795<
4796 __is_val_expr<_Expr>::value,
4797 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4798>::type
4799sqrt(const _Expr& __x)
4800{
4801 typedef typename _Expr::value_type value_type;
4802 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4803 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4804}
4805
4806template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004807inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004808typename enable_if
4809<
4810 __is_val_expr<_Expr>::value,
4811 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4812>::type
4813tan(const _Expr& __x)
4814{
4815 typedef typename _Expr::value_type value_type;
4816 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4817 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4818}
4819
4820template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004821inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004822typename enable_if
4823<
4824 __is_val_expr<_Expr>::value,
4825 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4826>::type
4827tanh(const _Expr& __x)
4828{
4829 typedef typename _Expr::value_type value_type;
4830 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4831 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4832}
4833
4834template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004835inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004836_Tp*
4837begin(valarray<_Tp>& __v)
4838{
4839 return __v.__begin_;
4840}
4841
4842template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004843inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004844const _Tp*
4845begin(const valarray<_Tp>& __v)
4846{
4847 return __v.__begin_;
4848}
4849
4850template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004851inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004852_Tp*
4853end(valarray<_Tp>& __v)
4854{
4855 return __v.__end_;
4856}
4857
4858template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004859inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004860const _Tp*
4861end(const valarray<_Tp>& __v)
4862{
4863 return __v.__end_;
4864}
4865
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004866_LIBCPP_END_NAMESPACE_STD
4867
4868#endif // _LIBCPP_VALARRAY