blob: ee61238a932f34400cdee3175286dfac24a34f38 [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 Hinnant08e17472011-10-17 20:05:10 +0000350#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000351#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000352#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000353
Eric Fiselier018a3d52017-05-31 22:07:49 +0000354_LIBCPP_PUSH_MACROS
355#include <__undef_macros>
356
357
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000358_LIBCPP_BEGIN_NAMESPACE_STD
359
Eric Fiselierc3589a82017-01-04 23:56:00 +0000360template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000361
Eric Fiselierc3589a82017-01-04 23:56:00 +0000362class _LIBCPP_TEMPLATE_VIS slice
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000363{
364 size_t __start_;
365 size_t __size_;
366 size_t __stride_;
367public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000368 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000369 slice()
370 : __start_(0),
371 __size_(0),
372 __stride_(0)
373 {}
374
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000375 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000376 slice(size_t __start, size_t __size, size_t __stride)
377 : __start_(__start),
378 __size_(__size),
379 __stride_(__stride)
380 {}
381
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000382 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
383 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
384 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000385};
386
Eric Fiselierc3589a82017-01-04 23:56:00 +0000387template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
Howard Hinnant83eade62013-03-06 23:30:19 +0000388class _LIBCPP_TYPE_VIS gslice;
Eric Fiselierc3589a82017-01-04 23:56:00 +0000389template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
390template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
391template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000392
393template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000394_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000395_Tp*
396begin(valarray<_Tp>& __v);
397
398template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000399_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000400const _Tp*
401begin(const valarray<_Tp>& __v);
402
403template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000404_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000405_Tp*
406end(valarray<_Tp>& __v);
407
408template <class _Tp>
Howard Hinnant33be35e2012-09-14 00:39:16 +0000409_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000410const _Tp*
411end(const valarray<_Tp>& __v);
412
413template <class _Op, class _A0>
414struct _UnaryOp
415{
416 typedef typename _Op::result_type result_type;
417 typedef typename _A0::value_type value_type;
418
419 _Op __op_;
420 _A0 __a0_;
421
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000422 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000423 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
424
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000425 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000426 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
427
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000428 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000429 size_t size() const {return __a0_.size();}
430};
431
432template <class _Op, class _A0, class _A1>
433struct _BinaryOp
434{
435 typedef typename _Op::result_type result_type;
436 typedef typename _A0::value_type value_type;
437
438 _Op __op_;
439 _A0 __a0_;
440 _A1 __a1_;
441
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000442 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000443 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
444 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
445
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000446 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000447 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
448
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000449 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000450 size_t size() const {return __a0_.size();}
451};
452
453template <class _Tp>
454class __scalar_expr
455{
456public:
457 typedef _Tp value_type;
458 typedef const _Tp& result_type;
459private:
460 const value_type& __t_;
461 size_t __s_;
462public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000463 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000464 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
465
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000466 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000467 result_type operator[](size_t) const {return __t_;}
468
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000469 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000470 size_t size() const {return __s_;}
471};
472
473template <class _Tp>
474struct __unary_plus : unary_function<_Tp, _Tp>
475{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000476 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000477 _Tp operator()(const _Tp& __x) const
478 {return +__x;}
479};
480
481template <class _Tp>
482struct __bit_not : unary_function<_Tp, _Tp>
483{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000484 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000485 _Tp operator()(const _Tp& __x) const
486 {return ~__x;}
487};
488
489template <class _Tp>
490struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
491{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000492 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000493 _Tp operator()(const _Tp& __x, const _Tp& __y) const
494 {return __x << __y;}
495};
496
497template <class _Tp>
498struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
499{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000500 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000501 _Tp operator()(const _Tp& __x, const _Tp& __y) const
502 {return __x >> __y;}
503};
504
Howard Hinnant99968442011-11-29 18:15:50 +0000505template <class _Tp, class _Fp>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000506struct __apply_expr : unary_function<_Tp, _Tp>
507{
508private:
Howard Hinnant99968442011-11-29 18:15:50 +0000509 _Fp __f_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000510public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000511 _LIBCPP_INLINE_VISIBILITY
Howard Hinnant99968442011-11-29 18:15:50 +0000512 explicit __apply_expr(_Fp __f) : __f_(__f) {}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000513
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000514 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000515 _Tp operator()(const _Tp& __x) const
516 {return __f_(__x);}
517};
518
519template <class _Tp>
520struct __abs_expr : unary_function<_Tp, _Tp>
521{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000522 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000523 _Tp operator()(const _Tp& __x) const
524 {return abs(__x);}
525};
526
527template <class _Tp>
528struct __acos_expr : unary_function<_Tp, _Tp>
529{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000530 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000531 _Tp operator()(const _Tp& __x) const
532 {return acos(__x);}
533};
534
535template <class _Tp>
536struct __asin_expr : unary_function<_Tp, _Tp>
537{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000538 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000539 _Tp operator()(const _Tp& __x) const
540 {return asin(__x);}
541};
542
543template <class _Tp>
544struct __atan_expr : unary_function<_Tp, _Tp>
545{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000546 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000547 _Tp operator()(const _Tp& __x) const
548 {return atan(__x);}
549};
550
551template <class _Tp>
552struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
553{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000554 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000555 _Tp operator()(const _Tp& __x, const _Tp& __y) const
556 {return atan2(__x, __y);}
557};
558
559template <class _Tp>
560struct __cos_expr : unary_function<_Tp, _Tp>
561{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000562 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000563 _Tp operator()(const _Tp& __x) const
564 {return cos(__x);}
565};
566
567template <class _Tp>
568struct __cosh_expr : unary_function<_Tp, _Tp>
569{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000570 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000571 _Tp operator()(const _Tp& __x) const
572 {return cosh(__x);}
573};
574
575template <class _Tp>
576struct __exp_expr : unary_function<_Tp, _Tp>
577{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000578 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000579 _Tp operator()(const _Tp& __x) const
580 {return exp(__x);}
581};
582
583template <class _Tp>
584struct __log_expr : unary_function<_Tp, _Tp>
585{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000586 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000587 _Tp operator()(const _Tp& __x) const
588 {return log(__x);}
589};
590
591template <class _Tp>
592struct __log10_expr : unary_function<_Tp, _Tp>
593{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000594 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000595 _Tp operator()(const _Tp& __x) const
596 {return log10(__x);}
597};
598
599template <class _Tp>
600struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
601{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000603 _Tp operator()(const _Tp& __x, const _Tp& __y) const
604 {return pow(__x, __y);}
605};
606
607template <class _Tp>
608struct __sin_expr : unary_function<_Tp, _Tp>
609{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000610 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000611 _Tp operator()(const _Tp& __x) const
612 {return sin(__x);}
613};
614
615template <class _Tp>
616struct __sinh_expr : unary_function<_Tp, _Tp>
617{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000618 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000619 _Tp operator()(const _Tp& __x) const
620 {return sinh(__x);}
621};
622
623template <class _Tp>
624struct __sqrt_expr : unary_function<_Tp, _Tp>
625{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000626 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000627 _Tp operator()(const _Tp& __x) const
628 {return sqrt(__x);}
629};
630
631template <class _Tp>
632struct __tan_expr : unary_function<_Tp, _Tp>
633{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000634 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000635 _Tp operator()(const _Tp& __x) const
636 {return tan(__x);}
637};
638
639template <class _Tp>
640struct __tanh_expr : unary_function<_Tp, _Tp>
641{
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000642 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000643 _Tp operator()(const _Tp& __x) const
644 {return tanh(__x);}
645};
646
647template <class _ValExpr>
648class __slice_expr
649{
650 typedef typename remove_reference<_ValExpr>::type _RmExpr;
651public:
652 typedef typename _RmExpr::value_type value_type;
653 typedef value_type result_type;
654
655private:
656 _ValExpr __expr_;
657 size_t __start_;
658 size_t __size_;
659 size_t __stride_;
660
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000661 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000662 __slice_expr(const slice& __sl, const _RmExpr& __e)
663 : __expr_(__e),
664 __start_(__sl.start()),
665 __size_(__sl.size()),
666 __stride_(__sl.stride())
667 {}
668public:
669
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000670 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000671 result_type operator[](size_t __i) const
672 {return __expr_[__start_ + __i * __stride_];}
673
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000674 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000675 size_t size() const {return __size_;}
676
Eric Fiselierc3589a82017-01-04 23:56:00 +0000677 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000678};
679
680template <class _ValExpr>
681class __mask_expr;
682
683template <class _ValExpr>
684class __indirect_expr;
685
686template <class _ValExpr>
687class __shift_expr
688{
689 typedef typename remove_reference<_ValExpr>::type _RmExpr;
690public:
691 typedef typename _RmExpr::value_type value_type;
692 typedef value_type result_type;
693
694private:
695 _ValExpr __expr_;
696 size_t __size_;
697 ptrdiff_t __ul_;
698 ptrdiff_t __sn_;
699 ptrdiff_t __n_;
Howard Hinnant99968442011-11-29 18:15:50 +0000700 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000701 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
702
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000703 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000704 __shift_expr(int __n, const _RmExpr& __e)
705 : __expr_(__e),
706 __size_(__e.size()),
707 __n_(__n)
708 {
Howard Hinnant99968442011-11-29 18:15:50 +0000709 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
710 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000711 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
712 }
713public:
714
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000715 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000716 result_type operator[](size_t __j) const
717 {
Howard Hinnantec3773c2011-12-01 20:21:04 +0000718 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
Howard Hinnant99968442011-11-29 18:15:50 +0000719 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000720 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
721 }
722
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000723 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000724 size_t size() const {return __size_;}
725
726 template <class> friend class __val_expr;
727};
728
729template <class _ValExpr>
730class __cshift_expr
731{
732 typedef typename remove_reference<_ValExpr>::type _RmExpr;
733public:
734 typedef typename _RmExpr::value_type value_type;
735 typedef value_type result_type;
736
737private:
738 _ValExpr __expr_;
739 size_t __size_;
740 size_t __m_;
741 size_t __o1_;
742 size_t __o2_;
743
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000744 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000745 __cshift_expr(int __n, const _RmExpr& __e)
746 : __expr_(__e),
747 __size_(__e.size())
748 {
749 __n %= static_cast<int>(__size_);
750 if (__n >= 0)
751 {
752 __m_ = __size_ - __n;
753 __o1_ = __n;
754 __o2_ = __n - __size_;
755 }
756 else
757 {
758 __m_ = -__n;
759 __o1_ = __n + __size_;
760 __o2_ = __n;
761 }
762 }
763public:
764
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000765 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000766 result_type operator[](size_t __i) const
767 {
768 if (__i < __m_)
769 return __expr_[__i + __o1_];
770 return __expr_[__i + __o2_];
771 }
772
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000773 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000774 size_t size() const {return __size_;}
775
776 template <class> friend class __val_expr;
777};
778
779template<class _ValExpr>
780class __val_expr;
781
782template<class _ValExpr>
783struct __is_val_expr : false_type {};
784
785template<class _ValExpr>
786struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
787
788template<class _Tp>
789struct __is_val_expr<valarray<_Tp> > : true_type {};
790
791template<class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +0000792class _LIBCPP_TEMPLATE_VIS valarray
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000793{
794public:
795 typedef _Tp value_type;
796 typedef _Tp result_type;
797
798private:
799 value_type* __begin_;
800 value_type* __end_;
801
802public:
803 // construct/destroy:
Douglas Gregor0855dde2012-05-19 07:14:17 +0000804 _LIBCPP_INLINE_VISIBILITY
805 valarray() : __begin_(0), __end_(0) {}
Eric Fiselierb6a049f2016-09-16 00:13:55 +0000806 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
807 explicit valarray(size_t __n);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000808 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000809 valarray(const value_type& __x, size_t __n);
810 valarray(const value_type* __p, size_t __n);
811 valarray(const valarray& __v);
Eric Fiselier97db5172017-04-19 00:23:45 +0000812#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000813 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd143082012-07-21 00:51:28 +0000814 valarray(valarray&& __v) _NOEXCEPT;
Douglas Gregor0855dde2012-05-19 07:14:17 +0000815 valarray(initializer_list<value_type> __il);
Eric Fiselier97db5172017-04-19 00:23:45 +0000816#endif // _LIBCPP_CXX03_LANG
Douglas Gregor0855dde2012-05-19 07:14:17 +0000817 valarray(const slice_array<value_type>& __sa);
818 valarray(const gslice_array<value_type>& __ga);
819 valarray(const mask_array<value_type>& __ma);
820 valarray(const indirect_array<value_type>& __ia);
Eric Fiselierb6a049f2016-09-16 00:13:55 +0000821 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000822 ~valarray();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000823
824 // assignment:
Douglas Gregor0855dde2012-05-19 07:14:17 +0000825 valarray& operator=(const valarray& __v);
Eric Fiselier97db5172017-04-19 00:23:45 +0000826#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000827 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd143082012-07-21 00:51:28 +0000828 valarray& operator=(valarray&& __v) _NOEXCEPT;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000829 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000830 valarray& operator=(initializer_list<value_type>);
Eric Fiselier97db5172017-04-19 00:23:45 +0000831#endif // _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000832 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +0000833 valarray& operator=(const value_type& __x);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000834 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000835 valarray& operator=(const slice_array<value_type>& __sa);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000836 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000837 valarray& operator=(const gslice_array<value_type>& __ga);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000838 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000839 valarray& operator=(const mask_array<value_type>& __ma);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000840 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000841 valarray& operator=(const indirect_array<value_type>& __ia);
Howard Hinnantdb866632011-07-27 23:19:59 +0000842 template <class _ValExpr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000843 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantdb866632011-07-27 23:19:59 +0000844 valarray& operator=(const __val_expr<_ValExpr>& __v);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000845
846 // element access:
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000847 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000848 const value_type& operator[](size_t __i) const {return __begin_[__i];}
849
Howard Hinnantee6ccd02010-09-23 18:58:28 +0000850 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000851 value_type& operator[](size_t __i) {return __begin_[__i];}
852
853 // subset operations:
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000854 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000855 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000856 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000857 slice_array<value_type> operator[](slice __s);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000858 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000859 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000860 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000861 gslice_array<value_type> operator[](const gslice& __gs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000862#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000863 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000864 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000865 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000866 gslice_array<value_type> operator[](gslice&& __gs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000867#endif // _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000868 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000869 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000870 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000871 mask_array<value_type> operator[](const valarray<bool>& __vb);
Eric Fiselier97db5172017-04-19 00:23:45 +0000872#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000873 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000874 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000875 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000876 mask_array<value_type> operator[](valarray<bool>&& __vb);
Eric Fiselier97db5172017-04-19 00:23:45 +0000877#endif // _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000878 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000879 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000880 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000881 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000882#ifndef _LIBCPP_CXX03_LANG
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000883 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000884 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000885 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000886 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
Eric Fiselier97db5172017-04-19 00:23:45 +0000887#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000888
889 // unary operators:
Douglas Gregor0855dde2012-05-19 07:14:17 +0000890 valarray operator+() const;
891 valarray operator-() const;
892 valarray operator~() const;
893 valarray<bool> operator!() const;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000894
895 // computed assignment:
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);
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000914 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000915 valarray& operator>>=(const value_type& __x);
916
917 template <class _Expr>
918 typename enable_if
919 <
920 __is_val_expr<_Expr>::value,
921 valarray&
922 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000923 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000924 operator*= (const _Expr& __v);
925
926 template <class _Expr>
927 typename enable_if
928 <
929 __is_val_expr<_Expr>::value,
930 valarray&
931 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000932 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000933 operator/= (const _Expr& __v);
934
935 template <class _Expr>
936 typename enable_if
937 <
938 __is_val_expr<_Expr>::value,
939 valarray&
940 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000941 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000942 operator%= (const _Expr& __v);
943
944 template <class _Expr>
945 typename enable_if
946 <
947 __is_val_expr<_Expr>::value,
948 valarray&
949 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000950 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000951 operator+= (const _Expr& __v);
952
953 template <class _Expr>
954 typename enable_if
955 <
956 __is_val_expr<_Expr>::value,
957 valarray&
958 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000959 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000960 operator-= (const _Expr& __v);
961
962 template <class _Expr>
963 typename enable_if
964 <
965 __is_val_expr<_Expr>::value,
966 valarray&
967 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000968 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000969 operator^= (const _Expr& __v);
970
971 template <class _Expr>
972 typename enable_if
973 <
974 __is_val_expr<_Expr>::value,
975 valarray&
976 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000977 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000978 operator|= (const _Expr& __v);
979
980 template <class _Expr>
981 typename enable_if
982 <
983 __is_val_expr<_Expr>::value,
984 valarray&
985 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000986 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000987 operator&= (const _Expr& __v);
988
989 template <class _Expr>
990 typename enable_if
991 <
992 __is_val_expr<_Expr>::value,
993 valarray&
994 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +0000995 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000996 operator<<= (const _Expr& __v);
997
998 template <class _Expr>
999 typename enable_if
1000 <
1001 __is_val_expr<_Expr>::value,
1002 valarray&
1003 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001004 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001005 operator>>= (const _Expr& __v);
1006
1007 // member functions:
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001008 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbd143082012-07-21 00:51:28 +00001009 void swap(valarray& __v) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001010
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001011 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantec3773c2011-12-01 20:21:04 +00001012 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001013
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001014 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +00001015 value_type sum() const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001016 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +00001017 value_type min() const;
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001018 _LIBCPP_INLINE_VISIBILITY
Douglas Gregor0855dde2012-05-19 07:14:17 +00001019 value_type max() const;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001020
Douglas Gregor0855dde2012-05-19 07:14:17 +00001021 valarray shift (int __i) const;
1022 valarray cshift(int __i) const;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001023 valarray apply(value_type __f(value_type)) const;
1024 valarray apply(value_type __f(const value_type&)) const;
1025 void resize(size_t __n, value_type __x = value_type());
1026
1027private:
Eric Fiselierc3589a82017-01-04 23:56:00 +00001028 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
1029 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
1030 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
1031 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001032 template <class> friend class __mask_expr;
Eric Fiselierc3589a82017-01-04 23:56:00 +00001033 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001034 template <class> friend class __indirect_expr;
1035 template <class> friend class __val_expr;
1036
1037 template <class _Up>
1038 friend
1039 _Up*
1040 begin(valarray<_Up>& __v);
Howard Hinnant324bb032010-08-22 00:02:43 +00001041
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001042 template <class _Up>
1043 friend
1044 const _Up*
1045 begin(const valarray<_Up>& __v);
Howard Hinnant324bb032010-08-22 00:02:43 +00001046
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001047 template <class _Up>
1048 friend
1049 _Up*
1050 end(valarray<_Up>& __v);
Howard Hinnant324bb032010-08-22 00:02:43 +00001051
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001052 template <class _Up>
1053 friend
1054 const _Up*
1055 end(const valarray<_Up>& __v);
1056};
1057
Howard Hinnant0f678bd2013-08-12 18:38:34 +00001058_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
1059_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
1060_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1061
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001062template <class _Op, class _Tp>
1063struct _UnaryOp<_Op, valarray<_Tp> >
1064{
1065 typedef typename _Op::result_type result_type;
1066 typedef _Tp value_type;
1067
1068 _Op __op_;
1069 const valarray<_Tp>& __a0_;
1070
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001071 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001072 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1073
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001074 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001075 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1076
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001077 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001078 size_t size() const {return __a0_.size();}
1079};
1080
1081template <class _Op, class _Tp, class _A1>
1082struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1083{
1084 typedef typename _Op::result_type result_type;
1085 typedef _Tp value_type;
1086
1087 _Op __op_;
1088 const valarray<_Tp>& __a0_;
1089 _A1 __a1_;
1090
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001091 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001092 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1093 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1094
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001095 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001096 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1097
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001098 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001099 size_t size() const {return __a0_.size();}
1100};
1101
1102template <class _Op, class _A0, class _Tp>
1103struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1104{
1105 typedef typename _Op::result_type result_type;
1106 typedef _Tp value_type;
1107
1108 _Op __op_;
1109 _A0 __a0_;
1110 const valarray<_Tp>& __a1_;
1111
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001112 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001113 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1114 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1115
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001116 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001117 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1118
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001119 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001120 size_t size() const {return __a0_.size();}
1121};
1122
1123template <class _Op, class _Tp>
1124struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1125{
1126 typedef typename _Op::result_type result_type;
1127 typedef _Tp value_type;
1128
1129 _Op __op_;
1130 const valarray<_Tp>& __a0_;
1131 const valarray<_Tp>& __a1_;
1132
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001133 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001134 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1135 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1136
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001137 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001138 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1139
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001140 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001141 size_t size() const {return __a0_.size();}
1142};
1143
1144// slice_array
1145
1146template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00001147class _LIBCPP_TEMPLATE_VIS slice_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001148{
1149public:
1150 typedef _Tp value_type;
1151
1152private:
1153 value_type* __vp_;
1154 size_t __size_;
1155 size_t __stride_;
1156
1157public:
1158 template <class _Expr>
1159 typename enable_if
1160 <
1161 __is_val_expr<_Expr>::value,
1162 void
1163 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001164 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001165 operator=(const _Expr& __v) const;
1166
1167 template <class _Expr>
1168 typename enable_if
1169 <
1170 __is_val_expr<_Expr>::value,
1171 void
1172 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001173 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001174 operator*=(const _Expr& __v) const;
1175
1176 template <class _Expr>
1177 typename enable_if
1178 <
1179 __is_val_expr<_Expr>::value,
1180 void
1181 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001182 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001183 operator/=(const _Expr& __v) const;
1184
1185 template <class _Expr>
1186 typename enable_if
1187 <
1188 __is_val_expr<_Expr>::value,
1189 void
1190 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001191 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001192 operator%=(const _Expr& __v) const;
1193
1194 template <class _Expr>
1195 typename enable_if
1196 <
1197 __is_val_expr<_Expr>::value,
1198 void
1199 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001200 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001201 operator+=(const _Expr& __v) const;
1202
1203 template <class _Expr>
1204 typename enable_if
1205 <
1206 __is_val_expr<_Expr>::value,
1207 void
1208 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001209 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001210 operator-=(const _Expr& __v) const;
1211
1212 template <class _Expr>
1213 typename enable_if
1214 <
1215 __is_val_expr<_Expr>::value,
1216 void
1217 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001218 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001219 operator^=(const _Expr& __v) const;
1220
1221 template <class _Expr>
1222 typename enable_if
1223 <
1224 __is_val_expr<_Expr>::value,
1225 void
1226 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001227 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001228 operator&=(const _Expr& __v) const;
1229
1230 template <class _Expr>
1231 typename enable_if
1232 <
1233 __is_val_expr<_Expr>::value,
1234 void
1235 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001236 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001237 operator|=(const _Expr& __v) const;
1238
1239 template <class _Expr>
1240 typename enable_if
1241 <
1242 __is_val_expr<_Expr>::value,
1243 void
1244 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001245 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001246 operator<<=(const _Expr& __v) const;
1247
1248 template <class _Expr>
1249 typename enable_if
1250 <
1251 __is_val_expr<_Expr>::value,
1252 void
1253 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001254 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001255 operator>>=(const _Expr& __v) const;
1256
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001257 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001258 const slice_array& operator=(const slice_array& __sa) const;
1259
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001260 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001261 void operator=(const value_type& __x) const;
1262
1263private:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001264 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001265 slice_array(const slice& __sl, const valarray<value_type>& __v)
1266 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1267 __size_(__sl.size()),
1268 __stride_(__sl.stride())
1269 {}
1270
1271 template <class> friend class valarray;
1272 template <class> friend class sliceExpr;
1273};
1274
1275template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001276inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001277const slice_array<_Tp>&
1278slice_array<_Tp>::operator=(const slice_array& __sa) const
1279{
1280 value_type* __t = __vp_;
1281 const value_type* __s = __sa.__vp_;
1282 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1283 *__t = *__s;
Eric Fiselierf4124612014-08-12 00:06:58 +00001284 return *this;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001285}
1286
1287template <class _Tp>
1288template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001289inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001290typename enable_if
1291<
1292 __is_val_expr<_Expr>::value,
1293 void
1294>::type
1295slice_array<_Tp>::operator=(const _Expr& __v) const
1296{
1297 value_type* __t = __vp_;
1298 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1299 *__t = __v[__i];
1300}
1301
1302template <class _Tp>
1303template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001304inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001305typename enable_if
1306<
1307 __is_val_expr<_Expr>::value,
1308 void
1309>::type
1310slice_array<_Tp>::operator*=(const _Expr& __v) const
1311{
1312 value_type* __t = __vp_;
1313 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1314 *__t *= __v[__i];
1315}
1316
1317template <class _Tp>
1318template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001319inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001320typename enable_if
1321<
1322 __is_val_expr<_Expr>::value,
1323 void
1324>::type
1325slice_array<_Tp>::operator/=(const _Expr& __v) const
1326{
1327 value_type* __t = __vp_;
1328 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1329 *__t /= __v[__i];
1330}
1331
1332template <class _Tp>
1333template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001334inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001335typename enable_if
1336<
1337 __is_val_expr<_Expr>::value,
1338 void
1339>::type
1340slice_array<_Tp>::operator%=(const _Expr& __v) const
1341{
1342 value_type* __t = __vp_;
1343 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1344 *__t %= __v[__i];
1345}
1346
1347template <class _Tp>
1348template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001349inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001350typename enable_if
1351<
1352 __is_val_expr<_Expr>::value,
1353 void
1354>::type
1355slice_array<_Tp>::operator+=(const _Expr& __v) const
1356{
1357 value_type* __t = __vp_;
1358 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1359 *__t += __v[__i];
1360}
1361
1362template <class _Tp>
1363template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001364inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001365typename enable_if
1366<
1367 __is_val_expr<_Expr>::value,
1368 void
1369>::type
1370slice_array<_Tp>::operator-=(const _Expr& __v) const
1371{
1372 value_type* __t = __vp_;
1373 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1374 *__t -= __v[__i];
1375}
1376
1377template <class _Tp>
1378template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001379inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001380typename enable_if
1381<
1382 __is_val_expr<_Expr>::value,
1383 void
1384>::type
1385slice_array<_Tp>::operator^=(const _Expr& __v) const
1386{
1387 value_type* __t = __vp_;
1388 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1389 *__t ^= __v[__i];
1390}
1391
1392template <class _Tp>
1393template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001394inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001395typename enable_if
1396<
1397 __is_val_expr<_Expr>::value,
1398 void
1399>::type
1400slice_array<_Tp>::operator&=(const _Expr& __v) const
1401{
1402 value_type* __t = __vp_;
1403 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1404 *__t &= __v[__i];
1405}
1406
1407template <class _Tp>
1408template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001409inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001410typename enable_if
1411<
1412 __is_val_expr<_Expr>::value,
1413 void
1414>::type
1415slice_array<_Tp>::operator|=(const _Expr& __v) const
1416{
1417 value_type* __t = __vp_;
1418 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1419 *__t |= __v[__i];
1420}
1421
1422template <class _Tp>
1423template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001424inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001425typename enable_if
1426<
1427 __is_val_expr<_Expr>::value,
1428 void
1429>::type
1430slice_array<_Tp>::operator<<=(const _Expr& __v) const
1431{
1432 value_type* __t = __vp_;
1433 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1434 *__t <<= __v[__i];
1435}
1436
1437template <class _Tp>
1438template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001439inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001440typename enable_if
1441<
1442 __is_val_expr<_Expr>::value,
1443 void
1444>::type
1445slice_array<_Tp>::operator>>=(const _Expr& __v) const
1446{
1447 value_type* __t = __vp_;
1448 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1449 *__t >>= __v[__i];
1450}
1451
1452template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001453inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001454void
1455slice_array<_Tp>::operator=(const value_type& __x) const
1456{
1457 value_type* __t = __vp_;
1458 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1459 *__t = __x;
1460}
1461
1462// gslice
1463
Howard Hinnant83eade62013-03-06 23:30:19 +00001464class _LIBCPP_TYPE_VIS gslice
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001465{
1466 valarray<size_t> __size_;
1467 valarray<size_t> __stride_;
1468 valarray<size_t> __1d_;
Howard Hinnant324bb032010-08-22 00:02:43 +00001469
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001470public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001471 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001472 gslice() {}
Douglas Gregor0855dde2012-05-19 07:14:17 +00001473
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001474 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001475 gslice(size_t __start, const valarray<size_t>& __size,
1476 const valarray<size_t>& __stride)
1477 : __size_(__size),
1478 __stride_(__stride)
1479 {__init(__start);}
1480
Eric Fiselier97db5172017-04-19 00:23:45 +00001481#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001482
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001483 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001484 gslice(size_t __start, const valarray<size_t>& __size,
1485 valarray<size_t>&& __stride)
1486 : __size_(__size),
1487 __stride_(move(__stride))
1488 {__init(__start);}
1489
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001490 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001491 gslice(size_t __start, valarray<size_t>&& __size,
1492 const valarray<size_t>& __stride)
1493 : __size_(move(__size)),
1494 __stride_(__stride)
1495 {__init(__start);}
1496
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001497 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001498 gslice(size_t __start, valarray<size_t>&& __size,
1499 valarray<size_t>&& __stride)
1500 : __size_(move(__size)),
1501 __stride_(move(__stride))
1502 {__init(__start);}
1503
Eric Fiselier97db5172017-04-19 00:23:45 +00001504#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001505
1506// gslice(const gslice&) = default;
1507// gslice(gslice&&) = default;
1508// gslice& operator=(const gslice&) = default;
1509// gslice& operator=(gslice&&) = default;
1510
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001511 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001512 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1513
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001514 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001515 valarray<size_t> size() const {return __size_;}
1516
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001517 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001518 valarray<size_t> stride() const {return __stride_;}
1519
1520private:
1521 void __init(size_t __start);
1522
1523 template <class> friend class gslice_array;
1524 template <class> friend class valarray;
1525 template <class> friend class __val_expr;
1526};
1527
1528// gslice_array
1529
1530template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00001531class _LIBCPP_TEMPLATE_VIS gslice_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001532{
1533public:
1534 typedef _Tp value_type;
1535
1536private:
1537 value_type* __vp_;
1538 valarray<size_t> __1d_;
1539
1540public:
1541 template <class _Expr>
1542 typename enable_if
1543 <
1544 __is_val_expr<_Expr>::value,
1545 void
1546 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001547 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001548 operator=(const _Expr& __v) const;
1549
1550 template <class _Expr>
1551 typename enable_if
1552 <
1553 __is_val_expr<_Expr>::value,
1554 void
1555 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001556 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001557 operator*=(const _Expr& __v) const;
1558
1559 template <class _Expr>
1560 typename enable_if
1561 <
1562 __is_val_expr<_Expr>::value,
1563 void
1564 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001565 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001566 operator/=(const _Expr& __v) const;
1567
1568 template <class _Expr>
1569 typename enable_if
1570 <
1571 __is_val_expr<_Expr>::value,
1572 void
1573 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001574 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001575 operator%=(const _Expr& __v) const;
1576
1577 template <class _Expr>
1578 typename enable_if
1579 <
1580 __is_val_expr<_Expr>::value,
1581 void
1582 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001583 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001584 operator+=(const _Expr& __v) const;
1585
1586 template <class _Expr>
1587 typename enable_if
1588 <
1589 __is_val_expr<_Expr>::value,
1590 void
1591 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001592 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001593 operator-=(const _Expr& __v) const;
1594
1595 template <class _Expr>
1596 typename enable_if
1597 <
1598 __is_val_expr<_Expr>::value,
1599 void
1600 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001601 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001602 operator^=(const _Expr& __v) const;
1603
1604 template <class _Expr>
1605 typename enable_if
1606 <
1607 __is_val_expr<_Expr>::value,
1608 void
1609 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001610 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001611 operator&=(const _Expr& __v) const;
1612
1613 template <class _Expr>
1614 typename enable_if
1615 <
1616 __is_val_expr<_Expr>::value,
1617 void
1618 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001619 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001620 operator|=(const _Expr& __v) const;
1621
1622 template <class _Expr>
1623 typename enable_if
1624 <
1625 __is_val_expr<_Expr>::value,
1626 void
1627 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001628 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001629 operator<<=(const _Expr& __v) const;
1630
1631 template <class _Expr>
1632 typename enable_if
1633 <
1634 __is_val_expr<_Expr>::value,
1635 void
1636 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001637 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001638 operator>>=(const _Expr& __v) const;
1639
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001640 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001641 const gslice_array& operator=(const gslice_array& __ga) const;
1642
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001643 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001644 void operator=(const value_type& __x) const;
1645
1646// gslice_array(const gslice_array&) = default;
1647// gslice_array(gslice_array&&) = default;
1648// gslice_array& operator=(const gslice_array&) = default;
1649// gslice_array& operator=(gslice_array&&) = default;
1650
1651private:
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001652 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1653 : __vp_(const_cast<value_type*>(__v.__begin_)),
1654 __1d_(__gs.__1d_)
1655 {}
1656
Eric Fiselier97db5172017-04-19 00:23:45 +00001657#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001658 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1659 : __vp_(const_cast<value_type*>(__v.__begin_)),
1660 __1d_(move(__gs.__1d_))
1661 {}
Eric Fiselier97db5172017-04-19 00:23:45 +00001662#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001663
1664 template <class> friend class valarray;
1665};
1666
1667template <class _Tp>
1668template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001669inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001670typename enable_if
1671<
1672 __is_val_expr<_Expr>::value,
1673 void
1674>::type
1675gslice_array<_Tp>::operator=(const _Expr& __v) const
1676{
1677 typedef const size_t* _Ip;
1678 size_t __j = 0;
1679 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1680 __vp_[*__i] = __v[__j];
1681}
1682
1683template <class _Tp>
1684template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001685inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001686typename enable_if
1687<
1688 __is_val_expr<_Expr>::value,
1689 void
1690>::type
1691gslice_array<_Tp>::operator*=(const _Expr& __v) const
1692{
1693 typedef const size_t* _Ip;
1694 size_t __j = 0;
1695 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1696 __vp_[*__i] *= __v[__j];
1697}
1698
1699template <class _Tp>
1700template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001701inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001702typename enable_if
1703<
1704 __is_val_expr<_Expr>::value,
1705 void
1706>::type
1707gslice_array<_Tp>::operator/=(const _Expr& __v) const
1708{
1709 typedef const size_t* _Ip;
1710 size_t __j = 0;
1711 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1712 __vp_[*__i] /= __v[__j];
1713}
1714
1715template <class _Tp>
1716template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001717inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001718typename enable_if
1719<
1720 __is_val_expr<_Expr>::value,
1721 void
1722>::type
1723gslice_array<_Tp>::operator%=(const _Expr& __v) const
1724{
1725 typedef const size_t* _Ip;
1726 size_t __j = 0;
1727 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1728 __vp_[*__i] %= __v[__j];
1729}
1730
1731template <class _Tp>
1732template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001733inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001734typename enable_if
1735<
1736 __is_val_expr<_Expr>::value,
1737 void
1738>::type
1739gslice_array<_Tp>::operator+=(const _Expr& __v) const
1740{
1741 typedef const size_t* _Ip;
1742 size_t __j = 0;
1743 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1744 __vp_[*__i] += __v[__j];
1745}
1746
1747template <class _Tp>
1748template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001749inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001750typename enable_if
1751<
1752 __is_val_expr<_Expr>::value,
1753 void
1754>::type
1755gslice_array<_Tp>::operator-=(const _Expr& __v) const
1756{
1757 typedef const size_t* _Ip;
1758 size_t __j = 0;
1759 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1760 __vp_[*__i] -= __v[__j];
1761}
1762
1763template <class _Tp>
1764template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001765inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001766typename enable_if
1767<
1768 __is_val_expr<_Expr>::value,
1769 void
1770>::type
1771gslice_array<_Tp>::operator^=(const _Expr& __v) const
1772{
1773 typedef const size_t* _Ip;
1774 size_t __j = 0;
1775 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1776 __vp_[*__i] ^= __v[__j];
1777}
1778
1779template <class _Tp>
1780template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001781inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001782typename enable_if
1783<
1784 __is_val_expr<_Expr>::value,
1785 void
1786>::type
1787gslice_array<_Tp>::operator&=(const _Expr& __v) const
1788{
1789 typedef const size_t* _Ip;
1790 size_t __j = 0;
1791 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1792 __vp_[*__i] &= __v[__j];
1793}
1794
1795template <class _Tp>
1796template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001797inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001798typename enable_if
1799<
1800 __is_val_expr<_Expr>::value,
1801 void
1802>::type
1803gslice_array<_Tp>::operator|=(const _Expr& __v) const
1804{
1805 typedef const size_t* _Ip;
1806 size_t __j = 0;
1807 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1808 __vp_[*__i] |= __v[__j];
1809}
1810
1811template <class _Tp>
1812template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001813inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001814typename enable_if
1815<
1816 __is_val_expr<_Expr>::value,
1817 void
1818>::type
1819gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1820{
1821 typedef const size_t* _Ip;
1822 size_t __j = 0;
1823 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1824 __vp_[*__i] <<= __v[__j];
1825}
1826
1827template <class _Tp>
1828template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001829inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001830typename enable_if
1831<
1832 __is_val_expr<_Expr>::value,
1833 void
1834>::type
1835gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1836{
1837 typedef const size_t* _Ip;
1838 size_t __j = 0;
1839 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1840 __vp_[*__i] >>= __v[__j];
1841}
1842
1843template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001844inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001845const gslice_array<_Tp>&
1846gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1847{
1848 typedef const size_t* _Ip;
1849 const value_type* __s = __ga.__vp_;
1850 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1851 __i != __e; ++__i, ++__j)
1852 __vp_[*__i] = __s[*__j];
1853 return *this;
1854}
1855
1856template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001857inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001858void
1859gslice_array<_Tp>::operator=(const value_type& __x) const
1860{
1861 typedef const size_t* _Ip;
1862 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1863 __vp_[*__i] = __x;
1864}
1865
1866// mask_array
1867
1868template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00001869class _LIBCPP_TEMPLATE_VIS mask_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001870{
1871public:
1872 typedef _Tp value_type;
1873
1874private:
1875 value_type* __vp_;
1876 valarray<size_t> __1d_;
1877
1878public:
1879 template <class _Expr>
1880 typename enable_if
1881 <
1882 __is_val_expr<_Expr>::value,
1883 void
1884 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001885 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001886 operator=(const _Expr& __v) const;
1887
1888 template <class _Expr>
1889 typename enable_if
1890 <
1891 __is_val_expr<_Expr>::value,
1892 void
1893 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001894 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001895 operator*=(const _Expr& __v) const;
1896
1897 template <class _Expr>
1898 typename enable_if
1899 <
1900 __is_val_expr<_Expr>::value,
1901 void
1902 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001903 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001904 operator/=(const _Expr& __v) const;
1905
1906 template <class _Expr>
1907 typename enable_if
1908 <
1909 __is_val_expr<_Expr>::value,
1910 void
1911 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001912 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001913 operator%=(const _Expr& __v) const;
1914
1915 template <class _Expr>
1916 typename enable_if
1917 <
1918 __is_val_expr<_Expr>::value,
1919 void
1920 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001921 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001922 operator+=(const _Expr& __v) const;
1923
1924 template <class _Expr>
1925 typename enable_if
1926 <
1927 __is_val_expr<_Expr>::value,
1928 void
1929 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001930 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001931 operator-=(const _Expr& __v) const;
1932
1933 template <class _Expr>
1934 typename enable_if
1935 <
1936 __is_val_expr<_Expr>::value,
1937 void
1938 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001939 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001940 operator^=(const _Expr& __v) const;
1941
1942 template <class _Expr>
1943 typename enable_if
1944 <
1945 __is_val_expr<_Expr>::value,
1946 void
1947 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001948 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001949 operator&=(const _Expr& __v) const;
1950
1951 template <class _Expr>
1952 typename enable_if
1953 <
1954 __is_val_expr<_Expr>::value,
1955 void
1956 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001957 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001958 operator|=(const _Expr& __v) const;
1959
1960 template <class _Expr>
1961 typename enable_if
1962 <
1963 __is_val_expr<_Expr>::value,
1964 void
1965 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001966 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001967 operator<<=(const _Expr& __v) const;
1968
1969 template <class _Expr>
1970 typename enable_if
1971 <
1972 __is_val_expr<_Expr>::value,
1973 void
1974 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001975 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001976 operator>>=(const _Expr& __v) const;
1977
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001978 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001979 const mask_array& operator=(const mask_array& __ma) const;
1980
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00001981 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001982 void operator=(const value_type& __x) const;
1983
1984// mask_array(const mask_array&) = default;
1985// mask_array(mask_array&&) = default;
1986// mask_array& operator=(const mask_array&) = default;
1987// mask_array& operator=(mask_array&&) = default;
1988
1989private:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00001990 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001991 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1992 : __vp_(const_cast<value_type*>(__v.__begin_)),
Howard Hinnantec3773c2011-12-01 20:21:04 +00001993 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001994 {
1995 size_t __j = 0;
1996 for (size_t __i = 0; __i < __vb.size(); ++__i)
1997 if (__vb[__i])
1998 __1d_[__j++] = __i;
1999 }
2000
2001 template <class> friend class valarray;
2002};
2003
2004template <class _Tp>
2005template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002006inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002007typename enable_if
2008<
2009 __is_val_expr<_Expr>::value,
2010 void
2011>::type
2012mask_array<_Tp>::operator=(const _Expr& __v) const
2013{
2014 size_t __n = __1d_.size();
2015 for (size_t __i = 0; __i < __n; ++__i)
2016 __vp_[__1d_[__i]] = __v[__i];
2017}
2018
2019template <class _Tp>
2020template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002021inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002022typename enable_if
2023<
2024 __is_val_expr<_Expr>::value,
2025 void
2026>::type
2027mask_array<_Tp>::operator*=(const _Expr& __v) const
2028{
2029 size_t __n = __1d_.size();
2030 for (size_t __i = 0; __i < __n; ++__i)
2031 __vp_[__1d_[__i]] *= __v[__i];
2032}
2033
2034template <class _Tp>
2035template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002036inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002037typename enable_if
2038<
2039 __is_val_expr<_Expr>::value,
2040 void
2041>::type
2042mask_array<_Tp>::operator/=(const _Expr& __v) const
2043{
2044 size_t __n = __1d_.size();
2045 for (size_t __i = 0; __i < __n; ++__i)
2046 __vp_[__1d_[__i]] /= __v[__i];
2047}
2048
2049template <class _Tp>
2050template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002051inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002052typename enable_if
2053<
2054 __is_val_expr<_Expr>::value,
2055 void
2056>::type
2057mask_array<_Tp>::operator%=(const _Expr& __v) const
2058{
2059 size_t __n = __1d_.size();
2060 for (size_t __i = 0; __i < __n; ++__i)
2061 __vp_[__1d_[__i]] %= __v[__i];
2062}
2063
2064template <class _Tp>
2065template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002066inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002067typename enable_if
2068<
2069 __is_val_expr<_Expr>::value,
2070 void
2071>::type
2072mask_array<_Tp>::operator+=(const _Expr& __v) const
2073{
2074 size_t __n = __1d_.size();
2075 for (size_t __i = 0; __i < __n; ++__i)
2076 __vp_[__1d_[__i]] += __v[__i];
2077}
2078
2079template <class _Tp>
2080template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002081inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002082typename enable_if
2083<
2084 __is_val_expr<_Expr>::value,
2085 void
2086>::type
2087mask_array<_Tp>::operator-=(const _Expr& __v) const
2088{
2089 size_t __n = __1d_.size();
2090 for (size_t __i = 0; __i < __n; ++__i)
2091 __vp_[__1d_[__i]] -= __v[__i];
2092}
2093
2094template <class _Tp>
2095template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002096inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002097typename enable_if
2098<
2099 __is_val_expr<_Expr>::value,
2100 void
2101>::type
2102mask_array<_Tp>::operator^=(const _Expr& __v) const
2103{
2104 size_t __n = __1d_.size();
2105 for (size_t __i = 0; __i < __n; ++__i)
2106 __vp_[__1d_[__i]] ^= __v[__i];
2107}
2108
2109template <class _Tp>
2110template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002111inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002112typename enable_if
2113<
2114 __is_val_expr<_Expr>::value,
2115 void
2116>::type
2117mask_array<_Tp>::operator&=(const _Expr& __v) const
2118{
2119 size_t __n = __1d_.size();
2120 for (size_t __i = 0; __i < __n; ++__i)
2121 __vp_[__1d_[__i]] &= __v[__i];
2122}
2123
2124template <class _Tp>
2125template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002126inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002127typename enable_if
2128<
2129 __is_val_expr<_Expr>::value,
2130 void
2131>::type
2132mask_array<_Tp>::operator|=(const _Expr& __v) const
2133{
2134 size_t __n = __1d_.size();
2135 for (size_t __i = 0; __i < __n; ++__i)
2136 __vp_[__1d_[__i]] |= __v[__i];
2137}
2138
2139template <class _Tp>
2140template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002141inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002142typename enable_if
2143<
2144 __is_val_expr<_Expr>::value,
2145 void
2146>::type
2147mask_array<_Tp>::operator<<=(const _Expr& __v) const
2148{
2149 size_t __n = __1d_.size();
2150 for (size_t __i = 0; __i < __n; ++__i)
2151 __vp_[__1d_[__i]] <<= __v[__i];
2152}
2153
2154template <class _Tp>
2155template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002156inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002157typename enable_if
2158<
2159 __is_val_expr<_Expr>::value,
2160 void
2161>::type
2162mask_array<_Tp>::operator>>=(const _Expr& __v) const
2163{
2164 size_t __n = __1d_.size();
2165 for (size_t __i = 0; __i < __n; ++__i)
2166 __vp_[__1d_[__i]] >>= __v[__i];
2167}
2168
2169template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002170inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002171const mask_array<_Tp>&
2172mask_array<_Tp>::operator=(const mask_array& __ma) const
2173{
2174 size_t __n = __1d_.size();
2175 for (size_t __i = 0; __i < __n; ++__i)
2176 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
Eric Fiselierf4124612014-08-12 00:06:58 +00002177 return *this;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002178}
2179
2180template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002181inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002182void
2183mask_array<_Tp>::operator=(const value_type& __x) const
2184{
2185 size_t __n = __1d_.size();
2186 for (size_t __i = 0; __i < __n; ++__i)
2187 __vp_[__1d_[__i]] = __x;
2188}
2189
2190template <class _ValExpr>
2191class __mask_expr
2192{
2193 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2194public:
2195 typedef typename _RmExpr::value_type value_type;
2196 typedef value_type result_type;
2197
2198private:
2199 _ValExpr __expr_;
2200 valarray<size_t> __1d_;
2201
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002202 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002203 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2204 : __expr_(__e),
Howard Hinnantec3773c2011-12-01 20:21:04 +00002205 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002206 {
2207 size_t __j = 0;
2208 for (size_t __i = 0; __i < __vb.size(); ++__i)
2209 if (__vb[__i])
2210 __1d_[__j++] = __i;
2211 }
2212
2213public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002214 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002215 result_type operator[](size_t __i) const
2216 {return __expr_[__1d_[__i]];}
2217
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002218 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002219 size_t size() const {return __1d_.size();}
2220
2221 template <class> friend class valarray;
2222};
2223
2224// indirect_array
2225
2226template <class _Tp>
Eric Fiselierc3589a82017-01-04 23:56:00 +00002227class _LIBCPP_TEMPLATE_VIS indirect_array
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002228{
2229public:
2230 typedef _Tp value_type;
2231
2232private:
2233 value_type* __vp_;
2234 valarray<size_t> __1d_;
2235
2236public:
2237 template <class _Expr>
2238 typename enable_if
2239 <
2240 __is_val_expr<_Expr>::value,
2241 void
2242 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002243 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002244 operator=(const _Expr& __v) const;
2245
2246 template <class _Expr>
2247 typename enable_if
2248 <
2249 __is_val_expr<_Expr>::value,
2250 void
2251 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002252 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002253 operator*=(const _Expr& __v) const;
2254
2255 template <class _Expr>
2256 typename enable_if
2257 <
2258 __is_val_expr<_Expr>::value,
2259 void
2260 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002261 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002262 operator/=(const _Expr& __v) const;
2263
2264 template <class _Expr>
2265 typename enable_if
2266 <
2267 __is_val_expr<_Expr>::value,
2268 void
2269 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002270 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002271 operator%=(const _Expr& __v) const;
2272
2273 template <class _Expr>
2274 typename enable_if
2275 <
2276 __is_val_expr<_Expr>::value,
2277 void
2278 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002279 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002280 operator+=(const _Expr& __v) const;
2281
2282 template <class _Expr>
2283 typename enable_if
2284 <
2285 __is_val_expr<_Expr>::value,
2286 void
2287 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002288 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002289 operator-=(const _Expr& __v) const;
2290
2291 template <class _Expr>
2292 typename enable_if
2293 <
2294 __is_val_expr<_Expr>::value,
2295 void
2296 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002297 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002298 operator^=(const _Expr& __v) const;
2299
2300 template <class _Expr>
2301 typename enable_if
2302 <
2303 __is_val_expr<_Expr>::value,
2304 void
2305 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002306 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002307 operator&=(const _Expr& __v) const;
2308
2309 template <class _Expr>
2310 typename enable_if
2311 <
2312 __is_val_expr<_Expr>::value,
2313 void
2314 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002315 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002316 operator|=(const _Expr& __v) const;
2317
2318 template <class _Expr>
2319 typename enable_if
2320 <
2321 __is_val_expr<_Expr>::value,
2322 void
2323 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002324 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002325 operator<<=(const _Expr& __v) const;
2326
2327 template <class _Expr>
2328 typename enable_if
2329 <
2330 __is_val_expr<_Expr>::value,
2331 void
2332 >::type
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002333 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002334 operator>>=(const _Expr& __v) const;
2335
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002336 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002337 const indirect_array& operator=(const indirect_array& __ia) const;
2338
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002339 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002340 void operator=(const value_type& __x) const;
2341
2342// indirect_array(const indirect_array&) = default;
2343// indirect_array(indirect_array&&) = default;
2344// indirect_array& operator=(const indirect_array&) = default;
2345// indirect_array& operator=(indirect_array&&) = default;
2346
2347private:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002348 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002349 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2350 : __vp_(const_cast<value_type*>(__v.__begin_)),
2351 __1d_(__ia)
2352 {}
2353
Eric Fiselier97db5172017-04-19 00:23:45 +00002354#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002355
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002356 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002357 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2358 : __vp_(const_cast<value_type*>(__v.__begin_)),
2359 __1d_(move(__ia))
2360 {}
2361
Eric Fiselier97db5172017-04-19 00:23:45 +00002362#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002363
2364 template <class> friend class valarray;
2365};
2366
2367template <class _Tp>
2368template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002369inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002370typename enable_if
2371<
2372 __is_val_expr<_Expr>::value,
2373 void
2374>::type
2375indirect_array<_Tp>::operator=(const _Expr& __v) const
2376{
2377 size_t __n = __1d_.size();
2378 for (size_t __i = 0; __i < __n; ++__i)
2379 __vp_[__1d_[__i]] = __v[__i];
2380}
2381
2382template <class _Tp>
2383template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002384inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002385typename enable_if
2386<
2387 __is_val_expr<_Expr>::value,
2388 void
2389>::type
2390indirect_array<_Tp>::operator*=(const _Expr& __v) const
2391{
2392 size_t __n = __1d_.size();
2393 for (size_t __i = 0; __i < __n; ++__i)
2394 __vp_[__1d_[__i]] *= __v[__i];
2395}
2396
2397template <class _Tp>
2398template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002399inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002400typename enable_if
2401<
2402 __is_val_expr<_Expr>::value,
2403 void
2404>::type
2405indirect_array<_Tp>::operator/=(const _Expr& __v) const
2406{
2407 size_t __n = __1d_.size();
2408 for (size_t __i = 0; __i < __n; ++__i)
2409 __vp_[__1d_[__i]] /= __v[__i];
2410}
2411
2412template <class _Tp>
2413template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002414inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002415typename enable_if
2416<
2417 __is_val_expr<_Expr>::value,
2418 void
2419>::type
2420indirect_array<_Tp>::operator%=(const _Expr& __v) const
2421{
2422 size_t __n = __1d_.size();
2423 for (size_t __i = 0; __i < __n; ++__i)
2424 __vp_[__1d_[__i]] %= __v[__i];
2425}
2426
2427template <class _Tp>
2428template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002429inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002430typename enable_if
2431<
2432 __is_val_expr<_Expr>::value,
2433 void
2434>::type
2435indirect_array<_Tp>::operator+=(const _Expr& __v) const
2436{
2437 size_t __n = __1d_.size();
2438 for (size_t __i = 0; __i < __n; ++__i)
2439 __vp_[__1d_[__i]] += __v[__i];
2440}
2441
2442template <class _Tp>
2443template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002444inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002445typename enable_if
2446<
2447 __is_val_expr<_Expr>::value,
2448 void
2449>::type
2450indirect_array<_Tp>::operator-=(const _Expr& __v) const
2451{
2452 size_t __n = __1d_.size();
2453 for (size_t __i = 0; __i < __n; ++__i)
2454 __vp_[__1d_[__i]] -= __v[__i];
2455}
2456
2457template <class _Tp>
2458template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002459inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002460typename enable_if
2461<
2462 __is_val_expr<_Expr>::value,
2463 void
2464>::type
2465indirect_array<_Tp>::operator^=(const _Expr& __v) const
2466{
2467 size_t __n = __1d_.size();
2468 for (size_t __i = 0; __i < __n; ++__i)
2469 __vp_[__1d_[__i]] ^= __v[__i];
2470}
2471
2472template <class _Tp>
2473template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002474inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002475typename enable_if
2476<
2477 __is_val_expr<_Expr>::value,
2478 void
2479>::type
2480indirect_array<_Tp>::operator&=(const _Expr& __v) const
2481{
2482 size_t __n = __1d_.size();
2483 for (size_t __i = 0; __i < __n; ++__i)
2484 __vp_[__1d_[__i]] &= __v[__i];
2485}
2486
2487template <class _Tp>
2488template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002489inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002490typename enable_if
2491<
2492 __is_val_expr<_Expr>::value,
2493 void
2494>::type
2495indirect_array<_Tp>::operator|=(const _Expr& __v) const
2496{
2497 size_t __n = __1d_.size();
2498 for (size_t __i = 0; __i < __n; ++__i)
2499 __vp_[__1d_[__i]] |= __v[__i];
2500}
2501
2502template <class _Tp>
2503template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002504inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002505typename enable_if
2506<
2507 __is_val_expr<_Expr>::value,
2508 void
2509>::type
2510indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2511{
2512 size_t __n = __1d_.size();
2513 for (size_t __i = 0; __i < __n; ++__i)
2514 __vp_[__1d_[__i]] <<= __v[__i];
2515}
2516
2517template <class _Tp>
2518template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002519inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002520typename enable_if
2521<
2522 __is_val_expr<_Expr>::value,
2523 void
2524>::type
2525indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2526{
2527 size_t __n = __1d_.size();
2528 for (size_t __i = 0; __i < __n; ++__i)
2529 __vp_[__1d_[__i]] >>= __v[__i];
2530}
2531
2532template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002533inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002534const indirect_array<_Tp>&
2535indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2536{
2537 typedef const size_t* _Ip;
2538 const value_type* __s = __ia.__vp_;
2539 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2540 __i != __e; ++__i, ++__j)
2541 __vp_[*__i] = __s[*__j];
2542 return *this;
2543}
2544
2545template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002546inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002547void
2548indirect_array<_Tp>::operator=(const value_type& __x) const
2549{
2550 typedef const size_t* _Ip;
2551 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2552 __vp_[*__i] = __x;
2553}
2554
2555template <class _ValExpr>
2556class __indirect_expr
2557{
2558 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2559public:
2560 typedef typename _RmExpr::value_type value_type;
2561 typedef value_type result_type;
2562
2563private:
2564 _ValExpr __expr_;
2565 valarray<size_t> __1d_;
2566
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002567 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002568 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2569 : __expr_(__e),
2570 __1d_(__ia)
2571 {}
2572
Eric Fiselier97db5172017-04-19 00:23:45 +00002573#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002574
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002575 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002576 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2577 : __expr_(__e),
2578 __1d_(move(__ia))
2579 {}
2580
Eric Fiselier97db5172017-04-19 00:23:45 +00002581#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002582
2583public:
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002584 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002585 result_type operator[](size_t __i) const
2586 {return __expr_[__1d_[__i]];}
2587
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002588 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002589 size_t size() const {return __1d_.size();}
2590
Eric Fiselierc3589a82017-01-04 23:56:00 +00002591 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002592};
2593
2594template<class _ValExpr>
2595class __val_expr
2596{
2597 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2598
2599 _ValExpr __expr_;
2600public:
2601 typedef typename _RmExpr::value_type value_type;
2602 typedef typename _RmExpr::result_type result_type;
2603
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002604 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002605 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2606
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002607 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002608 result_type operator[](size_t __i) const
2609 {return __expr_[__i];}
2610
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002611 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002612 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2613 {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2614
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002615 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002616 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2617 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2618
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002619 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002620 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2621 {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2622
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002623 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002624 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2625 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2626
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002627 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002628 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2629 operator+() const
2630 {
2631 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2632 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2633 }
2634
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002635 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002636 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2637 operator-() const
2638 {
2639 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2640 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2641 }
2642
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002643 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002644 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2645 operator~() const
2646 {
2647 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2648 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2649 }
2650
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002651 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002652 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2653 operator!() const
2654 {
2655 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2656 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2657 }
2658
2659 operator valarray<result_type>() const;
2660
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002661 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002662 size_t size() const {return __expr_.size();}
2663
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002664 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002665 result_type sum() const
2666 {
2667 size_t __n = __expr_.size();
2668 result_type __r = __n ? __expr_[0] : result_type();
2669 for (size_t __i = 1; __i < __n; ++__i)
2670 __r += __expr_[__i];
2671 return __r;
2672 }
2673
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002674 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002675 result_type min() const
2676 {
2677 size_t __n = size();
2678 result_type __r = __n ? (*this)[0] : result_type();
2679 for (size_t __i = 1; __i < __n; ++__i)
2680 {
2681 result_type __x = __expr_[__i];
2682 if (__x < __r)
2683 __r = __x;
2684 }
2685 return __r;
2686 }
2687
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002688 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002689 result_type max() const
2690 {
2691 size_t __n = size();
2692 result_type __r = __n ? (*this)[0] : result_type();
2693 for (size_t __i = 1; __i < __n; ++__i)
2694 {
2695 result_type __x = __expr_[__i];
2696 if (__r < __x)
2697 __r = __x;
2698 }
2699 return __r;
2700 }
2701
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002702 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002703 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2704 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2705
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002706 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002707 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2708 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2709
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002710 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002711 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2712 apply(value_type __f(value_type)) const
2713 {
2714 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2715 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2716 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2717 }
2718
Howard Hinnantee6ccd02010-09-23 18:58:28 +00002719 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002720 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2721 apply(value_type __f(const value_type&)) const
2722 {
2723 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2724 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2725 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2726 }
2727};
2728
2729template<class _ValExpr>
Howard Hinnantd8851432013-09-13 23:27:42 +00002730__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002731{
2732 valarray<result_type> __r;
2733 size_t __n = __expr_.size();
2734 if (__n)
2735 {
2736 __r.__begin_ =
2737 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00002738 static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002739 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2740 ::new (__r.__end_) result_type(__expr_[__i]);
2741 }
2742 return __r;
2743}
2744
2745// valarray
2746
2747template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002748inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002749valarray<_Tp>::valarray(size_t __n)
2750 : __begin_(0),
2751 __end_(0)
2752{
2753 resize(__n);
2754}
2755
2756template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002757inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002758valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2759 : __begin_(0),
2760 __end_(0)
2761{
2762 resize(__n, __x);
2763}
2764
2765template <class _Tp>
2766valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2767 : __begin_(0),
2768 __end_(0)
2769{
2770 if (__n)
2771 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002772 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002773#ifndef _LIBCPP_NO_EXCEPTIONS
2774 try
2775 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002776#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002777 for (; __n; ++__end_, ++__p, --__n)
2778 ::new (__end_) value_type(*__p);
2779#ifndef _LIBCPP_NO_EXCEPTIONS
2780 }
2781 catch (...)
2782 {
2783 resize(0);
2784 throw;
2785 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002786#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002787 }
2788}
2789
2790template <class _Tp>
2791valarray<_Tp>::valarray(const valarray& __v)
2792 : __begin_(0),
2793 __end_(0)
2794{
2795 if (__v.size())
2796 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002797 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002798#ifndef _LIBCPP_NO_EXCEPTIONS
2799 try
2800 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002801#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002802 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2803 ::new (__end_) value_type(*__p);
2804#ifndef _LIBCPP_NO_EXCEPTIONS
2805 }
2806 catch (...)
2807 {
2808 resize(0);
2809 throw;
2810 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002811#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002812 }
2813}
2814
Eric Fiselier97db5172017-04-19 00:23:45 +00002815#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002816
2817template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002818inline
Howard Hinnantbd143082012-07-21 00:51:28 +00002819valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002820 : __begin_(__v.__begin_),
2821 __end_(__v.__end_)
2822{
2823 __v.__begin_ = __v.__end_ = nullptr;
2824}
2825
2826template <class _Tp>
2827valarray<_Tp>::valarray(initializer_list<value_type> __il)
2828 : __begin_(0),
2829 __end_(0)
2830{
2831 size_t __n = __il.size();
2832 if (__n)
2833 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002834 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002835#ifndef _LIBCPP_NO_EXCEPTIONS
2836 try
2837 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002838#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002839 for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2840 ::new (__end_) value_type(*__p);
2841#ifndef _LIBCPP_NO_EXCEPTIONS
2842 }
2843 catch (...)
2844 {
2845 resize(0);
2846 throw;
2847 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002848#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002849 }
2850}
2851
Eric Fiselier97db5172017-04-19 00:23:45 +00002852#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002853
2854template <class _Tp>
2855valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2856 : __begin_(0),
2857 __end_(0)
2858{
2859 size_t __n = __sa.__size_;
2860 if (__n)
2861 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002862 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002863#ifndef _LIBCPP_NO_EXCEPTIONS
2864 try
2865 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002866#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002867 for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2868 ::new (__end_) value_type(*__p);
2869#ifndef _LIBCPP_NO_EXCEPTIONS
2870 }
2871 catch (...)
2872 {
2873 resize(0);
2874 throw;
2875 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002876#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002877 }
2878}
2879
2880template <class _Tp>
2881valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2882 : __begin_(0),
2883 __end_(0)
2884{
2885 size_t __n = __ga.__1d_.size();
2886 if (__n)
2887 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002888 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002889#ifndef _LIBCPP_NO_EXCEPTIONS
2890 try
2891 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002892#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002893 typedef const size_t* _Ip;
2894 const value_type* __s = __ga.__vp_;
2895 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2896 __i != __e; ++__i, ++__end_)
2897 ::new (__end_) value_type(__s[*__i]);
2898#ifndef _LIBCPP_NO_EXCEPTIONS
2899 }
2900 catch (...)
2901 {
2902 resize(0);
2903 throw;
2904 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002905#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002906 }
2907}
2908
2909template <class _Tp>
2910valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2911 : __begin_(0),
2912 __end_(0)
2913{
2914 size_t __n = __ma.__1d_.size();
2915 if (__n)
2916 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002917 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002918#ifndef _LIBCPP_NO_EXCEPTIONS
2919 try
2920 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002921#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002922 typedef const size_t* _Ip;
2923 const value_type* __s = __ma.__vp_;
2924 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2925 __i != __e; ++__i, ++__end_)
2926 ::new (__end_) value_type(__s[*__i]);
2927#ifndef _LIBCPP_NO_EXCEPTIONS
2928 }
2929 catch (...)
2930 {
2931 resize(0);
2932 throw;
2933 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002934#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002935 }
2936}
2937
2938template <class _Tp>
2939valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2940 : __begin_(0),
2941 __end_(0)
2942{
2943 size_t __n = __ia.__1d_.size();
2944 if (__n)
2945 {
Richard Smith73c1fce2014-06-04 19:54:15 +00002946 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002947#ifndef _LIBCPP_NO_EXCEPTIONS
2948 try
2949 {
Howard Hinnant324bb032010-08-22 00:02:43 +00002950#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002951 typedef const size_t* _Ip;
2952 const value_type* __s = __ia.__vp_;
2953 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2954 __i != __e; ++__i, ++__end_)
2955 ::new (__end_) value_type(__s[*__i]);
2956#ifndef _LIBCPP_NO_EXCEPTIONS
2957 }
2958 catch (...)
2959 {
2960 resize(0);
2961 throw;
2962 }
Howard Hinnant324bb032010-08-22 00:02:43 +00002963#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002964 }
2965}
2966
2967template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002968inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002969valarray<_Tp>::~valarray()
2970{
2971 resize(0);
2972}
2973
2974template <class _Tp>
2975valarray<_Tp>&
2976valarray<_Tp>::operator=(const valarray& __v)
2977{
2978 if (this != &__v)
2979 {
2980 if (size() != __v.size())
2981 resize(__v.size());
Howard Hinnant0949eed2011-06-30 21:18:19 +00002982 _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002983 }
2984 return *this;
2985}
2986
Eric Fiselier97db5172017-04-19 00:23:45 +00002987#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002988
2989template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00002990inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002991valarray<_Tp>&
Howard Hinnantbd143082012-07-21 00:51:28 +00002992valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00002993{
2994 resize(0);
2995 __begin_ = __v.__begin_;
2996 __end_ = __v.__end_;
2997 __v.__begin_ = nullptr;
2998 __v.__end_ = nullptr;
2999 return *this;
3000}
3001
3002template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003003inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003004valarray<_Tp>&
3005valarray<_Tp>::operator=(initializer_list<value_type> __il)
3006{
3007 if (size() != __il.size())
3008 resize(__il.size());
Howard Hinnant0949eed2011-06-30 21:18:19 +00003009 _VSTD::copy(__il.begin(), __il.end(), __begin_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003010 return *this;
3011}
3012
Eric Fiselier97db5172017-04-19 00:23:45 +00003013#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003014
3015template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003016inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003017valarray<_Tp>&
3018valarray<_Tp>::operator=(const value_type& __x)
3019{
Howard Hinnant0949eed2011-06-30 21:18:19 +00003020 _VSTD::fill(__begin_, __end_, __x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003021 return *this;
3022}
3023
3024template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003025inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003026valarray<_Tp>&
3027valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
3028{
3029 value_type* __t = __begin_;
3030 const value_type* __s = __sa.__vp_;
3031 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
3032 *__t = *__s;
3033 return *this;
3034}
3035
3036template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003037inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003038valarray<_Tp>&
3039valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
3040{
3041 typedef const size_t* _Ip;
3042 value_type* __t = __begin_;
3043 const value_type* __s = __ga.__vp_;
3044 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
3045 __i != __e; ++__i, ++__t)
3046 *__t = __s[*__i];
3047 return *this;
3048}
3049
3050template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003051inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003052valarray<_Tp>&
3053valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
3054{
3055 typedef const size_t* _Ip;
3056 value_type* __t = __begin_;
3057 const value_type* __s = __ma.__vp_;
3058 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
3059 __i != __e; ++__i, ++__t)
3060 *__t = __s[*__i];
3061 return *this;
3062}
3063
3064template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003065inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003066valarray<_Tp>&
3067valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
3068{
3069 typedef const size_t* _Ip;
3070 value_type* __t = __begin_;
3071 const value_type* __s = __ia.__vp_;
3072 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
3073 __i != __e; ++__i, ++__t)
3074 *__t = __s[*__i];
3075 return *this;
3076}
3077
3078template <class _Tp>
Howard Hinnantdb866632011-07-27 23:19:59 +00003079template <class _ValExpr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003080inline
Howard Hinnantdb866632011-07-27 23:19:59 +00003081valarray<_Tp>&
3082valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
3083{
3084 size_t __n = __v.size();
3085 if (size() != __n)
3086 resize(__n);
3087 value_type* __t = __begin_;
3088 for (size_t __i = 0; __i != __n; ++__t, ++__i)
3089 *__t = result_type(__v[__i]);
3090 return *this;
3091}
3092
3093template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003094inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003095__val_expr<__slice_expr<const valarray<_Tp>&> >
3096valarray<_Tp>::operator[](slice __s) const
3097{
3098 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3099}
3100
3101template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003102inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003103slice_array<_Tp>
3104valarray<_Tp>::operator[](slice __s)
3105{
3106 return slice_array<value_type>(__s, *this);
3107}
3108
3109template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003110inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003111__val_expr<__indirect_expr<const valarray<_Tp>&> >
3112valarray<_Tp>::operator[](const gslice& __gs) const
3113{
3114 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3115}
3116
3117template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003118inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003119gslice_array<_Tp>
3120valarray<_Tp>::operator[](const gslice& __gs)
3121{
3122 return gslice_array<value_type>(__gs, *this);
3123}
3124
Eric Fiselier97db5172017-04-19 00:23:45 +00003125#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003126
3127template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003128inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003129__val_expr<__indirect_expr<const valarray<_Tp>&> >
3130valarray<_Tp>::operator[](gslice&& __gs) const
3131{
3132 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3133}
3134
3135template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003136inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003137gslice_array<_Tp>
3138valarray<_Tp>::operator[](gslice&& __gs)
3139{
3140 return gslice_array<value_type>(move(__gs), *this);
3141}
3142
Eric Fiselier97db5172017-04-19 00:23:45 +00003143#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003144
3145template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003146inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003147__val_expr<__mask_expr<const valarray<_Tp>&> >
3148valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3149{
3150 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3151}
3152
3153template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003154inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003155mask_array<_Tp>
3156valarray<_Tp>::operator[](const valarray<bool>& __vb)
3157{
3158 return mask_array<value_type>(__vb, *this);
3159}
3160
Eric Fiselier97db5172017-04-19 00:23:45 +00003161#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003162
3163template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003164inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003165__val_expr<__mask_expr<const valarray<_Tp>&> >
3166valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3167{
3168 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3169}
3170
3171template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003172inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003173mask_array<_Tp>
3174valarray<_Tp>::operator[](valarray<bool>&& __vb)
3175{
3176 return mask_array<value_type>(move(__vb), *this);
3177}
3178
Eric Fiselier97db5172017-04-19 00:23:45 +00003179#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003180
3181template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003182inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003183__val_expr<__indirect_expr<const valarray<_Tp>&> >
3184valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3185{
3186 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3187}
3188
3189template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003190inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003191indirect_array<_Tp>
3192valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3193{
3194 return indirect_array<value_type>(__vs, *this);
3195}
3196
Eric Fiselier97db5172017-04-19 00:23:45 +00003197#ifndef _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003198
3199template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003200inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003201__val_expr<__indirect_expr<const valarray<_Tp>&> >
3202valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3203{
3204 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3205}
3206
3207template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003208inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003209indirect_array<_Tp>
3210valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3211{
3212 return indirect_array<value_type>(move(__vs), *this);
3213}
3214
Eric Fiselier97db5172017-04-19 00:23:45 +00003215#endif // _LIBCPP_CXX03_LANG
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003216
3217template <class _Tp>
3218valarray<_Tp>
3219valarray<_Tp>::operator+() const
3220{
3221 valarray<value_type> __r;
3222 size_t __n = size();
3223 if (__n)
3224 {
3225 __r.__begin_ =
3226 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003227 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003228 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3229 ::new (__r.__end_) value_type(+*__p);
3230 }
3231 return __r;
3232}
3233
3234template <class _Tp>
3235valarray<_Tp>
3236valarray<_Tp>::operator-() const
3237{
3238 valarray<value_type> __r;
3239 size_t __n = size();
3240 if (__n)
3241 {
3242 __r.__begin_ =
3243 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003244 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003245 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3246 ::new (__r.__end_) value_type(-*__p);
3247 }
3248 return __r;
3249}
3250
3251template <class _Tp>
3252valarray<_Tp>
3253valarray<_Tp>::operator~() const
3254{
3255 valarray<value_type> __r;
3256 size_t __n = size();
3257 if (__n)
3258 {
3259 __r.__begin_ =
3260 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003261 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003262 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3263 ::new (__r.__end_) value_type(~*__p);
3264 }
3265 return __r;
3266}
3267
3268template <class _Tp>
3269valarray<bool>
3270valarray<_Tp>::operator!() const
3271{
3272 valarray<bool> __r;
3273 size_t __n = size();
3274 if (__n)
3275 {
3276 __r.__begin_ =
3277 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003278 static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003279 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3280 ::new (__r.__end_) bool(!*__p);
3281 }
3282 return __r;
3283}
3284
3285template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003286inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003287valarray<_Tp>&
3288valarray<_Tp>::operator*=(const value_type& __x)
3289{
3290 for (value_type* __p = __begin_; __p != __end_; ++__p)
3291 *__p *= __x;
3292 return *this;
3293}
3294
3295template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003296inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003297valarray<_Tp>&
3298valarray<_Tp>::operator/=(const value_type& __x)
3299{
3300 for (value_type* __p = __begin_; __p != __end_; ++__p)
3301 *__p /= __x;
3302 return *this;
3303}
3304
3305template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003306inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003307valarray<_Tp>&
3308valarray<_Tp>::operator%=(const value_type& __x)
3309{
3310 for (value_type* __p = __begin_; __p != __end_; ++__p)
3311 *__p %= __x;
3312 return *this;
3313}
3314
3315template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003316inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003317valarray<_Tp>&
3318valarray<_Tp>::operator+=(const value_type& __x)
3319{
3320 for (value_type* __p = __begin_; __p != __end_; ++__p)
3321 *__p += __x;
3322 return *this;
3323}
3324
3325template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003326inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003327valarray<_Tp>&
3328valarray<_Tp>::operator-=(const value_type& __x)
3329{
3330 for (value_type* __p = __begin_; __p != __end_; ++__p)
3331 *__p -= __x;
3332 return *this;
3333}
3334
3335template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003336inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003337valarray<_Tp>&
3338valarray<_Tp>::operator^=(const value_type& __x)
3339{
3340 for (value_type* __p = __begin_; __p != __end_; ++__p)
3341 *__p ^= __x;
3342 return *this;
3343}
3344
3345template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003346inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003347valarray<_Tp>&
3348valarray<_Tp>::operator&=(const value_type& __x)
3349{
3350 for (value_type* __p = __begin_; __p != __end_; ++__p)
3351 *__p &= __x;
3352 return *this;
3353}
3354
3355template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003356inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003357valarray<_Tp>&
3358valarray<_Tp>::operator|=(const value_type& __x)
3359{
3360 for (value_type* __p = __begin_; __p != __end_; ++__p)
3361 *__p |= __x;
3362 return *this;
3363}
3364
3365template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003366inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003367valarray<_Tp>&
3368valarray<_Tp>::operator<<=(const value_type& __x)
3369{
3370 for (value_type* __p = __begin_; __p != __end_; ++__p)
3371 *__p <<= __x;
3372 return *this;
3373}
3374
3375template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003376inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003377valarray<_Tp>&
3378valarray<_Tp>::operator>>=(const value_type& __x)
3379{
3380 for (value_type* __p = __begin_; __p != __end_; ++__p)
3381 *__p >>= __x;
3382 return *this;
3383}
3384
3385template <class _Tp>
3386template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003387inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003388typename enable_if
3389<
3390 __is_val_expr<_Expr>::value,
3391 valarray<_Tp>&
3392>::type
3393valarray<_Tp>::operator*=(const _Expr& __v)
3394{
3395 size_t __i = 0;
3396 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3397 *__t *= __v[__i];
3398 return *this;
3399}
3400
3401template <class _Tp>
3402template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003403inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003404typename enable_if
3405<
3406 __is_val_expr<_Expr>::value,
3407 valarray<_Tp>&
3408>::type
3409valarray<_Tp>::operator/=(const _Expr& __v)
3410{
3411 size_t __i = 0;
3412 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3413 *__t /= __v[__i];
3414 return *this;
3415}
3416
3417template <class _Tp>
3418template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003419inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003420typename enable_if
3421<
3422 __is_val_expr<_Expr>::value,
3423 valarray<_Tp>&
3424>::type
3425valarray<_Tp>::operator%=(const _Expr& __v)
3426{
3427 size_t __i = 0;
3428 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3429 *__t %= __v[__i];
3430 return *this;
3431}
3432
3433template <class _Tp>
3434template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003435inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003436typename enable_if
3437<
3438 __is_val_expr<_Expr>::value,
3439 valarray<_Tp>&
3440>::type
3441valarray<_Tp>::operator+=(const _Expr& __v)
3442{
3443 size_t __i = 0;
3444 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3445 *__t += __v[__i];
3446 return *this;
3447}
3448
3449template <class _Tp>
3450template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003451inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003452typename enable_if
3453<
3454 __is_val_expr<_Expr>::value,
3455 valarray<_Tp>&
3456>::type
3457valarray<_Tp>::operator-=(const _Expr& __v)
3458{
3459 size_t __i = 0;
3460 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3461 *__t -= __v[__i];
3462 return *this;
3463}
3464
3465template <class _Tp>
3466template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003467inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003468typename enable_if
3469<
3470 __is_val_expr<_Expr>::value,
3471 valarray<_Tp>&
3472>::type
3473valarray<_Tp>::operator^=(const _Expr& __v)
3474{
3475 size_t __i = 0;
3476 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3477 *__t ^= __v[__i];
3478 return *this;
3479}
3480
3481template <class _Tp>
3482template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003483inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003484typename enable_if
3485<
3486 __is_val_expr<_Expr>::value,
3487 valarray<_Tp>&
3488>::type
3489valarray<_Tp>::operator|=(const _Expr& __v)
3490{
3491 size_t __i = 0;
3492 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3493 *__t |= __v[__i];
3494 return *this;
3495}
3496
3497template <class _Tp>
3498template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003499inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003500typename enable_if
3501<
3502 __is_val_expr<_Expr>::value,
3503 valarray<_Tp>&
3504>::type
3505valarray<_Tp>::operator&=(const _Expr& __v)
3506{
3507 size_t __i = 0;
3508 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3509 *__t &= __v[__i];
3510 return *this;
3511}
3512
3513template <class _Tp>
3514template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003515inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003516typename enable_if
3517<
3518 __is_val_expr<_Expr>::value,
3519 valarray<_Tp>&
3520>::type
3521valarray<_Tp>::operator<<=(const _Expr& __v)
3522{
3523 size_t __i = 0;
3524 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3525 *__t <<= __v[__i];
3526 return *this;
3527}
3528
3529template <class _Tp>
3530template <class _Expr>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003531inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003532typename enable_if
3533<
3534 __is_val_expr<_Expr>::value,
3535 valarray<_Tp>&
3536>::type
3537valarray<_Tp>::operator>>=(const _Expr& __v)
3538{
3539 size_t __i = 0;
3540 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3541 *__t >>= __v[__i];
3542 return *this;
3543}
3544
3545template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003546inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003547void
Howard Hinnantbd143082012-07-21 00:51:28 +00003548valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003549{
Howard Hinnant0949eed2011-06-30 21:18:19 +00003550 _VSTD::swap(__begin_, __v.__begin_);
3551 _VSTD::swap(__end_, __v.__end_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003552}
3553
3554template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003555inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003556_Tp
3557valarray<_Tp>::sum() const
3558{
3559 if (__begin_ == __end_)
3560 return value_type();
3561 const value_type* __p = __begin_;
3562 _Tp __r = *__p;
3563 for (++__p; __p != __end_; ++__p)
3564 __r += *__p;
3565 return __r;
3566}
3567
3568template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003569inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003570_Tp
3571valarray<_Tp>::min() const
3572{
3573 if (__begin_ == __end_)
3574 return value_type();
Howard Hinnant0949eed2011-06-30 21:18:19 +00003575 return *_VSTD::min_element(__begin_, __end_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003576}
3577
3578template <class _Tp>
Evgeniy Stepanova3b25f82015-11-07 01:22:13 +00003579inline
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003580_Tp
3581valarray<_Tp>::max() const
3582{
3583 if (__begin_ == __end_)
3584 return value_type();
Howard Hinnant0949eed2011-06-30 21:18:19 +00003585 return *_VSTD::max_element(__begin_, __end_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003586}
3587
3588template <class _Tp>
3589valarray<_Tp>
3590valarray<_Tp>::shift(int __i) const
3591{
3592 valarray<value_type> __r;
3593 size_t __n = size();
3594 if (__n)
3595 {
3596 __r.__begin_ =
3597 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003598 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003599 const value_type* __sb;
3600 value_type* __tb;
3601 value_type* __te;
3602 if (__i >= 0)
3603 {
Howard Hinnant0949eed2011-06-30 21:18:19 +00003604 __i = _VSTD::min(__i, static_cast<int>(__n));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003605 __sb = __begin_ + __i;
3606 __tb = __r.__begin_;
3607 __te = __r.__begin_ + (__n - __i);
3608 }
3609 else
3610 {
Howard Hinnant0949eed2011-06-30 21:18:19 +00003611 __i = _VSTD::min(-__i, static_cast<int>(__n));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003612 __sb = __begin_;
3613 __tb = __r.__begin_ + __i;
3614 __te = __r.__begin_ + __n;
3615 }
3616 for (; __r.__end_ != __tb; ++__r.__end_)
3617 ::new (__r.__end_) value_type();
3618 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3619 ::new (__r.__end_) value_type(*__sb);
3620 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3621 ::new (__r.__end_) value_type();
3622 }
3623 return __r;
3624}
3625
3626template <class _Tp>
3627valarray<_Tp>
3628valarray<_Tp>::cshift(int __i) const
3629{
3630 valarray<value_type> __r;
3631 size_t __n = size();
3632 if (__n)
3633 {
3634 __r.__begin_ =
3635 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003636 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003637 __i %= static_cast<int>(__n);
3638 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3639 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3640 ::new (__r.__end_) value_type(*__s);
3641 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3642 ::new (__r.__end_) value_type(*__s);
3643 }
3644 return __r;
3645}
3646
3647template <class _Tp>
3648valarray<_Tp>
3649valarray<_Tp>::apply(value_type __f(value_type)) const
3650{
3651 valarray<value_type> __r;
3652 size_t __n = size();
3653 if (__n)
3654 {
3655 __r.__begin_ =
3656 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003657 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003658 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3659 ::new (__r.__end_) value_type(__f(*__p));
3660 }
3661 return __r;
3662}
3663
3664template <class _Tp>
3665valarray<_Tp>
3666valarray<_Tp>::apply(value_type __f(const value_type&)) const
3667{
3668 valarray<value_type> __r;
3669 size_t __n = size();
3670 if (__n)
3671 {
3672 __r.__begin_ =
3673 __r.__end_ =
Richard Smith73c1fce2014-06-04 19:54:15 +00003674 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003675 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3676 ::new (__r.__end_) value_type(__f(*__p));
3677 }
3678 return __r;
3679}
3680
3681template <class _Tp>
3682void
3683valarray<_Tp>::resize(size_t __n, value_type __x)
3684{
3685 if (__begin_ != nullptr)
3686 {
3687 while (__end_ != __begin_)
3688 (--__end_)->~value_type();
Eric Fiselier32b19c32017-01-07 03:01:24 +00003689 _VSTD::__libcpp_deallocate(__begin_);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003690 __begin_ = __end_ = nullptr;
3691 }
3692 if (__n)
3693 {
Richard Smith73c1fce2014-06-04 19:54:15 +00003694 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003695#ifndef _LIBCPP_NO_EXCEPTIONS
3696 try
3697 {
Howard Hinnant324bb032010-08-22 00:02:43 +00003698#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003699 for (; __n; --__n, ++__end_)
3700 ::new (__end_) value_type(__x);
3701#ifndef _LIBCPP_NO_EXCEPTIONS
3702 }
3703 catch (...)
3704 {
3705 resize(0);
3706 throw;
3707 }
Howard Hinnant324bb032010-08-22 00:02:43 +00003708#endif // _LIBCPP_NO_EXCEPTIONS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003709 }
3710}
3711
3712template<class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003713inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003714void
Howard Hinnantbd143082012-07-21 00:51:28 +00003715swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003716{
3717 __x.swap(__y);
3718}
3719
3720template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003721inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003722typename enable_if
3723<
3724 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3725 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3726>::type
3727operator*(const _Expr1& __x, const _Expr2& __y)
3728{
3729 typedef typename _Expr1::value_type value_type;
3730 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3731 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3732}
3733
3734template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003735inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003736typename enable_if
3737<
3738 __is_val_expr<_Expr>::value,
3739 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3740 _Expr, __scalar_expr<typename _Expr::value_type> > >
3741>::type
3742operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3743{
3744 typedef typename _Expr::value_type value_type;
3745 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3746 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3747 __x, __scalar_expr<value_type>(__y, __x.size())));
3748}
3749
3750template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003751inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003752typename enable_if
3753<
3754 __is_val_expr<_Expr>::value,
3755 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3756 __scalar_expr<typename _Expr::value_type>, _Expr> >
3757>::type
3758operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3759{
3760 typedef typename _Expr::value_type value_type;
3761 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3762 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3763 __scalar_expr<value_type>(__x, __y.size()), __y));
3764}
3765
3766template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003767inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003768typename enable_if
3769<
3770 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3771 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3772>::type
3773operator/(const _Expr1& __x, const _Expr2& __y)
3774{
3775 typedef typename _Expr1::value_type value_type;
3776 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3777 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3778}
3779
3780template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003781inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003782typename enable_if
3783<
3784 __is_val_expr<_Expr>::value,
3785 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3786 _Expr, __scalar_expr<typename _Expr::value_type> > >
3787>::type
3788operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3789{
3790 typedef typename _Expr::value_type value_type;
3791 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3792 return __val_expr<_Op>(_Op(divides<value_type>(),
3793 __x, __scalar_expr<value_type>(__y, __x.size())));
3794}
3795
3796template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003797inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003798typename enable_if
3799<
3800 __is_val_expr<_Expr>::value,
3801 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3802 __scalar_expr<typename _Expr::value_type>, _Expr> >
3803>::type
3804operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3805{
3806 typedef typename _Expr::value_type value_type;
3807 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3808 return __val_expr<_Op>(_Op(divides<value_type>(),
3809 __scalar_expr<value_type>(__x, __y.size()), __y));
3810}
3811
3812template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003813inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003814typename enable_if
3815<
3816 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3817 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3818>::type
3819operator%(const _Expr1& __x, const _Expr2& __y)
3820{
3821 typedef typename _Expr1::value_type value_type;
3822 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3823 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3824}
3825
3826template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003827inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003828typename enable_if
3829<
3830 __is_val_expr<_Expr>::value,
3831 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3832 _Expr, __scalar_expr<typename _Expr::value_type> > >
3833>::type
3834operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3835{
3836 typedef typename _Expr::value_type value_type;
3837 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3838 return __val_expr<_Op>(_Op(modulus<value_type>(),
3839 __x, __scalar_expr<value_type>(__y, __x.size())));
3840}
3841
3842template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003843inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003844typename enable_if
3845<
3846 __is_val_expr<_Expr>::value,
3847 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3848 __scalar_expr<typename _Expr::value_type>, _Expr> >
3849>::type
3850operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3851{
3852 typedef typename _Expr::value_type value_type;
3853 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3854 return __val_expr<_Op>(_Op(modulus<value_type>(),
3855 __scalar_expr<value_type>(__x, __y.size()), __y));
3856}
3857
3858template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003859inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003860typename enable_if
3861<
3862 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3863 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3864>::type
3865operator+(const _Expr1& __x, const _Expr2& __y)
3866{
3867 typedef typename _Expr1::value_type value_type;
3868 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3869 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3870}
3871
3872template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003873inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003874typename enable_if
3875<
3876 __is_val_expr<_Expr>::value,
3877 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3878 _Expr, __scalar_expr<typename _Expr::value_type> > >
3879>::type
3880operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3881{
3882 typedef typename _Expr::value_type value_type;
3883 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3884 return __val_expr<_Op>(_Op(plus<value_type>(),
3885 __x, __scalar_expr<value_type>(__y, __x.size())));
3886}
3887
3888template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003889inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003890typename enable_if
3891<
3892 __is_val_expr<_Expr>::value,
3893 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3894 __scalar_expr<typename _Expr::value_type>, _Expr> >
3895>::type
3896operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3897{
3898 typedef typename _Expr::value_type value_type;
3899 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3900 return __val_expr<_Op>(_Op(plus<value_type>(),
3901 __scalar_expr<value_type>(__x, __y.size()), __y));
3902}
3903
3904template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003905inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003906typename enable_if
3907<
3908 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3909 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3910>::type
3911operator-(const _Expr1& __x, const _Expr2& __y)
3912{
3913 typedef typename _Expr1::value_type value_type;
3914 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3915 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3916}
3917
3918template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003919inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003920typename enable_if
3921<
3922 __is_val_expr<_Expr>::value,
3923 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3924 _Expr, __scalar_expr<typename _Expr::value_type> > >
3925>::type
3926operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3927{
3928 typedef typename _Expr::value_type value_type;
3929 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3930 return __val_expr<_Op>(_Op(minus<value_type>(),
3931 __x, __scalar_expr<value_type>(__y, __x.size())));
3932}
3933
3934template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003935inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003936typename enable_if
3937<
3938 __is_val_expr<_Expr>::value,
3939 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3940 __scalar_expr<typename _Expr::value_type>, _Expr> >
3941>::type
3942operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3943{
3944 typedef typename _Expr::value_type value_type;
3945 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3946 return __val_expr<_Op>(_Op(minus<value_type>(),
3947 __scalar_expr<value_type>(__x, __y.size()), __y));
3948}
3949
3950template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003951inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003952typename enable_if
3953<
3954 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3955 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3956>::type
3957operator^(const _Expr1& __x, const _Expr2& __y)
3958{
3959 typedef typename _Expr1::value_type value_type;
3960 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3961 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3962}
3963
3964template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003965inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003966typename enable_if
3967<
3968 __is_val_expr<_Expr>::value,
3969 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3970 _Expr, __scalar_expr<typename _Expr::value_type> > >
3971>::type
3972operator^(const _Expr& __x, const typename _Expr::value_type& __y)
3973{
3974 typedef typename _Expr::value_type value_type;
3975 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3976 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3977 __x, __scalar_expr<value_type>(__y, __x.size())));
3978}
3979
3980template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003981inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003982typename enable_if
3983<
3984 __is_val_expr<_Expr>::value,
3985 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3986 __scalar_expr<typename _Expr::value_type>, _Expr> >
3987>::type
3988operator^(const typename _Expr::value_type& __x, const _Expr& __y)
3989{
3990 typedef typename _Expr::value_type value_type;
3991 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3992 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3993 __scalar_expr<value_type>(__x, __y.size()), __y));
3994}
3995
3996template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00003997inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00003998typename enable_if
3999<
4000 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4001 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4002>::type
4003operator&(const _Expr1& __x, const _Expr2& __y)
4004{
4005 typedef typename _Expr1::value_type value_type;
4006 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
4007 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
4008}
4009
4010template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004011inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004012typename enable_if
4013<
4014 __is_val_expr<_Expr>::value,
4015 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4016 _Expr, __scalar_expr<typename _Expr::value_type> > >
4017>::type
4018operator&(const _Expr& __x, const typename _Expr::value_type& __y)
4019{
4020 typedef typename _Expr::value_type value_type;
4021 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4022 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4023 __x, __scalar_expr<value_type>(__y, __x.size())));
4024}
4025
4026template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004027inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004028typename enable_if
4029<
4030 __is_val_expr<_Expr>::value,
4031 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4032 __scalar_expr<typename _Expr::value_type>, _Expr> >
4033>::type
4034operator&(const typename _Expr::value_type& __x, const _Expr& __y)
4035{
4036 typedef typename _Expr::value_type value_type;
4037 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4038 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4039 __scalar_expr<value_type>(__x, __y.size()), __y));
4040}
4041
4042template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004043inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004044typename enable_if
4045<
4046 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4047 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4048>::type
4049operator|(const _Expr1& __x, const _Expr2& __y)
4050{
4051 typedef typename _Expr1::value_type value_type;
4052 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
4053 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
4054}
4055
4056template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004057inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004058typename enable_if
4059<
4060 __is_val_expr<_Expr>::value,
4061 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4062 _Expr, __scalar_expr<typename _Expr::value_type> > >
4063>::type
4064operator|(const _Expr& __x, const typename _Expr::value_type& __y)
4065{
4066 typedef typename _Expr::value_type value_type;
4067 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4068 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4069 __x, __scalar_expr<value_type>(__y, __x.size())));
4070}
4071
4072template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004073inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004074typename enable_if
4075<
4076 __is_val_expr<_Expr>::value,
4077 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4078 __scalar_expr<typename _Expr::value_type>, _Expr> >
4079>::type
4080operator|(const typename _Expr::value_type& __x, const _Expr& __y)
4081{
4082 typedef typename _Expr::value_type value_type;
4083 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4084 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4085 __scalar_expr<value_type>(__x, __y.size()), __y));
4086}
4087
4088template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004089inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004090typename enable_if
4091<
4092 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4093 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4094>::type
4095operator<<(const _Expr1& __x, const _Expr2& __y)
4096{
4097 typedef typename _Expr1::value_type value_type;
4098 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4099 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4100}
4101
4102template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004103inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004104typename enable_if
4105<
4106 __is_val_expr<_Expr>::value,
4107 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4108 _Expr, __scalar_expr<typename _Expr::value_type> > >
4109>::type
4110operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4111{
4112 typedef typename _Expr::value_type value_type;
4113 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4114 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4115 __x, __scalar_expr<value_type>(__y, __x.size())));
4116}
4117
4118template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004119inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004120typename enable_if
4121<
4122 __is_val_expr<_Expr>::value,
4123 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4124 __scalar_expr<typename _Expr::value_type>, _Expr> >
4125>::type
4126operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4127{
4128 typedef typename _Expr::value_type value_type;
4129 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4130 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4131 __scalar_expr<value_type>(__x, __y.size()), __y));
4132}
4133
4134template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004135inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004136typename enable_if
4137<
4138 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4139 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4140>::type
4141operator>>(const _Expr1& __x, const _Expr2& __y)
4142{
4143 typedef typename _Expr1::value_type value_type;
4144 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4145 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4146}
4147
4148template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004149inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004150typename enable_if
4151<
4152 __is_val_expr<_Expr>::value,
4153 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4154 _Expr, __scalar_expr<typename _Expr::value_type> > >
4155>::type
4156operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4157{
4158 typedef typename _Expr::value_type value_type;
4159 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4160 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4161 __x, __scalar_expr<value_type>(__y, __x.size())));
4162}
4163
4164template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004165inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004166typename enable_if
4167<
4168 __is_val_expr<_Expr>::value,
4169 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4170 __scalar_expr<typename _Expr::value_type>, _Expr> >
4171>::type
4172operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4173{
4174 typedef typename _Expr::value_type value_type;
4175 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4176 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4177 __scalar_expr<value_type>(__x, __y.size()), __y));
4178}
4179
4180template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004181inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004182typename enable_if
4183<
4184 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4185 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4186>::type
4187operator&&(const _Expr1& __x, const _Expr2& __y)
4188{
4189 typedef typename _Expr1::value_type value_type;
4190 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4191 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4192}
4193
4194template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004195inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004196typename enable_if
4197<
4198 __is_val_expr<_Expr>::value,
4199 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4200 _Expr, __scalar_expr<typename _Expr::value_type> > >
4201>::type
4202operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4203{
4204 typedef typename _Expr::value_type value_type;
4205 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4206 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4207 __x, __scalar_expr<value_type>(__y, __x.size())));
4208}
4209
4210template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004211inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004212typename enable_if
4213<
4214 __is_val_expr<_Expr>::value,
4215 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4216 __scalar_expr<typename _Expr::value_type>, _Expr> >
4217>::type
4218operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4219{
4220 typedef typename _Expr::value_type value_type;
4221 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4222 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4223 __scalar_expr<value_type>(__x, __y.size()), __y));
4224}
4225
4226template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004227inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004228typename enable_if
4229<
4230 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4231 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4232>::type
4233operator||(const _Expr1& __x, const _Expr2& __y)
4234{
4235 typedef typename _Expr1::value_type value_type;
4236 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4237 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4238}
4239
4240template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004241inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004242typename enable_if
4243<
4244 __is_val_expr<_Expr>::value,
4245 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4246 _Expr, __scalar_expr<typename _Expr::value_type> > >
4247>::type
4248operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4249{
4250 typedef typename _Expr::value_type value_type;
4251 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4252 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4253 __x, __scalar_expr<value_type>(__y, __x.size())));
4254}
4255
4256template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004257inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004258typename enable_if
4259<
4260 __is_val_expr<_Expr>::value,
4261 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4262 __scalar_expr<typename _Expr::value_type>, _Expr> >
4263>::type
4264operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4265{
4266 typedef typename _Expr::value_type value_type;
4267 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4268 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4269 __scalar_expr<value_type>(__x, __y.size()), __y));
4270}
4271
4272template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004273inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004274typename enable_if
4275<
4276 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4277 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4278>::type
4279operator==(const _Expr1& __x, const _Expr2& __y)
4280{
4281 typedef typename _Expr1::value_type value_type;
4282 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4283 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4284}
4285
4286template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004287inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004288typename enable_if
4289<
4290 __is_val_expr<_Expr>::value,
4291 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4292 _Expr, __scalar_expr<typename _Expr::value_type> > >
4293>::type
4294operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4295{
4296 typedef typename _Expr::value_type value_type;
4297 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4298 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4299 __x, __scalar_expr<value_type>(__y, __x.size())));
4300}
4301
4302template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004303inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004304typename enable_if
4305<
4306 __is_val_expr<_Expr>::value,
4307 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4308 __scalar_expr<typename _Expr::value_type>, _Expr> >
4309>::type
4310operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4311{
4312 typedef typename _Expr::value_type value_type;
4313 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4314 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4315 __scalar_expr<value_type>(__x, __y.size()), __y));
4316}
4317
4318template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004319inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004320typename enable_if
4321<
4322 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4323 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4324>::type
4325operator!=(const _Expr1& __x, const _Expr2& __y)
4326{
4327 typedef typename _Expr1::value_type value_type;
4328 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4329 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4330}
4331
4332template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004333inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004334typename enable_if
4335<
4336 __is_val_expr<_Expr>::value,
4337 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4338 _Expr, __scalar_expr<typename _Expr::value_type> > >
4339>::type
4340operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4341{
4342 typedef typename _Expr::value_type value_type;
4343 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4344 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4345 __x, __scalar_expr<value_type>(__y, __x.size())));
4346}
4347
4348template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004349inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004350typename enable_if
4351<
4352 __is_val_expr<_Expr>::value,
4353 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4354 __scalar_expr<typename _Expr::value_type>, _Expr> >
4355>::type
4356operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4357{
4358 typedef typename _Expr::value_type value_type;
4359 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4360 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4361 __scalar_expr<value_type>(__x, __y.size()), __y));
4362}
4363
4364template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004365inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004366typename enable_if
4367<
4368 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4369 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4370>::type
4371operator<(const _Expr1& __x, const _Expr2& __y)
4372{
4373 typedef typename _Expr1::value_type value_type;
4374 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4375 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4376}
4377
4378template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004379inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004380typename enable_if
4381<
4382 __is_val_expr<_Expr>::value,
4383 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4384 _Expr, __scalar_expr<typename _Expr::value_type> > >
4385>::type
4386operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4387{
4388 typedef typename _Expr::value_type value_type;
4389 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4390 return __val_expr<_Op>(_Op(less<value_type>(),
4391 __x, __scalar_expr<value_type>(__y, __x.size())));
4392}
4393
4394template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004395inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004396typename enable_if
4397<
4398 __is_val_expr<_Expr>::value,
4399 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4400 __scalar_expr<typename _Expr::value_type>, _Expr> >
4401>::type
4402operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4403{
4404 typedef typename _Expr::value_type value_type;
4405 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4406 return __val_expr<_Op>(_Op(less<value_type>(),
4407 __scalar_expr<value_type>(__x, __y.size()), __y));
4408}
4409
4410template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004411inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004412typename enable_if
4413<
4414 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4415 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4416>::type
4417operator>(const _Expr1& __x, const _Expr2& __y)
4418{
4419 typedef typename _Expr1::value_type value_type;
4420 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4421 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4422}
4423
4424template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004425inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004426typename enable_if
4427<
4428 __is_val_expr<_Expr>::value,
4429 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4430 _Expr, __scalar_expr<typename _Expr::value_type> > >
4431>::type
4432operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4433{
4434 typedef typename _Expr::value_type value_type;
4435 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4436 return __val_expr<_Op>(_Op(greater<value_type>(),
4437 __x, __scalar_expr<value_type>(__y, __x.size())));
4438}
4439
4440template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004441inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004442typename enable_if
4443<
4444 __is_val_expr<_Expr>::value,
4445 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4446 __scalar_expr<typename _Expr::value_type>, _Expr> >
4447>::type
4448operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4449{
4450 typedef typename _Expr::value_type value_type;
4451 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4452 return __val_expr<_Op>(_Op(greater<value_type>(),
4453 __scalar_expr<value_type>(__x, __y.size()), __y));
4454}
4455
4456template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004457inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004458typename enable_if
4459<
4460 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4461 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4462>::type
4463operator<=(const _Expr1& __x, const _Expr2& __y)
4464{
4465 typedef typename _Expr1::value_type value_type;
4466 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4467 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4468}
4469
4470template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004471inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004472typename enable_if
4473<
4474 __is_val_expr<_Expr>::value,
4475 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4476 _Expr, __scalar_expr<typename _Expr::value_type> > >
4477>::type
4478operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4479{
4480 typedef typename _Expr::value_type value_type;
4481 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4482 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4483 __x, __scalar_expr<value_type>(__y, __x.size())));
4484}
4485
4486template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004487inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004488typename enable_if
4489<
4490 __is_val_expr<_Expr>::value,
4491 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4492 __scalar_expr<typename _Expr::value_type>, _Expr> >
4493>::type
4494operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4495{
4496 typedef typename _Expr::value_type value_type;
4497 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4498 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4499 __scalar_expr<value_type>(__x, __y.size()), __y));
4500}
4501
4502template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004503inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004504typename enable_if
4505<
4506 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4507 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4508>::type
4509operator>=(const _Expr1& __x, const _Expr2& __y)
4510{
4511 typedef typename _Expr1::value_type value_type;
4512 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4513 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4514}
4515
4516template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004517inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004518typename enable_if
4519<
4520 __is_val_expr<_Expr>::value,
4521 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4522 _Expr, __scalar_expr<typename _Expr::value_type> > >
4523>::type
4524operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4525{
4526 typedef typename _Expr::value_type value_type;
4527 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4528 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4529 __x, __scalar_expr<value_type>(__y, __x.size())));
4530}
4531
4532template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004533inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004534typename enable_if
4535<
4536 __is_val_expr<_Expr>::value,
4537 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4538 __scalar_expr<typename _Expr::value_type>, _Expr> >
4539>::type
4540operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4541{
4542 typedef typename _Expr::value_type value_type;
4543 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4544 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4545 __scalar_expr<value_type>(__x, __y.size()), __y));
4546}
4547
4548template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004549inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004550typename enable_if
4551<
4552 __is_val_expr<_Expr>::value,
4553 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4554>::type
4555abs(const _Expr& __x)
4556{
4557 typedef typename _Expr::value_type value_type;
4558 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4559 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4560}
4561
4562template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004563inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004564typename enable_if
4565<
4566 __is_val_expr<_Expr>::value,
4567 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4568>::type
4569acos(const _Expr& __x)
4570{
4571 typedef typename _Expr::value_type value_type;
4572 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4573 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4574}
4575
4576template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004577inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004578typename enable_if
4579<
4580 __is_val_expr<_Expr>::value,
4581 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4582>::type
4583asin(const _Expr& __x)
4584{
4585 typedef typename _Expr::value_type value_type;
4586 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4587 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4588}
4589
4590template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004591inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004592typename enable_if
4593<
4594 __is_val_expr<_Expr>::value,
4595 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4596>::type
4597atan(const _Expr& __x)
4598{
4599 typedef typename _Expr::value_type value_type;
4600 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4601 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4602}
4603
4604template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004605inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004606typename enable_if
4607<
4608 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4609 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4610>::type
4611atan2(const _Expr1& __x, const _Expr2& __y)
4612{
4613 typedef typename _Expr1::value_type value_type;
4614 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4615 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4616}
4617
4618template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004619inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004620typename enable_if
4621<
4622 __is_val_expr<_Expr>::value,
4623 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4624 _Expr, __scalar_expr<typename _Expr::value_type> > >
4625>::type
4626atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4627{
4628 typedef typename _Expr::value_type value_type;
4629 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4630 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4631 __x, __scalar_expr<value_type>(__y, __x.size())));
4632}
4633
4634template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004635inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004636typename enable_if
4637<
4638 __is_val_expr<_Expr>::value,
4639 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4640 __scalar_expr<typename _Expr::value_type>, _Expr> >
4641>::type
4642atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4643{
4644 typedef typename _Expr::value_type value_type;
4645 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4646 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4647 __scalar_expr<value_type>(__x, __y.size()), __y));
4648}
4649
4650template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004651inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004652typename enable_if
4653<
4654 __is_val_expr<_Expr>::value,
4655 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4656>::type
4657cos(const _Expr& __x)
4658{
4659 typedef typename _Expr::value_type value_type;
4660 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4661 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4662}
4663
4664template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004665inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004666typename enable_if
4667<
4668 __is_val_expr<_Expr>::value,
4669 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4670>::type
4671cosh(const _Expr& __x)
4672{
4673 typedef typename _Expr::value_type value_type;
4674 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4675 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4676}
4677
4678template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004679inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004680typename enable_if
4681<
4682 __is_val_expr<_Expr>::value,
4683 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4684>::type
4685exp(const _Expr& __x)
4686{
4687 typedef typename _Expr::value_type value_type;
4688 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4689 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4690}
4691
4692template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004693inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004694typename enable_if
4695<
4696 __is_val_expr<_Expr>::value,
4697 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4698>::type
4699log(const _Expr& __x)
4700{
4701 typedef typename _Expr::value_type value_type;
4702 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4703 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4704}
4705
4706template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004707inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004708typename enable_if
4709<
4710 __is_val_expr<_Expr>::value,
4711 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4712>::type
4713log10(const _Expr& __x)
4714{
4715 typedef typename _Expr::value_type value_type;
4716 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4717 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4718}
4719
4720template<class _Expr1, class _Expr2>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004721inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004722typename enable_if
4723<
4724 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4725 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4726>::type
4727pow(const _Expr1& __x, const _Expr2& __y)
4728{
4729 typedef typename _Expr1::value_type value_type;
4730 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4731 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4732}
4733
4734template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004735inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004736typename enable_if
4737<
4738 __is_val_expr<_Expr>::value,
4739 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4740 _Expr, __scalar_expr<typename _Expr::value_type> > >
4741>::type
4742pow(const _Expr& __x, const typename _Expr::value_type& __y)
4743{
4744 typedef typename _Expr::value_type value_type;
4745 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4746 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4747 __x, __scalar_expr<value_type>(__y, __x.size())));
4748}
4749
4750template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004751inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004752typename enable_if
4753<
4754 __is_val_expr<_Expr>::value,
4755 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4756 __scalar_expr<typename _Expr::value_type>, _Expr> >
4757>::type
4758pow(const typename _Expr::value_type& __x, const _Expr& __y)
4759{
4760 typedef typename _Expr::value_type value_type;
4761 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4762 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4763 __scalar_expr<value_type>(__x, __y.size()), __y));
4764}
4765
4766template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004767inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004768typename enable_if
4769<
4770 __is_val_expr<_Expr>::value,
4771 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4772>::type
4773sin(const _Expr& __x)
4774{
4775 typedef typename _Expr::value_type value_type;
4776 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4777 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4778}
4779
4780template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004781inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004782typename enable_if
4783<
4784 __is_val_expr<_Expr>::value,
4785 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4786>::type
4787sinh(const _Expr& __x)
4788{
4789 typedef typename _Expr::value_type value_type;
4790 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4791 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4792}
4793
4794template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004795inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004796typename enable_if
4797<
4798 __is_val_expr<_Expr>::value,
4799 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4800>::type
4801sqrt(const _Expr& __x)
4802{
4803 typedef typename _Expr::value_type value_type;
4804 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4805 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4806}
4807
4808template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004809inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004810typename enable_if
4811<
4812 __is_val_expr<_Expr>::value,
4813 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4814>::type
4815tan(const _Expr& __x)
4816{
4817 typedef typename _Expr::value_type value_type;
4818 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4819 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4820}
4821
4822template<class _Expr>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004823inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004824typename enable_if
4825<
4826 __is_val_expr<_Expr>::value,
4827 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4828>::type
4829tanh(const _Expr& __x)
4830{
4831 typedef typename _Expr::value_type value_type;
4832 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4833 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4834}
4835
4836template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004837inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004838_Tp*
4839begin(valarray<_Tp>& __v)
4840{
4841 return __v.__begin_;
4842}
4843
4844template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004845inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004846const _Tp*
4847begin(const valarray<_Tp>& __v)
4848{
4849 return __v.__begin_;
4850}
4851
4852template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004853inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004854_Tp*
4855end(valarray<_Tp>& __v)
4856{
4857 return __v.__end_;
4858}
4859
4860template <class _Tp>
Howard Hinnantee6ccd02010-09-23 18:58:28 +00004861inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004862const _Tp*
4863end(const valarray<_Tp>& __v)
4864{
4865 return __v.__end_;
4866}
4867
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004868_LIBCPP_END_NAMESPACE_STD
4869
Eric Fiselier018a3d52017-05-31 22:07:49 +00004870_LIBCPP_POP_MACROS
4871
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004872#endif // _LIBCPP_VALARRAY