xref: /minix3/external/bsd/libc++/dist/libcxx/include/valarray (revision 4684ddb6aab0b36791c8099bc705d6140b3d05d0)
1*4684ddb6SLionel Sambuc// -*- C++ -*-
2*4684ddb6SLionel Sambuc//===-------------------------- valarray ----------------------------------===//
3*4684ddb6SLionel Sambuc//
4*4684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
5*4684ddb6SLionel Sambuc//
6*4684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
7*4684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
8*4684ddb6SLionel Sambuc//
9*4684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
10*4684ddb6SLionel Sambuc
11*4684ddb6SLionel Sambuc#ifndef _LIBCPP_VALARRAY
12*4684ddb6SLionel Sambuc#define _LIBCPP_VALARRAY
13*4684ddb6SLionel Sambuc
14*4684ddb6SLionel Sambuc/*
15*4684ddb6SLionel Sambuc    valarray synopsis
16*4684ddb6SLionel Sambuc
17*4684ddb6SLionel Sambucnamespace std
18*4684ddb6SLionel Sambuc{
19*4684ddb6SLionel Sambuc
20*4684ddb6SLionel Sambuctemplate<class T>
21*4684ddb6SLionel Sambucclass valarray
22*4684ddb6SLionel Sambuc{
23*4684ddb6SLionel Sambucpublic:
24*4684ddb6SLionel Sambuc    typedef T value_type;
25*4684ddb6SLionel Sambuc
26*4684ddb6SLionel Sambuc    // construct/destroy:
27*4684ddb6SLionel Sambuc    valarray();
28*4684ddb6SLionel Sambuc    explicit valarray(size_t n);
29*4684ddb6SLionel Sambuc    valarray(const value_type& x, size_t n);
30*4684ddb6SLionel Sambuc    valarray(const value_type* px, size_t n);
31*4684ddb6SLionel Sambuc    valarray(const valarray& v);
32*4684ddb6SLionel Sambuc    valarray(valarray&& v) noexcept;
33*4684ddb6SLionel Sambuc    valarray(const slice_array<value_type>& sa);
34*4684ddb6SLionel Sambuc    valarray(const gslice_array<value_type>& ga);
35*4684ddb6SLionel Sambuc    valarray(const mask_array<value_type>& ma);
36*4684ddb6SLionel Sambuc    valarray(const indirect_array<value_type>& ia);
37*4684ddb6SLionel Sambuc    valarray(initializer_list<value_type> il);
38*4684ddb6SLionel Sambuc    ~valarray();
39*4684ddb6SLionel Sambuc
40*4684ddb6SLionel Sambuc    // assignment:
41*4684ddb6SLionel Sambuc    valarray& operator=(const valarray& v);
42*4684ddb6SLionel Sambuc    valarray& operator=(valarray&& v) noexcept;
43*4684ddb6SLionel Sambuc    valarray& operator=(initializer_list<value_type> il);
44*4684ddb6SLionel Sambuc    valarray& operator=(const value_type& x);
45*4684ddb6SLionel Sambuc    valarray& operator=(const slice_array<value_type>& sa);
46*4684ddb6SLionel Sambuc    valarray& operator=(const gslice_array<value_type>& ga);
47*4684ddb6SLionel Sambuc    valarray& operator=(const mask_array<value_type>& ma);
48*4684ddb6SLionel Sambuc    valarray& operator=(const indirect_array<value_type>& ia);
49*4684ddb6SLionel Sambuc
50*4684ddb6SLionel Sambuc    // element access:
51*4684ddb6SLionel Sambuc    const value_type& operator[](size_t i) const;
52*4684ddb6SLionel Sambuc    value_type&       operator[](size_t i);
53*4684ddb6SLionel Sambuc
54*4684ddb6SLionel Sambuc    // subset operations:
55*4684ddb6SLionel Sambuc    valarray                   operator[](slice s) const;
56*4684ddb6SLionel Sambuc    slice_array<value_type>    operator[](slice s);
57*4684ddb6SLionel Sambuc    valarray                   operator[](const gslice& gs) const;
58*4684ddb6SLionel Sambuc    gslice_array<value_type>   operator[](const gslice& gs);
59*4684ddb6SLionel Sambuc    valarray                   operator[](const valarray<bool>& vb) const;
60*4684ddb6SLionel Sambuc    mask_array<value_type>     operator[](const valarray<bool>& vb);
61*4684ddb6SLionel Sambuc    valarray                   operator[](const valarray<size_t>& vs) const;
62*4684ddb6SLionel Sambuc    indirect_array<value_type> operator[](const valarray<size_t>& vs);
63*4684ddb6SLionel Sambuc
64*4684ddb6SLionel Sambuc    // unary operators:
65*4684ddb6SLionel Sambuc    valarray       operator+() const;
66*4684ddb6SLionel Sambuc    valarray       operator-() const;
67*4684ddb6SLionel Sambuc    valarray       operator~() const;
68*4684ddb6SLionel Sambuc    valarray<bool> operator!() const;
69*4684ddb6SLionel Sambuc
70*4684ddb6SLionel Sambuc    // computed assignment:
71*4684ddb6SLionel Sambuc    valarray& operator*= (const value_type& x);
72*4684ddb6SLionel Sambuc    valarray& operator/= (const value_type& x);
73*4684ddb6SLionel Sambuc    valarray& operator%= (const value_type& x);
74*4684ddb6SLionel Sambuc    valarray& operator+= (const value_type& x);
75*4684ddb6SLionel Sambuc    valarray& operator-= (const value_type& x);
76*4684ddb6SLionel Sambuc    valarray& operator^= (const value_type& x);
77*4684ddb6SLionel Sambuc    valarray& operator&= (const value_type& x);
78*4684ddb6SLionel Sambuc    valarray& operator|= (const value_type& x);
79*4684ddb6SLionel Sambuc    valarray& operator<<=(const value_type& x);
80*4684ddb6SLionel Sambuc    valarray& operator>>=(const value_type& x);
81*4684ddb6SLionel Sambuc
82*4684ddb6SLionel Sambuc    valarray& operator*= (const valarray& v);
83*4684ddb6SLionel Sambuc    valarray& operator/= (const valarray& v);
84*4684ddb6SLionel Sambuc    valarray& operator%= (const valarray& v);
85*4684ddb6SLionel Sambuc    valarray& operator+= (const valarray& v);
86*4684ddb6SLionel Sambuc    valarray& operator-= (const valarray& v);
87*4684ddb6SLionel Sambuc    valarray& operator^= (const valarray& v);
88*4684ddb6SLionel Sambuc    valarray& operator|= (const valarray& v);
89*4684ddb6SLionel Sambuc    valarray& operator&= (const valarray& v);
90*4684ddb6SLionel Sambuc    valarray& operator<<=(const valarray& v);
91*4684ddb6SLionel Sambuc    valarray& operator>>=(const valarray& v);
92*4684ddb6SLionel Sambuc
93*4684ddb6SLionel Sambuc    // member functions:
94*4684ddb6SLionel Sambuc    void swap(valarray& v) noexcept;
95*4684ddb6SLionel Sambuc
96*4684ddb6SLionel Sambuc    size_t size() const;
97*4684ddb6SLionel Sambuc
98*4684ddb6SLionel Sambuc    value_type sum() const;
99*4684ddb6SLionel Sambuc    value_type min() const;
100*4684ddb6SLionel Sambuc    value_type max() const;
101*4684ddb6SLionel Sambuc
102*4684ddb6SLionel Sambuc    valarray shift (int i) const;
103*4684ddb6SLionel Sambuc    valarray cshift(int i) const;
104*4684ddb6SLionel Sambuc    valarray apply(value_type f(value_type)) const;
105*4684ddb6SLionel Sambuc    valarray apply(value_type f(const value_type&)) const;
106*4684ddb6SLionel Sambuc    void resize(size_t n, value_type x = value_type());
107*4684ddb6SLionel Sambuc};
108*4684ddb6SLionel Sambuc
109*4684ddb6SLionel Sambucclass slice
110*4684ddb6SLionel Sambuc{
111*4684ddb6SLionel Sambucpublic:
112*4684ddb6SLionel Sambuc    slice();
113*4684ddb6SLionel Sambuc    slice(size_t start, size_t size, size_t stride);
114*4684ddb6SLionel Sambuc
115*4684ddb6SLionel Sambuc    size_t start()  const;
116*4684ddb6SLionel Sambuc    size_t size()   const;
117*4684ddb6SLionel Sambuc    size_t stride() const;
118*4684ddb6SLionel Sambuc};
119*4684ddb6SLionel Sambuc
120*4684ddb6SLionel Sambuctemplate <class T>
121*4684ddb6SLionel Sambucclass slice_array
122*4684ddb6SLionel Sambuc{
123*4684ddb6SLionel Sambucpublic:
124*4684ddb6SLionel Sambuc    typedef T value_type;
125*4684ddb6SLionel Sambuc
126*4684ddb6SLionel Sambuc    const slice_array& operator=(const slice_array& sa) const;
127*4684ddb6SLionel Sambuc    void operator=  (const valarray<value_type>& v) const;
128*4684ddb6SLionel Sambuc    void operator*= (const valarray<value_type>& v) const;
129*4684ddb6SLionel Sambuc    void operator/= (const valarray<value_type>& v) const;
130*4684ddb6SLionel Sambuc    void operator%= (const valarray<value_type>& v) const;
131*4684ddb6SLionel Sambuc    void operator+= (const valarray<value_type>& v) const;
132*4684ddb6SLionel Sambuc    void operator-= (const valarray<value_type>& v) const;
133*4684ddb6SLionel Sambuc    void operator^= (const valarray<value_type>& v) const;
134*4684ddb6SLionel Sambuc    void operator&= (const valarray<value_type>& v) const;
135*4684ddb6SLionel Sambuc    void operator|= (const valarray<value_type>& v) const;
136*4684ddb6SLionel Sambuc    void operator<<=(const valarray<value_type>& v) const;
137*4684ddb6SLionel Sambuc    void operator>>=(const valarray<value_type>& v) const;
138*4684ddb6SLionel Sambuc
139*4684ddb6SLionel Sambuc    void operator=(const value_type& x) const;
140*4684ddb6SLionel Sambuc
141*4684ddb6SLionel Sambuc    slice_array() = delete;
142*4684ddb6SLionel Sambuc};
143*4684ddb6SLionel Sambuc
144*4684ddb6SLionel Sambucclass gslice
145*4684ddb6SLionel Sambuc{
146*4684ddb6SLionel Sambucpublic:
147*4684ddb6SLionel Sambuc    gslice();
148*4684ddb6SLionel Sambuc    gslice(size_t start, const valarray<size_t>& size,
149*4684ddb6SLionel Sambuc                         const valarray<size_t>& stride);
150*4684ddb6SLionel Sambuc
151*4684ddb6SLionel Sambuc    size_t           start()  const;
152*4684ddb6SLionel Sambuc    valarray<size_t> size()   const;
153*4684ddb6SLionel Sambuc    valarray<size_t> stride() const;
154*4684ddb6SLionel Sambuc};
155*4684ddb6SLionel Sambuc
156*4684ddb6SLionel Sambuctemplate <class T>
157*4684ddb6SLionel Sambucclass gslice_array
158*4684ddb6SLionel Sambuc{
159*4684ddb6SLionel Sambucpublic:
160*4684ddb6SLionel Sambuc    typedef T value_type;
161*4684ddb6SLionel Sambuc
162*4684ddb6SLionel Sambuc    void operator=  (const valarray<value_type>& v) const;
163*4684ddb6SLionel Sambuc    void operator*= (const valarray<value_type>& v) const;
164*4684ddb6SLionel Sambuc    void operator/= (const valarray<value_type>& v) const;
165*4684ddb6SLionel Sambuc    void operator%= (const valarray<value_type>& v) const;
166*4684ddb6SLionel Sambuc    void operator+= (const valarray<value_type>& v) const;
167*4684ddb6SLionel Sambuc    void operator-= (const valarray<value_type>& v) const;
168*4684ddb6SLionel Sambuc    void operator^= (const valarray<value_type>& v) const;
169*4684ddb6SLionel Sambuc    void operator&= (const valarray<value_type>& v) const;
170*4684ddb6SLionel Sambuc    void operator|= (const valarray<value_type>& v) const;
171*4684ddb6SLionel Sambuc    void operator<<=(const valarray<value_type>& v) const;
172*4684ddb6SLionel Sambuc    void operator>>=(const valarray<value_type>& v) const;
173*4684ddb6SLionel Sambuc
174*4684ddb6SLionel Sambuc    gslice_array(const gslice_array& ga);
175*4684ddb6SLionel Sambuc    ~gslice_array();
176*4684ddb6SLionel Sambuc    const gslice_array& operator=(const gslice_array& ga) const;
177*4684ddb6SLionel Sambuc    void operator=(const value_type& x) const;
178*4684ddb6SLionel Sambuc
179*4684ddb6SLionel Sambuc    gslice_array() = delete;
180*4684ddb6SLionel Sambuc};
181*4684ddb6SLionel Sambuc
182*4684ddb6SLionel Sambuctemplate <class T>
183*4684ddb6SLionel Sambucclass mask_array
184*4684ddb6SLionel Sambuc{
185*4684ddb6SLionel Sambucpublic:
186*4684ddb6SLionel Sambuc    typedef T value_type;
187*4684ddb6SLionel Sambuc
188*4684ddb6SLionel Sambuc    void operator=  (const valarray<value_type>& v) const;
189*4684ddb6SLionel Sambuc    void operator*= (const valarray<value_type>& v) const;
190*4684ddb6SLionel Sambuc    void operator/= (const valarray<value_type>& v) const;
191*4684ddb6SLionel Sambuc    void operator%= (const valarray<value_type>& v) const;
192*4684ddb6SLionel Sambuc    void operator+= (const valarray<value_type>& v) const;
193*4684ddb6SLionel Sambuc    void operator-= (const valarray<value_type>& v) const;
194*4684ddb6SLionel Sambuc    void operator^= (const valarray<value_type>& v) const;
195*4684ddb6SLionel Sambuc    void operator&= (const valarray<value_type>& v) const;
196*4684ddb6SLionel Sambuc    void operator|= (const valarray<value_type>& v) const;
197*4684ddb6SLionel Sambuc    void operator<<=(const valarray<value_type>& v) const;
198*4684ddb6SLionel Sambuc    void operator>>=(const valarray<value_type>& v) const;
199*4684ddb6SLionel Sambuc
200*4684ddb6SLionel Sambuc    mask_array(const mask_array& ma);
201*4684ddb6SLionel Sambuc    ~mask_array();
202*4684ddb6SLionel Sambuc    const mask_array& operator=(const mask_array& ma) const;
203*4684ddb6SLionel Sambuc    void operator=(const value_type& x) const;
204*4684ddb6SLionel Sambuc
205*4684ddb6SLionel Sambuc    mask_array() = delete;
206*4684ddb6SLionel Sambuc};
207*4684ddb6SLionel Sambuc
208*4684ddb6SLionel Sambuctemplate <class T>
209*4684ddb6SLionel Sambucclass indirect_array
210*4684ddb6SLionel Sambuc{
211*4684ddb6SLionel Sambucpublic:
212*4684ddb6SLionel Sambuc    typedef T value_type;
213*4684ddb6SLionel Sambuc
214*4684ddb6SLionel Sambuc    void operator=  (const valarray<value_type>& v) const;
215*4684ddb6SLionel Sambuc    void operator*= (const valarray<value_type>& v) const;
216*4684ddb6SLionel Sambuc    void operator/= (const valarray<value_type>& v) const;
217*4684ddb6SLionel Sambuc    void operator%= (const valarray<value_type>& v) const;
218*4684ddb6SLionel Sambuc    void operator+= (const valarray<value_type>& v) const;
219*4684ddb6SLionel Sambuc    void operator-= (const valarray<value_type>& v) const;
220*4684ddb6SLionel Sambuc    void operator^= (const valarray<value_type>& v) const;
221*4684ddb6SLionel Sambuc    void operator&= (const valarray<value_type>& v) const;
222*4684ddb6SLionel Sambuc    void operator|= (const valarray<value_type>& v) const;
223*4684ddb6SLionel Sambuc    void operator<<=(const valarray<value_type>& v) const;
224*4684ddb6SLionel Sambuc    void operator>>=(const valarray<value_type>& v) const;
225*4684ddb6SLionel Sambuc
226*4684ddb6SLionel Sambuc    indirect_array(const indirect_array& ia);
227*4684ddb6SLionel Sambuc    ~indirect_array();
228*4684ddb6SLionel Sambuc    const indirect_array& operator=(const indirect_array& ia) const;
229*4684ddb6SLionel Sambuc    void operator=(const value_type& x) const;
230*4684ddb6SLionel Sambuc
231*4684ddb6SLionel Sambuc    indirect_array() = delete;
232*4684ddb6SLionel Sambuc};
233*4684ddb6SLionel Sambuc
234*4684ddb6SLionel Sambuctemplate<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
235*4684ddb6SLionel Sambuc
236*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
237*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
238*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
239*4684ddb6SLionel Sambuc
240*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
241*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
242*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
243*4684ddb6SLionel Sambuc
244*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
245*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
246*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
247*4684ddb6SLionel Sambuc
248*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
249*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
250*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
251*4684ddb6SLionel Sambuc
252*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
253*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
254*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
255*4684ddb6SLionel Sambuc
256*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
257*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
258*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
259*4684ddb6SLionel Sambuc
260*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
261*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
262*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
263*4684ddb6SLionel Sambuc
264*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
265*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
266*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
267*4684ddb6SLionel Sambuc
268*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
269*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
270*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
271*4684ddb6SLionel Sambuc
272*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
273*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
274*4684ddb6SLionel Sambuctemplate<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
275*4684ddb6SLionel Sambuc
276*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
277*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
278*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
279*4684ddb6SLionel Sambuc
280*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
281*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
282*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
283*4684ddb6SLionel Sambuc
284*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
285*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
286*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
287*4684ddb6SLionel Sambuc
288*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
289*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
290*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
291*4684ddb6SLionel Sambuc
292*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
293*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
294*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
295*4684ddb6SLionel Sambuc
296*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
297*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
298*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
299*4684ddb6SLionel Sambuc
300*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
301*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
302*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
303*4684ddb6SLionel Sambuc
304*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
305*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
306*4684ddb6SLionel Sambuctemplate<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
307*4684ddb6SLionel Sambuc
308*4684ddb6SLionel Sambuctemplate<class T> valarray<T> abs (const valarray<T>& x);
309*4684ddb6SLionel Sambuctemplate<class T> valarray<T> acos (const valarray<T>& x);
310*4684ddb6SLionel Sambuctemplate<class T> valarray<T> asin (const valarray<T>& x);
311*4684ddb6SLionel Sambuctemplate<class T> valarray<T> atan (const valarray<T>& x);
312*4684ddb6SLionel Sambuc
313*4684ddb6SLionel Sambuctemplate<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
314*4684ddb6SLionel Sambuctemplate<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
315*4684ddb6SLionel Sambuctemplate<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
316*4684ddb6SLionel Sambuc
317*4684ddb6SLionel Sambuctemplate<class T> valarray<T> cos (const valarray<T>& x);
318*4684ddb6SLionel Sambuctemplate<class T> valarray<T> cosh (const valarray<T>& x);
319*4684ddb6SLionel Sambuctemplate<class T> valarray<T> exp (const valarray<T>& x);
320*4684ddb6SLionel Sambuctemplate<class T> valarray<T> log (const valarray<T>& x);
321*4684ddb6SLionel Sambuctemplate<class T> valarray<T> log10(const valarray<T>& x);
322*4684ddb6SLionel Sambuc
323*4684ddb6SLionel Sambuctemplate<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
324*4684ddb6SLionel Sambuctemplate<class T> valarray<T> pow(const valarray<T>& x, const T& y);
325*4684ddb6SLionel Sambuctemplate<class T> valarray<T> pow(const T& x, const valarray<T>& y);
326*4684ddb6SLionel Sambuc
327*4684ddb6SLionel Sambuctemplate<class T> valarray<T> sin (const valarray<T>& x);
328*4684ddb6SLionel Sambuctemplate<class T> valarray<T> sinh (const valarray<T>& x);
329*4684ddb6SLionel Sambuctemplate<class T> valarray<T> sqrt (const valarray<T>& x);
330*4684ddb6SLionel Sambuctemplate<class T> valarray<T> tan (const valarray<T>& x);
331*4684ddb6SLionel Sambuctemplate<class T> valarray<T> tanh (const valarray<T>& x);
332*4684ddb6SLionel Sambuc
333*4684ddb6SLionel Sambuctemplate <class T> unspecified1 begin(valarray<T>& v);
334*4684ddb6SLionel Sambuctemplate <class T> unspecified2 begin(const valarray<T>& v);
335*4684ddb6SLionel Sambuctemplate <class T> unspecified1 end(valarray<T>& v);
336*4684ddb6SLionel Sambuctemplate <class T> unspecified2 end(const valarray<T>& v);
337*4684ddb6SLionel Sambuc
338*4684ddb6SLionel Sambuc}  // std
339*4684ddb6SLionel Sambuc
340*4684ddb6SLionel Sambuc*/
341*4684ddb6SLionel Sambuc
342*4684ddb6SLionel Sambuc#include <__config>
343*4684ddb6SLionel Sambuc#include <cstddef>
344*4684ddb6SLionel Sambuc#include <cmath>
345*4684ddb6SLionel Sambuc#include <initializer_list>
346*4684ddb6SLionel Sambuc#include <algorithm>
347*4684ddb6SLionel Sambuc#include <functional>
348*4684ddb6SLionel Sambuc
349*4684ddb6SLionel Sambuc#include <__undef_min_max>
350*4684ddb6SLionel Sambuc
351*4684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
352*4684ddb6SLionel Sambuc#pragma GCC system_header
353*4684ddb6SLionel Sambuc#endif
354*4684ddb6SLionel Sambuc
355*4684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
356*4684ddb6SLionel Sambuc
357*4684ddb6SLionel Sambuctemplate<class _Tp> class _LIBCPP_TYPE_VIS_ONLY valarray;
358*4684ddb6SLionel Sambuc
359*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY slice
360*4684ddb6SLionel Sambuc{
361*4684ddb6SLionel Sambuc    size_t __start_;
362*4684ddb6SLionel Sambuc    size_t __size_;
363*4684ddb6SLionel Sambuc    size_t __stride_;
364*4684ddb6SLionel Sambucpublic:
365*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
366*4684ddb6SLionel Sambuc    slice()
367*4684ddb6SLionel Sambuc        : __start_(0),
368*4684ddb6SLionel Sambuc          __size_(0),
369*4684ddb6SLionel Sambuc          __stride_(0)
370*4684ddb6SLionel Sambuc          {}
371*4684ddb6SLionel Sambuc
372*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
373*4684ddb6SLionel Sambuc    slice(size_t __start, size_t __size, size_t __stride)
374*4684ddb6SLionel Sambuc        : __start_(__start),
375*4684ddb6SLionel Sambuc          __size_(__size),
376*4684ddb6SLionel Sambuc          __stride_(__stride)
377*4684ddb6SLionel Sambuc          {}
378*4684ddb6SLionel Sambuc
379*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY size_t start()  const {return __start_;}
380*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY size_t size()   const {return __size_;}
381*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
382*4684ddb6SLionel Sambuc};
383*4684ddb6SLionel Sambuc
384*4684ddb6SLionel Sambuctemplate <class _Tp> class _LIBCPP_TYPE_VIS_ONLY slice_array;
385*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS gslice;
386*4684ddb6SLionel Sambuctemplate <class _Tp> class _LIBCPP_TYPE_VIS_ONLY gslice_array;
387*4684ddb6SLionel Sambuctemplate <class _Tp> class _LIBCPP_TYPE_VIS_ONLY mask_array;
388*4684ddb6SLionel Sambuctemplate <class _Tp> class _LIBCPP_TYPE_VIS_ONLY indirect_array;
389*4684ddb6SLionel Sambuc
390*4684ddb6SLionel Sambuctemplate <class _Tp>
391*4684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY
392*4684ddb6SLionel Sambuc_Tp*
393*4684ddb6SLionel Sambucbegin(valarray<_Tp>& __v);
394*4684ddb6SLionel Sambuc
395*4684ddb6SLionel Sambuctemplate <class _Tp>
396*4684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY
397*4684ddb6SLionel Sambucconst _Tp*
398*4684ddb6SLionel Sambucbegin(const valarray<_Tp>& __v);
399*4684ddb6SLionel Sambuc
400*4684ddb6SLionel Sambuctemplate <class _Tp>
401*4684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY
402*4684ddb6SLionel Sambuc_Tp*
403*4684ddb6SLionel Sambucend(valarray<_Tp>& __v);
404*4684ddb6SLionel Sambuc
405*4684ddb6SLionel Sambuctemplate <class _Tp>
406*4684ddb6SLionel Sambuc_LIBCPP_INLINE_VISIBILITY
407*4684ddb6SLionel Sambucconst _Tp*
408*4684ddb6SLionel Sambucend(const valarray<_Tp>& __v);
409*4684ddb6SLionel Sambuc
410*4684ddb6SLionel Sambuctemplate <class _Op, class _A0>
411*4684ddb6SLionel Sambucstruct _UnaryOp
412*4684ddb6SLionel Sambuc{
413*4684ddb6SLionel Sambuc    typedef typename _Op::result_type result_type;
414*4684ddb6SLionel Sambuc    typedef typename _A0::value_type value_type;
415*4684ddb6SLionel Sambuc
416*4684ddb6SLionel Sambuc    _Op __op_;
417*4684ddb6SLionel Sambuc    _A0 __a0_;
418*4684ddb6SLionel Sambuc
419*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
420*4684ddb6SLionel Sambuc    _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
421*4684ddb6SLionel Sambuc
422*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
423*4684ddb6SLionel Sambuc    result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
424*4684ddb6SLionel Sambuc
425*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
426*4684ddb6SLionel Sambuc    size_t size() const {return __a0_.size();}
427*4684ddb6SLionel Sambuc};
428*4684ddb6SLionel Sambuc
429*4684ddb6SLionel Sambuctemplate <class _Op, class _A0, class _A1>
430*4684ddb6SLionel Sambucstruct _BinaryOp
431*4684ddb6SLionel Sambuc{
432*4684ddb6SLionel Sambuc    typedef typename _Op::result_type result_type;
433*4684ddb6SLionel Sambuc    typedef typename _A0::value_type value_type;
434*4684ddb6SLionel Sambuc
435*4684ddb6SLionel Sambuc    _Op __op_;
436*4684ddb6SLionel Sambuc    _A0 __a0_;
437*4684ddb6SLionel Sambuc    _A1 __a1_;
438*4684ddb6SLionel Sambuc
439*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
440*4684ddb6SLionel Sambuc    _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
441*4684ddb6SLionel Sambuc        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
442*4684ddb6SLionel Sambuc
443*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
444*4684ddb6SLionel Sambuc    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
445*4684ddb6SLionel Sambuc
446*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
447*4684ddb6SLionel Sambuc    size_t size() const {return __a0_.size();}
448*4684ddb6SLionel Sambuc};
449*4684ddb6SLionel Sambuc
450*4684ddb6SLionel Sambuctemplate <class _Tp>
451*4684ddb6SLionel Sambucclass __scalar_expr
452*4684ddb6SLionel Sambuc{
453*4684ddb6SLionel Sambucpublic:
454*4684ddb6SLionel Sambuc    typedef _Tp        value_type;
455*4684ddb6SLionel Sambuc    typedef const _Tp& result_type;
456*4684ddb6SLionel Sambucprivate:
457*4684ddb6SLionel Sambuc    const value_type& __t_;
458*4684ddb6SLionel Sambuc    size_t __s_;
459*4684ddb6SLionel Sambucpublic:
460*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
461*4684ddb6SLionel Sambuc    explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
462*4684ddb6SLionel Sambuc
463*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
464*4684ddb6SLionel Sambuc    result_type operator[](size_t) const {return __t_;}
465*4684ddb6SLionel Sambuc
466*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
467*4684ddb6SLionel Sambuc    size_t size() const {return __s_;}
468*4684ddb6SLionel Sambuc};
469*4684ddb6SLionel Sambuc
470*4684ddb6SLionel Sambuctemplate <class _Tp>
471*4684ddb6SLionel Sambucstruct __unary_plus : unary_function<_Tp, _Tp>
472*4684ddb6SLionel Sambuc{
473*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
474*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
475*4684ddb6SLionel Sambuc        {return +__x;}
476*4684ddb6SLionel Sambuc};
477*4684ddb6SLionel Sambuc
478*4684ddb6SLionel Sambuctemplate <class _Tp>
479*4684ddb6SLionel Sambucstruct __bit_not  : unary_function<_Tp, _Tp>
480*4684ddb6SLionel Sambuc{
481*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
482*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
483*4684ddb6SLionel Sambuc        {return ~__x;}
484*4684ddb6SLionel Sambuc};
485*4684ddb6SLionel Sambuc
486*4684ddb6SLionel Sambuctemplate <class _Tp>
487*4684ddb6SLionel Sambucstruct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
488*4684ddb6SLionel Sambuc{
489*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
490*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
491*4684ddb6SLionel Sambuc        {return __x << __y;}
492*4684ddb6SLionel Sambuc};
493*4684ddb6SLionel Sambuc
494*4684ddb6SLionel Sambuctemplate <class _Tp>
495*4684ddb6SLionel Sambucstruct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
496*4684ddb6SLionel Sambuc{
497*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
498*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
499*4684ddb6SLionel Sambuc        {return __x >> __y;}
500*4684ddb6SLionel Sambuc};
501*4684ddb6SLionel Sambuc
502*4684ddb6SLionel Sambuctemplate <class _Tp, class _Fp>
503*4684ddb6SLionel Sambucstruct __apply_expr   : unary_function<_Tp, _Tp>
504*4684ddb6SLionel Sambuc{
505*4684ddb6SLionel Sambucprivate:
506*4684ddb6SLionel Sambuc    _Fp __f_;
507*4684ddb6SLionel Sambucpublic:
508*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
509*4684ddb6SLionel Sambuc    explicit __apply_expr(_Fp __f) : __f_(__f) {}
510*4684ddb6SLionel Sambuc
511*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
512*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
513*4684ddb6SLionel Sambuc        {return __f_(__x);}
514*4684ddb6SLionel Sambuc};
515*4684ddb6SLionel Sambuc
516*4684ddb6SLionel Sambuctemplate <class _Tp>
517*4684ddb6SLionel Sambucstruct __abs_expr : unary_function<_Tp, _Tp>
518*4684ddb6SLionel Sambuc{
519*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
520*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
521*4684ddb6SLionel Sambuc        {return abs(__x);}
522*4684ddb6SLionel Sambuc};
523*4684ddb6SLionel Sambuc
524*4684ddb6SLionel Sambuctemplate <class _Tp>
525*4684ddb6SLionel Sambucstruct __acos_expr : unary_function<_Tp, _Tp>
526*4684ddb6SLionel Sambuc{
527*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
528*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
529*4684ddb6SLionel Sambuc        {return acos(__x);}
530*4684ddb6SLionel Sambuc};
531*4684ddb6SLionel Sambuc
532*4684ddb6SLionel Sambuctemplate <class _Tp>
533*4684ddb6SLionel Sambucstruct __asin_expr : unary_function<_Tp, _Tp>
534*4684ddb6SLionel Sambuc{
535*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
536*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
537*4684ddb6SLionel Sambuc        {return asin(__x);}
538*4684ddb6SLionel Sambuc};
539*4684ddb6SLionel Sambuc
540*4684ddb6SLionel Sambuctemplate <class _Tp>
541*4684ddb6SLionel Sambucstruct __atan_expr : unary_function<_Tp, _Tp>
542*4684ddb6SLionel Sambuc{
543*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
544*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
545*4684ddb6SLionel Sambuc        {return atan(__x);}
546*4684ddb6SLionel Sambuc};
547*4684ddb6SLionel Sambuc
548*4684ddb6SLionel Sambuctemplate <class _Tp>
549*4684ddb6SLionel Sambucstruct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
550*4684ddb6SLionel Sambuc{
551*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
552*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
553*4684ddb6SLionel Sambuc        {return atan2(__x, __y);}
554*4684ddb6SLionel Sambuc};
555*4684ddb6SLionel Sambuc
556*4684ddb6SLionel Sambuctemplate <class _Tp>
557*4684ddb6SLionel Sambucstruct __cos_expr : unary_function<_Tp, _Tp>
558*4684ddb6SLionel Sambuc{
559*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
560*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
561*4684ddb6SLionel Sambuc        {return cos(__x);}
562*4684ddb6SLionel Sambuc};
563*4684ddb6SLionel Sambuc
564*4684ddb6SLionel Sambuctemplate <class _Tp>
565*4684ddb6SLionel Sambucstruct __cosh_expr : unary_function<_Tp, _Tp>
566*4684ddb6SLionel Sambuc{
567*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
568*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
569*4684ddb6SLionel Sambuc        {return cosh(__x);}
570*4684ddb6SLionel Sambuc};
571*4684ddb6SLionel Sambuc
572*4684ddb6SLionel Sambuctemplate <class _Tp>
573*4684ddb6SLionel Sambucstruct __exp_expr : unary_function<_Tp, _Tp>
574*4684ddb6SLionel Sambuc{
575*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
576*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
577*4684ddb6SLionel Sambuc        {return exp(__x);}
578*4684ddb6SLionel Sambuc};
579*4684ddb6SLionel Sambuc
580*4684ddb6SLionel Sambuctemplate <class _Tp>
581*4684ddb6SLionel Sambucstruct __log_expr : unary_function<_Tp, _Tp>
582*4684ddb6SLionel Sambuc{
583*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
584*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
585*4684ddb6SLionel Sambuc        {return log(__x);}
586*4684ddb6SLionel Sambuc};
587*4684ddb6SLionel Sambuc
588*4684ddb6SLionel Sambuctemplate <class _Tp>
589*4684ddb6SLionel Sambucstruct __log10_expr : unary_function<_Tp, _Tp>
590*4684ddb6SLionel Sambuc{
591*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
592*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
593*4684ddb6SLionel Sambuc        {return log10(__x);}
594*4684ddb6SLionel Sambuc};
595*4684ddb6SLionel Sambuc
596*4684ddb6SLionel Sambuctemplate <class _Tp>
597*4684ddb6SLionel Sambucstruct __pow_expr : binary_function<_Tp, _Tp, _Tp>
598*4684ddb6SLionel Sambuc{
599*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
600*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x, const _Tp& __y) const
601*4684ddb6SLionel Sambuc        {return pow(__x, __y);}
602*4684ddb6SLionel Sambuc};
603*4684ddb6SLionel Sambuc
604*4684ddb6SLionel Sambuctemplate <class _Tp>
605*4684ddb6SLionel Sambucstruct __sin_expr : unary_function<_Tp, _Tp>
606*4684ddb6SLionel Sambuc{
607*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
608*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
609*4684ddb6SLionel Sambuc        {return sin(__x);}
610*4684ddb6SLionel Sambuc};
611*4684ddb6SLionel Sambuc
612*4684ddb6SLionel Sambuctemplate <class _Tp>
613*4684ddb6SLionel Sambucstruct __sinh_expr : unary_function<_Tp, _Tp>
614*4684ddb6SLionel Sambuc{
615*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
616*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
617*4684ddb6SLionel Sambuc        {return sinh(__x);}
618*4684ddb6SLionel Sambuc};
619*4684ddb6SLionel Sambuc
620*4684ddb6SLionel Sambuctemplate <class _Tp>
621*4684ddb6SLionel Sambucstruct __sqrt_expr : unary_function<_Tp, _Tp>
622*4684ddb6SLionel Sambuc{
623*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
624*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
625*4684ddb6SLionel Sambuc        {return sqrt(__x);}
626*4684ddb6SLionel Sambuc};
627*4684ddb6SLionel Sambuc
628*4684ddb6SLionel Sambuctemplate <class _Tp>
629*4684ddb6SLionel Sambucstruct __tan_expr : unary_function<_Tp, _Tp>
630*4684ddb6SLionel Sambuc{
631*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
632*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
633*4684ddb6SLionel Sambuc        {return tan(__x);}
634*4684ddb6SLionel Sambuc};
635*4684ddb6SLionel Sambuc
636*4684ddb6SLionel Sambuctemplate <class _Tp>
637*4684ddb6SLionel Sambucstruct __tanh_expr : unary_function<_Tp, _Tp>
638*4684ddb6SLionel Sambuc{
639*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
640*4684ddb6SLionel Sambuc    _Tp operator()(const _Tp& __x) const
641*4684ddb6SLionel Sambuc        {return tanh(__x);}
642*4684ddb6SLionel Sambuc};
643*4684ddb6SLionel Sambuc
644*4684ddb6SLionel Sambuctemplate <class _ValExpr>
645*4684ddb6SLionel Sambucclass __slice_expr
646*4684ddb6SLionel Sambuc{
647*4684ddb6SLionel Sambuc    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
648*4684ddb6SLionel Sambucpublic:
649*4684ddb6SLionel Sambuc    typedef typename _RmExpr::value_type value_type;
650*4684ddb6SLionel Sambuc    typedef value_type result_type;
651*4684ddb6SLionel Sambuc
652*4684ddb6SLionel Sambucprivate:
653*4684ddb6SLionel Sambuc    _ValExpr __expr_;
654*4684ddb6SLionel Sambuc    size_t __start_;
655*4684ddb6SLionel Sambuc    size_t __size_;
656*4684ddb6SLionel Sambuc    size_t __stride_;
657*4684ddb6SLionel Sambuc
658*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
659*4684ddb6SLionel Sambuc    __slice_expr(const slice& __sl, const _RmExpr& __e)
660*4684ddb6SLionel Sambuc        : __expr_(__e),
661*4684ddb6SLionel Sambuc          __start_(__sl.start()),
662*4684ddb6SLionel Sambuc          __size_(__sl.size()),
663*4684ddb6SLionel Sambuc          __stride_(__sl.stride())
664*4684ddb6SLionel Sambuc        {}
665*4684ddb6SLionel Sambucpublic:
666*4684ddb6SLionel Sambuc
667*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
668*4684ddb6SLionel Sambuc    result_type operator[](size_t __i) const
669*4684ddb6SLionel Sambuc        {return __expr_[__start_ + __i * __stride_];}
670*4684ddb6SLionel Sambuc
671*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
672*4684ddb6SLionel Sambuc    size_t size() const {return __size_;}
673*4684ddb6SLionel Sambuc
674*4684ddb6SLionel Sambuc    template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
675*4684ddb6SLionel Sambuc};
676*4684ddb6SLionel Sambuc
677*4684ddb6SLionel Sambuctemplate <class _ValExpr>
678*4684ddb6SLionel Sambucclass __mask_expr;
679*4684ddb6SLionel Sambuc
680*4684ddb6SLionel Sambuctemplate <class _ValExpr>
681*4684ddb6SLionel Sambucclass __indirect_expr;
682*4684ddb6SLionel Sambuc
683*4684ddb6SLionel Sambuctemplate <class _ValExpr>
684*4684ddb6SLionel Sambucclass __shift_expr
685*4684ddb6SLionel Sambuc{
686*4684ddb6SLionel Sambuc    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
687*4684ddb6SLionel Sambucpublic:
688*4684ddb6SLionel Sambuc    typedef typename _RmExpr::value_type value_type;
689*4684ddb6SLionel Sambuc    typedef value_type result_type;
690*4684ddb6SLionel Sambuc
691*4684ddb6SLionel Sambucprivate:
692*4684ddb6SLionel Sambuc    _ValExpr __expr_;
693*4684ddb6SLionel Sambuc    size_t __size_;
694*4684ddb6SLionel Sambuc    ptrdiff_t __ul_;
695*4684ddb6SLionel Sambuc    ptrdiff_t __sn_;
696*4684ddb6SLionel Sambuc    ptrdiff_t __n_;
697*4684ddb6SLionel Sambuc    static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
698*4684ddb6SLionel Sambuc                                    sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
699*4684ddb6SLionel Sambuc
700*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
701*4684ddb6SLionel Sambuc    __shift_expr(int __n, const _RmExpr& __e)
702*4684ddb6SLionel Sambuc        : __expr_(__e),
703*4684ddb6SLionel Sambuc          __size_(__e.size()),
704*4684ddb6SLionel Sambuc          __n_(__n)
705*4684ddb6SLionel Sambuc        {
706*4684ddb6SLionel Sambuc            ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
707*4684ddb6SLionel Sambuc            __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
708*4684ddb6SLionel Sambuc            __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
709*4684ddb6SLionel Sambuc        }
710*4684ddb6SLionel Sambucpublic:
711*4684ddb6SLionel Sambuc
712*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
713*4684ddb6SLionel Sambuc    result_type operator[](size_t __j) const
714*4684ddb6SLionel Sambuc        {
715*4684ddb6SLionel Sambuc            ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
716*4684ddb6SLionel Sambuc            ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
717*4684ddb6SLionel Sambuc            return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
718*4684ddb6SLionel Sambuc        }
719*4684ddb6SLionel Sambuc
720*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
721*4684ddb6SLionel Sambuc    size_t size() const {return __size_;}
722*4684ddb6SLionel Sambuc
723*4684ddb6SLionel Sambuc    template <class> friend class __val_expr;
724*4684ddb6SLionel Sambuc};
725*4684ddb6SLionel Sambuc
726*4684ddb6SLionel Sambuctemplate <class _ValExpr>
727*4684ddb6SLionel Sambucclass __cshift_expr
728*4684ddb6SLionel Sambuc{
729*4684ddb6SLionel Sambuc    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
730*4684ddb6SLionel Sambucpublic:
731*4684ddb6SLionel Sambuc    typedef typename _RmExpr::value_type value_type;
732*4684ddb6SLionel Sambuc    typedef value_type result_type;
733*4684ddb6SLionel Sambuc
734*4684ddb6SLionel Sambucprivate:
735*4684ddb6SLionel Sambuc    _ValExpr __expr_;
736*4684ddb6SLionel Sambuc    size_t __size_;
737*4684ddb6SLionel Sambuc    size_t __m_;
738*4684ddb6SLionel Sambuc    size_t __o1_;
739*4684ddb6SLionel Sambuc    size_t __o2_;
740*4684ddb6SLionel Sambuc
741*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
742*4684ddb6SLionel Sambuc    __cshift_expr(int __n, const _RmExpr& __e)
743*4684ddb6SLionel Sambuc        : __expr_(__e),
744*4684ddb6SLionel Sambuc          __size_(__e.size())
745*4684ddb6SLionel Sambuc        {
746*4684ddb6SLionel Sambuc            __n %= static_cast<int>(__size_);
747*4684ddb6SLionel Sambuc            if (__n >= 0)
748*4684ddb6SLionel Sambuc            {
749*4684ddb6SLionel Sambuc                __m_ = __size_ - __n;
750*4684ddb6SLionel Sambuc                __o1_ = __n;
751*4684ddb6SLionel Sambuc                __o2_ = __n - __size_;
752*4684ddb6SLionel Sambuc            }
753*4684ddb6SLionel Sambuc            else
754*4684ddb6SLionel Sambuc            {
755*4684ddb6SLionel Sambuc                __m_ = -__n;
756*4684ddb6SLionel Sambuc                __o1_ = __n + __size_;
757*4684ddb6SLionel Sambuc                __o2_ = __n;
758*4684ddb6SLionel Sambuc            }
759*4684ddb6SLionel Sambuc        }
760*4684ddb6SLionel Sambucpublic:
761*4684ddb6SLionel Sambuc
762*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
763*4684ddb6SLionel Sambuc    result_type operator[](size_t __i) const
764*4684ddb6SLionel Sambuc        {
765*4684ddb6SLionel Sambuc            if (__i < __m_)
766*4684ddb6SLionel Sambuc                return __expr_[__i + __o1_];
767*4684ddb6SLionel Sambuc            return __expr_[__i + __o2_];
768*4684ddb6SLionel Sambuc        }
769*4684ddb6SLionel Sambuc
770*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
771*4684ddb6SLionel Sambuc    size_t size() const {return __size_;}
772*4684ddb6SLionel Sambuc
773*4684ddb6SLionel Sambuc    template <class> friend class __val_expr;
774*4684ddb6SLionel Sambuc};
775*4684ddb6SLionel Sambuc
776*4684ddb6SLionel Sambuctemplate<class _ValExpr>
777*4684ddb6SLionel Sambucclass __val_expr;
778*4684ddb6SLionel Sambuc
779*4684ddb6SLionel Sambuctemplate<class _ValExpr>
780*4684ddb6SLionel Sambucstruct __is_val_expr : false_type {};
781*4684ddb6SLionel Sambuc
782*4684ddb6SLionel Sambuctemplate<class _ValExpr>
783*4684ddb6SLionel Sambucstruct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
784*4684ddb6SLionel Sambuc
785*4684ddb6SLionel Sambuctemplate<class _Tp>
786*4684ddb6SLionel Sambucstruct __is_val_expr<valarray<_Tp> > : true_type {};
787*4684ddb6SLionel Sambuc
788*4684ddb6SLionel Sambuctemplate<class _Tp>
789*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY valarray
790*4684ddb6SLionel Sambuc{
791*4684ddb6SLionel Sambucpublic:
792*4684ddb6SLionel Sambuc    typedef _Tp value_type;
793*4684ddb6SLionel Sambuc    typedef _Tp result_type;
794*4684ddb6SLionel Sambuc
795*4684ddb6SLionel Sambucprivate:
796*4684ddb6SLionel Sambuc    value_type* __begin_;
797*4684ddb6SLionel Sambuc    value_type* __end_;
798*4684ddb6SLionel Sambuc
799*4684ddb6SLionel Sambucpublic:
800*4684ddb6SLionel Sambuc    // construct/destroy:
801*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
802*4684ddb6SLionel Sambuc    valarray() : __begin_(0), __end_(0) {}
803*4684ddb6SLionel Sambuc    explicit valarray(size_t __n);
804*4684ddb6SLionel Sambuc    valarray(const value_type& __x, size_t __n);
805*4684ddb6SLionel Sambuc    valarray(const value_type* __p, size_t __n);
806*4684ddb6SLionel Sambuc    valarray(const valarray& __v);
807*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
808*4684ddb6SLionel Sambuc    valarray(valarray&& __v) _NOEXCEPT;
809*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
810*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
811*4684ddb6SLionel Sambuc    valarray(initializer_list<value_type> __il);
812*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
813*4684ddb6SLionel Sambuc    valarray(const slice_array<value_type>& __sa);
814*4684ddb6SLionel Sambuc    valarray(const gslice_array<value_type>& __ga);
815*4684ddb6SLionel Sambuc    valarray(const mask_array<value_type>& __ma);
816*4684ddb6SLionel Sambuc    valarray(const indirect_array<value_type>& __ia);
817*4684ddb6SLionel Sambuc    ~valarray();
818*4684ddb6SLionel Sambuc
819*4684ddb6SLionel Sambuc    // assignment:
820*4684ddb6SLionel Sambuc    valarray& operator=(const valarray& __v);
821*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
822*4684ddb6SLionel Sambuc    valarray& operator=(valarray&& __v) _NOEXCEPT;
823*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
824*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
825*4684ddb6SLionel Sambuc    valarray& operator=(initializer_list<value_type>);
826*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
827*4684ddb6SLionel Sambuc    valarray& operator=(const value_type& __x);
828*4684ddb6SLionel Sambuc    valarray& operator=(const slice_array<value_type>& __sa);
829*4684ddb6SLionel Sambuc    valarray& operator=(const gslice_array<value_type>& __ga);
830*4684ddb6SLionel Sambuc    valarray& operator=(const mask_array<value_type>& __ma);
831*4684ddb6SLionel Sambuc    valarray& operator=(const indirect_array<value_type>& __ia);
832*4684ddb6SLionel Sambuc    template <class _ValExpr>
833*4684ddb6SLionel Sambuc        valarray& operator=(const __val_expr<_ValExpr>& __v);
834*4684ddb6SLionel Sambuc
835*4684ddb6SLionel Sambuc    // element access:
836*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
837*4684ddb6SLionel Sambuc    const value_type& operator[](size_t __i) const {return __begin_[__i];}
838*4684ddb6SLionel Sambuc
839*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
840*4684ddb6SLionel Sambuc    value_type&       operator[](size_t __i)       {return __begin_[__i];}
841*4684ddb6SLionel Sambuc
842*4684ddb6SLionel Sambuc    // subset operations:
843*4684ddb6SLionel Sambuc    __val_expr<__slice_expr<const valarray&> >    operator[](slice __s) const;
844*4684ddb6SLionel Sambuc    slice_array<value_type>                       operator[](slice __s);
845*4684ddb6SLionel Sambuc    __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
846*4684ddb6SLionel Sambuc    gslice_array<value_type>   operator[](const gslice& __gs);
847*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
848*4684ddb6SLionel Sambuc    __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
849*4684ddb6SLionel Sambuc    gslice_array<value_type>                      operator[](gslice&& __gs);
850*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
851*4684ddb6SLionel Sambuc    __val_expr<__mask_expr<const valarray&> >     operator[](const valarray<bool>& __vb) const;
852*4684ddb6SLionel Sambuc    mask_array<value_type>                        operator[](const valarray<bool>& __vb);
853*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
854*4684ddb6SLionel Sambuc    __val_expr<__mask_expr<const valarray&> >     operator[](valarray<bool>&& __vb) const;
855*4684ddb6SLionel Sambuc    mask_array<value_type>                        operator[](valarray<bool>&& __vb);
856*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
857*4684ddb6SLionel Sambuc    __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
858*4684ddb6SLionel Sambuc    indirect_array<value_type>                    operator[](const valarray<size_t>& __vs);
859*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
860*4684ddb6SLionel Sambuc    __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
861*4684ddb6SLionel Sambuc    indirect_array<value_type>                    operator[](valarray<size_t>&& __vs);
862*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
863*4684ddb6SLionel Sambuc
864*4684ddb6SLionel Sambuc    // unary operators:
865*4684ddb6SLionel Sambuc    valarray       operator+() const;
866*4684ddb6SLionel Sambuc    valarray       operator-() const;
867*4684ddb6SLionel Sambuc    valarray       operator~() const;
868*4684ddb6SLionel Sambuc    valarray<bool> operator!() const;
869*4684ddb6SLionel Sambuc
870*4684ddb6SLionel Sambuc    // computed assignment:
871*4684ddb6SLionel Sambuc    valarray& operator*= (const value_type& __x);
872*4684ddb6SLionel Sambuc    valarray& operator/= (const value_type& __x);
873*4684ddb6SLionel Sambuc    valarray& operator%= (const value_type& __x);
874*4684ddb6SLionel Sambuc    valarray& operator+= (const value_type& __x);
875*4684ddb6SLionel Sambuc    valarray& operator-= (const value_type& __x);
876*4684ddb6SLionel Sambuc    valarray& operator^= (const value_type& __x);
877*4684ddb6SLionel Sambuc    valarray& operator&= (const value_type& __x);
878*4684ddb6SLionel Sambuc    valarray& operator|= (const value_type& __x);
879*4684ddb6SLionel Sambuc    valarray& operator<<=(const value_type& __x);
880*4684ddb6SLionel Sambuc    valarray& operator>>=(const value_type& __x);
881*4684ddb6SLionel Sambuc
882*4684ddb6SLionel Sambuc    template <class _Expr>
883*4684ddb6SLionel Sambuc    typename enable_if
884*4684ddb6SLionel Sambuc    <
885*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
886*4684ddb6SLionel Sambuc        valarray&
887*4684ddb6SLionel Sambuc    >::type
888*4684ddb6SLionel Sambuc    operator*= (const _Expr& __v);
889*4684ddb6SLionel Sambuc
890*4684ddb6SLionel Sambuc    template <class _Expr>
891*4684ddb6SLionel Sambuc    typename enable_if
892*4684ddb6SLionel Sambuc    <
893*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
894*4684ddb6SLionel Sambuc        valarray&
895*4684ddb6SLionel Sambuc    >::type
896*4684ddb6SLionel Sambuc    operator/= (const _Expr& __v);
897*4684ddb6SLionel Sambuc
898*4684ddb6SLionel Sambuc    template <class _Expr>
899*4684ddb6SLionel Sambuc    typename enable_if
900*4684ddb6SLionel Sambuc    <
901*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
902*4684ddb6SLionel Sambuc        valarray&
903*4684ddb6SLionel Sambuc    >::type
904*4684ddb6SLionel Sambuc    operator%= (const _Expr& __v);
905*4684ddb6SLionel Sambuc
906*4684ddb6SLionel Sambuc    template <class _Expr>
907*4684ddb6SLionel Sambuc    typename enable_if
908*4684ddb6SLionel Sambuc    <
909*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
910*4684ddb6SLionel Sambuc        valarray&
911*4684ddb6SLionel Sambuc    >::type
912*4684ddb6SLionel Sambuc    operator+= (const _Expr& __v);
913*4684ddb6SLionel Sambuc
914*4684ddb6SLionel Sambuc    template <class _Expr>
915*4684ddb6SLionel Sambuc    typename enable_if
916*4684ddb6SLionel Sambuc    <
917*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
918*4684ddb6SLionel Sambuc        valarray&
919*4684ddb6SLionel Sambuc    >::type
920*4684ddb6SLionel Sambuc    operator-= (const _Expr& __v);
921*4684ddb6SLionel Sambuc
922*4684ddb6SLionel Sambuc    template <class _Expr>
923*4684ddb6SLionel Sambuc    typename enable_if
924*4684ddb6SLionel Sambuc    <
925*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
926*4684ddb6SLionel Sambuc        valarray&
927*4684ddb6SLionel Sambuc    >::type
928*4684ddb6SLionel Sambuc    operator^= (const _Expr& __v);
929*4684ddb6SLionel Sambuc
930*4684ddb6SLionel Sambuc    template <class _Expr>
931*4684ddb6SLionel Sambuc    typename enable_if
932*4684ddb6SLionel Sambuc    <
933*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
934*4684ddb6SLionel Sambuc        valarray&
935*4684ddb6SLionel Sambuc    >::type
936*4684ddb6SLionel Sambuc    operator|= (const _Expr& __v);
937*4684ddb6SLionel Sambuc
938*4684ddb6SLionel Sambuc    template <class _Expr>
939*4684ddb6SLionel Sambuc    typename enable_if
940*4684ddb6SLionel Sambuc    <
941*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
942*4684ddb6SLionel Sambuc        valarray&
943*4684ddb6SLionel Sambuc    >::type
944*4684ddb6SLionel Sambuc    operator&= (const _Expr& __v);
945*4684ddb6SLionel Sambuc
946*4684ddb6SLionel Sambuc    template <class _Expr>
947*4684ddb6SLionel Sambuc    typename enable_if
948*4684ddb6SLionel Sambuc    <
949*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
950*4684ddb6SLionel Sambuc        valarray&
951*4684ddb6SLionel Sambuc    >::type
952*4684ddb6SLionel Sambuc    operator<<= (const _Expr& __v);
953*4684ddb6SLionel Sambuc
954*4684ddb6SLionel Sambuc    template <class _Expr>
955*4684ddb6SLionel Sambuc    typename enable_if
956*4684ddb6SLionel Sambuc    <
957*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
958*4684ddb6SLionel Sambuc        valarray&
959*4684ddb6SLionel Sambuc    >::type
960*4684ddb6SLionel Sambuc    operator>>= (const _Expr& __v);
961*4684ddb6SLionel Sambuc
962*4684ddb6SLionel Sambuc    // member functions:
963*4684ddb6SLionel Sambuc    void swap(valarray& __v) _NOEXCEPT;
964*4684ddb6SLionel Sambuc
965*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
966*4684ddb6SLionel Sambuc    size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
967*4684ddb6SLionel Sambuc
968*4684ddb6SLionel Sambuc    value_type sum() const;
969*4684ddb6SLionel Sambuc    value_type min() const;
970*4684ddb6SLionel Sambuc    value_type max() const;
971*4684ddb6SLionel Sambuc
972*4684ddb6SLionel Sambuc    valarray shift (int __i) const;
973*4684ddb6SLionel Sambuc    valarray cshift(int __i) const;
974*4684ddb6SLionel Sambuc    valarray apply(value_type __f(value_type)) const;
975*4684ddb6SLionel Sambuc    valarray apply(value_type __f(const value_type&)) const;
976*4684ddb6SLionel Sambuc    void     resize(size_t __n, value_type __x = value_type());
977*4684ddb6SLionel Sambuc
978*4684ddb6SLionel Sambucprivate:
979*4684ddb6SLionel Sambuc    template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
980*4684ddb6SLionel Sambuc    template <class> friend class _LIBCPP_TYPE_VIS_ONLY slice_array;
981*4684ddb6SLionel Sambuc    template <class> friend class _LIBCPP_TYPE_VIS_ONLY gslice_array;
982*4684ddb6SLionel Sambuc    template <class> friend class _LIBCPP_TYPE_VIS_ONLY mask_array;
983*4684ddb6SLionel Sambuc    template <class> friend class __mask_expr;
984*4684ddb6SLionel Sambuc    template <class> friend class _LIBCPP_TYPE_VIS_ONLY indirect_array;
985*4684ddb6SLionel Sambuc    template <class> friend class __indirect_expr;
986*4684ddb6SLionel Sambuc    template <class> friend class __val_expr;
987*4684ddb6SLionel Sambuc
988*4684ddb6SLionel Sambuc    template <class _Up>
989*4684ddb6SLionel Sambuc    friend
990*4684ddb6SLionel Sambuc    _Up*
991*4684ddb6SLionel Sambuc    begin(valarray<_Up>& __v);
992*4684ddb6SLionel Sambuc
993*4684ddb6SLionel Sambuc    template <class _Up>
994*4684ddb6SLionel Sambuc    friend
995*4684ddb6SLionel Sambuc    const _Up*
996*4684ddb6SLionel Sambuc    begin(const valarray<_Up>& __v);
997*4684ddb6SLionel Sambuc
998*4684ddb6SLionel Sambuc    template <class _Up>
999*4684ddb6SLionel Sambuc    friend
1000*4684ddb6SLionel Sambuc    _Up*
1001*4684ddb6SLionel Sambuc    end(valarray<_Up>& __v);
1002*4684ddb6SLionel Sambuc
1003*4684ddb6SLionel Sambuc    template <class _Up>
1004*4684ddb6SLionel Sambuc    friend
1005*4684ddb6SLionel Sambuc    const _Up*
1006*4684ddb6SLionel Sambuc    end(const valarray<_Up>& __v);
1007*4684ddb6SLionel Sambuc};
1008*4684ddb6SLionel Sambuc
1009*4684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
1010*4684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
1011*4684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1012*4684ddb6SLionel Sambuc
1013*4684ddb6SLionel Sambuctemplate <class _Op, class _Tp>
1014*4684ddb6SLionel Sambucstruct _UnaryOp<_Op, valarray<_Tp> >
1015*4684ddb6SLionel Sambuc{
1016*4684ddb6SLionel Sambuc    typedef typename _Op::result_type result_type;
1017*4684ddb6SLionel Sambuc    typedef _Tp value_type;
1018*4684ddb6SLionel Sambuc
1019*4684ddb6SLionel Sambuc    _Op __op_;
1020*4684ddb6SLionel Sambuc    const valarray<_Tp>& __a0_;
1021*4684ddb6SLionel Sambuc
1022*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1023*4684ddb6SLionel Sambuc    _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1024*4684ddb6SLionel Sambuc
1025*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1026*4684ddb6SLionel Sambuc    result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1027*4684ddb6SLionel Sambuc
1028*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1029*4684ddb6SLionel Sambuc    size_t size() const {return __a0_.size();}
1030*4684ddb6SLionel Sambuc};
1031*4684ddb6SLionel Sambuc
1032*4684ddb6SLionel Sambuctemplate <class _Op, class _Tp, class _A1>
1033*4684ddb6SLionel Sambucstruct _BinaryOp<_Op, valarray<_Tp>, _A1>
1034*4684ddb6SLionel Sambuc{
1035*4684ddb6SLionel Sambuc    typedef typename _Op::result_type result_type;
1036*4684ddb6SLionel Sambuc    typedef _Tp value_type;
1037*4684ddb6SLionel Sambuc
1038*4684ddb6SLionel Sambuc    _Op __op_;
1039*4684ddb6SLionel Sambuc    const valarray<_Tp>& __a0_;
1040*4684ddb6SLionel Sambuc    _A1 __a1_;
1041*4684ddb6SLionel Sambuc
1042*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1043*4684ddb6SLionel Sambuc    _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1044*4684ddb6SLionel Sambuc        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1045*4684ddb6SLionel Sambuc
1046*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1047*4684ddb6SLionel Sambuc    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1048*4684ddb6SLionel Sambuc
1049*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1050*4684ddb6SLionel Sambuc    size_t size() const {return __a0_.size();}
1051*4684ddb6SLionel Sambuc};
1052*4684ddb6SLionel Sambuc
1053*4684ddb6SLionel Sambuctemplate <class _Op, class _A0, class _Tp>
1054*4684ddb6SLionel Sambucstruct _BinaryOp<_Op, _A0, valarray<_Tp> >
1055*4684ddb6SLionel Sambuc{
1056*4684ddb6SLionel Sambuc    typedef typename _Op::result_type result_type;
1057*4684ddb6SLionel Sambuc    typedef _Tp value_type;
1058*4684ddb6SLionel Sambuc
1059*4684ddb6SLionel Sambuc    _Op __op_;
1060*4684ddb6SLionel Sambuc    _A0 __a0_;
1061*4684ddb6SLionel Sambuc    const valarray<_Tp>& __a1_;
1062*4684ddb6SLionel Sambuc
1063*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1064*4684ddb6SLionel Sambuc    _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1065*4684ddb6SLionel Sambuc        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1066*4684ddb6SLionel Sambuc
1067*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1068*4684ddb6SLionel Sambuc    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1069*4684ddb6SLionel Sambuc
1070*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1071*4684ddb6SLionel Sambuc    size_t size() const {return __a0_.size();}
1072*4684ddb6SLionel Sambuc};
1073*4684ddb6SLionel Sambuc
1074*4684ddb6SLionel Sambuctemplate <class _Op, class _Tp>
1075*4684ddb6SLionel Sambucstruct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1076*4684ddb6SLionel Sambuc{
1077*4684ddb6SLionel Sambuc    typedef typename _Op::result_type result_type;
1078*4684ddb6SLionel Sambuc    typedef _Tp value_type;
1079*4684ddb6SLionel Sambuc
1080*4684ddb6SLionel Sambuc    _Op __op_;
1081*4684ddb6SLionel Sambuc    const valarray<_Tp>& __a0_;
1082*4684ddb6SLionel Sambuc    const valarray<_Tp>& __a1_;
1083*4684ddb6SLionel Sambuc
1084*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1085*4684ddb6SLionel Sambuc    _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1086*4684ddb6SLionel Sambuc        : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1087*4684ddb6SLionel Sambuc
1088*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1089*4684ddb6SLionel Sambuc    value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1090*4684ddb6SLionel Sambuc
1091*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1092*4684ddb6SLionel Sambuc    size_t size() const {return __a0_.size();}
1093*4684ddb6SLionel Sambuc};
1094*4684ddb6SLionel Sambuc
1095*4684ddb6SLionel Sambuc// slice_array
1096*4684ddb6SLionel Sambuc
1097*4684ddb6SLionel Sambuctemplate <class _Tp>
1098*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY slice_array
1099*4684ddb6SLionel Sambuc{
1100*4684ddb6SLionel Sambucpublic:
1101*4684ddb6SLionel Sambuc    typedef _Tp value_type;
1102*4684ddb6SLionel Sambuc
1103*4684ddb6SLionel Sambucprivate:
1104*4684ddb6SLionel Sambuc    value_type* __vp_;
1105*4684ddb6SLionel Sambuc    size_t __size_;
1106*4684ddb6SLionel Sambuc    size_t __stride_;
1107*4684ddb6SLionel Sambuc
1108*4684ddb6SLionel Sambucpublic:
1109*4684ddb6SLionel Sambuc    template <class _Expr>
1110*4684ddb6SLionel Sambuc    typename enable_if
1111*4684ddb6SLionel Sambuc    <
1112*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1113*4684ddb6SLionel Sambuc        void
1114*4684ddb6SLionel Sambuc    >::type
1115*4684ddb6SLionel Sambuc    operator=(const _Expr& __v) const;
1116*4684ddb6SLionel Sambuc
1117*4684ddb6SLionel Sambuc    template <class _Expr>
1118*4684ddb6SLionel Sambuc    typename enable_if
1119*4684ddb6SLionel Sambuc    <
1120*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1121*4684ddb6SLionel Sambuc        void
1122*4684ddb6SLionel Sambuc    >::type
1123*4684ddb6SLionel Sambuc    operator*=(const _Expr& __v) const;
1124*4684ddb6SLionel Sambuc
1125*4684ddb6SLionel Sambuc    template <class _Expr>
1126*4684ddb6SLionel Sambuc    typename enable_if
1127*4684ddb6SLionel Sambuc    <
1128*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1129*4684ddb6SLionel Sambuc        void
1130*4684ddb6SLionel Sambuc    >::type
1131*4684ddb6SLionel Sambuc    operator/=(const _Expr& __v) const;
1132*4684ddb6SLionel Sambuc
1133*4684ddb6SLionel Sambuc    template <class _Expr>
1134*4684ddb6SLionel Sambuc    typename enable_if
1135*4684ddb6SLionel Sambuc    <
1136*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1137*4684ddb6SLionel Sambuc        void
1138*4684ddb6SLionel Sambuc    >::type
1139*4684ddb6SLionel Sambuc    operator%=(const _Expr& __v) const;
1140*4684ddb6SLionel Sambuc
1141*4684ddb6SLionel Sambuc    template <class _Expr>
1142*4684ddb6SLionel Sambuc    typename enable_if
1143*4684ddb6SLionel Sambuc    <
1144*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1145*4684ddb6SLionel Sambuc        void
1146*4684ddb6SLionel Sambuc    >::type
1147*4684ddb6SLionel Sambuc    operator+=(const _Expr& __v) const;
1148*4684ddb6SLionel Sambuc
1149*4684ddb6SLionel Sambuc    template <class _Expr>
1150*4684ddb6SLionel Sambuc    typename enable_if
1151*4684ddb6SLionel Sambuc    <
1152*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1153*4684ddb6SLionel Sambuc        void
1154*4684ddb6SLionel Sambuc    >::type
1155*4684ddb6SLionel Sambuc    operator-=(const _Expr& __v) const;
1156*4684ddb6SLionel Sambuc
1157*4684ddb6SLionel Sambuc    template <class _Expr>
1158*4684ddb6SLionel Sambuc    typename enable_if
1159*4684ddb6SLionel Sambuc    <
1160*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1161*4684ddb6SLionel Sambuc        void
1162*4684ddb6SLionel Sambuc    >::type
1163*4684ddb6SLionel Sambuc    operator^=(const _Expr& __v) const;
1164*4684ddb6SLionel Sambuc
1165*4684ddb6SLionel Sambuc    template <class _Expr>
1166*4684ddb6SLionel Sambuc    typename enable_if
1167*4684ddb6SLionel Sambuc    <
1168*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1169*4684ddb6SLionel Sambuc        void
1170*4684ddb6SLionel Sambuc    >::type
1171*4684ddb6SLionel Sambuc    operator&=(const _Expr& __v) const;
1172*4684ddb6SLionel Sambuc
1173*4684ddb6SLionel Sambuc    template <class _Expr>
1174*4684ddb6SLionel Sambuc    typename enable_if
1175*4684ddb6SLionel Sambuc    <
1176*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1177*4684ddb6SLionel Sambuc        void
1178*4684ddb6SLionel Sambuc    >::type
1179*4684ddb6SLionel Sambuc    operator|=(const _Expr& __v) const;
1180*4684ddb6SLionel Sambuc
1181*4684ddb6SLionel Sambuc    template <class _Expr>
1182*4684ddb6SLionel Sambuc    typename enable_if
1183*4684ddb6SLionel Sambuc    <
1184*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1185*4684ddb6SLionel Sambuc        void
1186*4684ddb6SLionel Sambuc    >::type
1187*4684ddb6SLionel Sambuc    operator<<=(const _Expr& __v) const;
1188*4684ddb6SLionel Sambuc
1189*4684ddb6SLionel Sambuc    template <class _Expr>
1190*4684ddb6SLionel Sambuc    typename enable_if
1191*4684ddb6SLionel Sambuc    <
1192*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1193*4684ddb6SLionel Sambuc        void
1194*4684ddb6SLionel Sambuc    >::type
1195*4684ddb6SLionel Sambuc    operator>>=(const _Expr& __v) const;
1196*4684ddb6SLionel Sambuc
1197*4684ddb6SLionel Sambuc    const slice_array& operator=(const slice_array& __sa) const;
1198*4684ddb6SLionel Sambuc
1199*4684ddb6SLionel Sambuc    void operator=(const value_type& __x) const;
1200*4684ddb6SLionel Sambuc
1201*4684ddb6SLionel Sambucprivate:
1202*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1203*4684ddb6SLionel Sambuc    slice_array(const slice& __sl, const valarray<value_type>& __v)
1204*4684ddb6SLionel Sambuc        : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1205*4684ddb6SLionel Sambuc          __size_(__sl.size()),
1206*4684ddb6SLionel Sambuc          __stride_(__sl.stride())
1207*4684ddb6SLionel Sambuc        {}
1208*4684ddb6SLionel Sambuc
1209*4684ddb6SLionel Sambuc    template <class> friend class valarray;
1210*4684ddb6SLionel Sambuc    template <class> friend class sliceExpr;
1211*4684ddb6SLionel Sambuc};
1212*4684ddb6SLionel Sambuc
1213*4684ddb6SLionel Sambuctemplate <class _Tp>
1214*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1215*4684ddb6SLionel Sambucconst slice_array<_Tp>&
1216*4684ddb6SLionel Sambucslice_array<_Tp>::operator=(const slice_array& __sa) const
1217*4684ddb6SLionel Sambuc{
1218*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1219*4684ddb6SLionel Sambuc    const value_type* __s = __sa.__vp_;
1220*4684ddb6SLionel Sambuc    for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1221*4684ddb6SLionel Sambuc        *__t = *__s;
1222*4684ddb6SLionel Sambuc}
1223*4684ddb6SLionel Sambuc
1224*4684ddb6SLionel Sambuctemplate <class _Tp>
1225*4684ddb6SLionel Sambuctemplate <class _Expr>
1226*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1227*4684ddb6SLionel Sambuctypename enable_if
1228*4684ddb6SLionel Sambuc<
1229*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1230*4684ddb6SLionel Sambuc    void
1231*4684ddb6SLionel Sambuc>::type
1232*4684ddb6SLionel Sambucslice_array<_Tp>::operator=(const _Expr& __v) const
1233*4684ddb6SLionel Sambuc{
1234*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1235*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1236*4684ddb6SLionel Sambuc        *__t = __v[__i];
1237*4684ddb6SLionel Sambuc}
1238*4684ddb6SLionel Sambuc
1239*4684ddb6SLionel Sambuctemplate <class _Tp>
1240*4684ddb6SLionel Sambuctemplate <class _Expr>
1241*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1242*4684ddb6SLionel Sambuctypename enable_if
1243*4684ddb6SLionel Sambuc<
1244*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1245*4684ddb6SLionel Sambuc    void
1246*4684ddb6SLionel Sambuc>::type
1247*4684ddb6SLionel Sambucslice_array<_Tp>::operator*=(const _Expr& __v) const
1248*4684ddb6SLionel Sambuc{
1249*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1250*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1251*4684ddb6SLionel Sambuc        *__t *= __v[__i];
1252*4684ddb6SLionel Sambuc}
1253*4684ddb6SLionel Sambuc
1254*4684ddb6SLionel Sambuctemplate <class _Tp>
1255*4684ddb6SLionel Sambuctemplate <class _Expr>
1256*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1257*4684ddb6SLionel Sambuctypename enable_if
1258*4684ddb6SLionel Sambuc<
1259*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1260*4684ddb6SLionel Sambuc    void
1261*4684ddb6SLionel Sambuc>::type
1262*4684ddb6SLionel Sambucslice_array<_Tp>::operator/=(const _Expr& __v) const
1263*4684ddb6SLionel Sambuc{
1264*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1265*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1266*4684ddb6SLionel Sambuc        *__t /= __v[__i];
1267*4684ddb6SLionel Sambuc}
1268*4684ddb6SLionel Sambuc
1269*4684ddb6SLionel Sambuctemplate <class _Tp>
1270*4684ddb6SLionel Sambuctemplate <class _Expr>
1271*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1272*4684ddb6SLionel Sambuctypename enable_if
1273*4684ddb6SLionel Sambuc<
1274*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1275*4684ddb6SLionel Sambuc    void
1276*4684ddb6SLionel Sambuc>::type
1277*4684ddb6SLionel Sambucslice_array<_Tp>::operator%=(const _Expr& __v) const
1278*4684ddb6SLionel Sambuc{
1279*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1280*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1281*4684ddb6SLionel Sambuc        *__t %= __v[__i];
1282*4684ddb6SLionel Sambuc}
1283*4684ddb6SLionel Sambuc
1284*4684ddb6SLionel Sambuctemplate <class _Tp>
1285*4684ddb6SLionel Sambuctemplate <class _Expr>
1286*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1287*4684ddb6SLionel Sambuctypename enable_if
1288*4684ddb6SLionel Sambuc<
1289*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1290*4684ddb6SLionel Sambuc    void
1291*4684ddb6SLionel Sambuc>::type
1292*4684ddb6SLionel Sambucslice_array<_Tp>::operator+=(const _Expr& __v) const
1293*4684ddb6SLionel Sambuc{
1294*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1295*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1296*4684ddb6SLionel Sambuc        *__t += __v[__i];
1297*4684ddb6SLionel Sambuc}
1298*4684ddb6SLionel Sambuc
1299*4684ddb6SLionel Sambuctemplate <class _Tp>
1300*4684ddb6SLionel Sambuctemplate <class _Expr>
1301*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1302*4684ddb6SLionel Sambuctypename enable_if
1303*4684ddb6SLionel Sambuc<
1304*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1305*4684ddb6SLionel Sambuc    void
1306*4684ddb6SLionel Sambuc>::type
1307*4684ddb6SLionel Sambucslice_array<_Tp>::operator-=(const _Expr& __v) const
1308*4684ddb6SLionel Sambuc{
1309*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1310*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1311*4684ddb6SLionel Sambuc        *__t -= __v[__i];
1312*4684ddb6SLionel Sambuc}
1313*4684ddb6SLionel Sambuc
1314*4684ddb6SLionel Sambuctemplate <class _Tp>
1315*4684ddb6SLionel Sambuctemplate <class _Expr>
1316*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1317*4684ddb6SLionel Sambuctypename enable_if
1318*4684ddb6SLionel Sambuc<
1319*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1320*4684ddb6SLionel Sambuc    void
1321*4684ddb6SLionel Sambuc>::type
1322*4684ddb6SLionel Sambucslice_array<_Tp>::operator^=(const _Expr& __v) const
1323*4684ddb6SLionel Sambuc{
1324*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1325*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1326*4684ddb6SLionel Sambuc        *__t ^= __v[__i];
1327*4684ddb6SLionel Sambuc}
1328*4684ddb6SLionel Sambuc
1329*4684ddb6SLionel Sambuctemplate <class _Tp>
1330*4684ddb6SLionel Sambuctemplate <class _Expr>
1331*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1332*4684ddb6SLionel Sambuctypename enable_if
1333*4684ddb6SLionel Sambuc<
1334*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1335*4684ddb6SLionel Sambuc    void
1336*4684ddb6SLionel Sambuc>::type
1337*4684ddb6SLionel Sambucslice_array<_Tp>::operator&=(const _Expr& __v) const
1338*4684ddb6SLionel Sambuc{
1339*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1340*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1341*4684ddb6SLionel Sambuc        *__t &= __v[__i];
1342*4684ddb6SLionel Sambuc}
1343*4684ddb6SLionel Sambuc
1344*4684ddb6SLionel Sambuctemplate <class _Tp>
1345*4684ddb6SLionel Sambuctemplate <class _Expr>
1346*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1347*4684ddb6SLionel Sambuctypename enable_if
1348*4684ddb6SLionel Sambuc<
1349*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1350*4684ddb6SLionel Sambuc    void
1351*4684ddb6SLionel Sambuc>::type
1352*4684ddb6SLionel Sambucslice_array<_Tp>::operator|=(const _Expr& __v) const
1353*4684ddb6SLionel Sambuc{
1354*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1355*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1356*4684ddb6SLionel Sambuc        *__t |= __v[__i];
1357*4684ddb6SLionel Sambuc}
1358*4684ddb6SLionel Sambuc
1359*4684ddb6SLionel Sambuctemplate <class _Tp>
1360*4684ddb6SLionel Sambuctemplate <class _Expr>
1361*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1362*4684ddb6SLionel Sambuctypename enable_if
1363*4684ddb6SLionel Sambuc<
1364*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1365*4684ddb6SLionel Sambuc    void
1366*4684ddb6SLionel Sambuc>::type
1367*4684ddb6SLionel Sambucslice_array<_Tp>::operator<<=(const _Expr& __v) const
1368*4684ddb6SLionel Sambuc{
1369*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1370*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1371*4684ddb6SLionel Sambuc        *__t <<= __v[__i];
1372*4684ddb6SLionel Sambuc}
1373*4684ddb6SLionel Sambuc
1374*4684ddb6SLionel Sambuctemplate <class _Tp>
1375*4684ddb6SLionel Sambuctemplate <class _Expr>
1376*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1377*4684ddb6SLionel Sambuctypename enable_if
1378*4684ddb6SLionel Sambuc<
1379*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1380*4684ddb6SLionel Sambuc    void
1381*4684ddb6SLionel Sambuc>::type
1382*4684ddb6SLionel Sambucslice_array<_Tp>::operator>>=(const _Expr& __v) const
1383*4684ddb6SLionel Sambuc{
1384*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1385*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1386*4684ddb6SLionel Sambuc        *__t >>= __v[__i];
1387*4684ddb6SLionel Sambuc}
1388*4684ddb6SLionel Sambuc
1389*4684ddb6SLionel Sambuctemplate <class _Tp>
1390*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1391*4684ddb6SLionel Sambucvoid
1392*4684ddb6SLionel Sambucslice_array<_Tp>::operator=(const value_type& __x) const
1393*4684ddb6SLionel Sambuc{
1394*4684ddb6SLionel Sambuc    value_type* __t = __vp_;
1395*4684ddb6SLionel Sambuc    for (size_t __n = __size_; __n; --__n, __t += __stride_)
1396*4684ddb6SLionel Sambuc        *__t = __x;
1397*4684ddb6SLionel Sambuc}
1398*4684ddb6SLionel Sambuc
1399*4684ddb6SLionel Sambuc// gslice
1400*4684ddb6SLionel Sambuc
1401*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS gslice
1402*4684ddb6SLionel Sambuc{
1403*4684ddb6SLionel Sambuc    valarray<size_t> __size_;
1404*4684ddb6SLionel Sambuc    valarray<size_t> __stride_;
1405*4684ddb6SLionel Sambuc    valarray<size_t> __1d_;
1406*4684ddb6SLionel Sambuc
1407*4684ddb6SLionel Sambucpublic:
1408*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1409*4684ddb6SLionel Sambuc    gslice() {}
1410*4684ddb6SLionel Sambuc
1411*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1412*4684ddb6SLionel Sambuc    gslice(size_t __start, const valarray<size_t>& __size,
1413*4684ddb6SLionel Sambuc                           const valarray<size_t>& __stride)
1414*4684ddb6SLionel Sambuc        : __size_(__size),
1415*4684ddb6SLionel Sambuc          __stride_(__stride)
1416*4684ddb6SLionel Sambuc        {__init(__start);}
1417*4684ddb6SLionel Sambuc
1418*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1419*4684ddb6SLionel Sambuc
1420*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1421*4684ddb6SLionel Sambuc    gslice(size_t __start, const valarray<size_t>&  __size,
1422*4684ddb6SLionel Sambuc                                 valarray<size_t>&& __stride)
1423*4684ddb6SLionel Sambuc        : __size_(__size),
1424*4684ddb6SLionel Sambuc          __stride_(move(__stride))
1425*4684ddb6SLionel Sambuc        {__init(__start);}
1426*4684ddb6SLionel Sambuc
1427*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1428*4684ddb6SLionel Sambuc    gslice(size_t __start,       valarray<size_t>&& __size,
1429*4684ddb6SLionel Sambuc                           const valarray<size_t>&  __stride)
1430*4684ddb6SLionel Sambuc        : __size_(move(__size)),
1431*4684ddb6SLionel Sambuc          __stride_(__stride)
1432*4684ddb6SLionel Sambuc        {__init(__start);}
1433*4684ddb6SLionel Sambuc
1434*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1435*4684ddb6SLionel Sambuc    gslice(size_t __start,       valarray<size_t>&& __size,
1436*4684ddb6SLionel Sambuc                                 valarray<size_t>&& __stride)
1437*4684ddb6SLionel Sambuc        : __size_(move(__size)),
1438*4684ddb6SLionel Sambuc          __stride_(move(__stride))
1439*4684ddb6SLionel Sambuc        {__init(__start);}
1440*4684ddb6SLionel Sambuc
1441*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1442*4684ddb6SLionel Sambuc
1443*4684ddb6SLionel Sambuc//  gslice(const gslice&)            = default;
1444*4684ddb6SLionel Sambuc//  gslice(gslice&&)                 = default;
1445*4684ddb6SLionel Sambuc//  gslice& operator=(const gslice&) = default;
1446*4684ddb6SLionel Sambuc//  gslice& operator=(gslice&&)      = default;
1447*4684ddb6SLionel Sambuc
1448*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1449*4684ddb6SLionel Sambuc    size_t           start()  const {return __1d_.size() ? __1d_[0] : 0;}
1450*4684ddb6SLionel Sambuc
1451*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1452*4684ddb6SLionel Sambuc    valarray<size_t> size()   const {return __size_;}
1453*4684ddb6SLionel Sambuc
1454*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1455*4684ddb6SLionel Sambuc    valarray<size_t> stride() const {return __stride_;}
1456*4684ddb6SLionel Sambuc
1457*4684ddb6SLionel Sambucprivate:
1458*4684ddb6SLionel Sambuc    void __init(size_t __start);
1459*4684ddb6SLionel Sambuc
1460*4684ddb6SLionel Sambuc    template <class> friend class gslice_array;
1461*4684ddb6SLionel Sambuc    template <class> friend class valarray;
1462*4684ddb6SLionel Sambuc    template <class> friend class __val_expr;
1463*4684ddb6SLionel Sambuc};
1464*4684ddb6SLionel Sambuc
1465*4684ddb6SLionel Sambuc// gslice_array
1466*4684ddb6SLionel Sambuc
1467*4684ddb6SLionel Sambuctemplate <class _Tp>
1468*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY gslice_array
1469*4684ddb6SLionel Sambuc{
1470*4684ddb6SLionel Sambucpublic:
1471*4684ddb6SLionel Sambuc    typedef _Tp value_type;
1472*4684ddb6SLionel Sambuc
1473*4684ddb6SLionel Sambucprivate:
1474*4684ddb6SLionel Sambuc    value_type*      __vp_;
1475*4684ddb6SLionel Sambuc    valarray<size_t> __1d_;
1476*4684ddb6SLionel Sambuc
1477*4684ddb6SLionel Sambucpublic:
1478*4684ddb6SLionel Sambuc    template <class _Expr>
1479*4684ddb6SLionel Sambuc    typename enable_if
1480*4684ddb6SLionel Sambuc    <
1481*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1482*4684ddb6SLionel Sambuc        void
1483*4684ddb6SLionel Sambuc    >::type
1484*4684ddb6SLionel Sambuc    operator=(const _Expr& __v) const;
1485*4684ddb6SLionel Sambuc
1486*4684ddb6SLionel Sambuc    template <class _Expr>
1487*4684ddb6SLionel Sambuc    typename enable_if
1488*4684ddb6SLionel Sambuc    <
1489*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1490*4684ddb6SLionel Sambuc        void
1491*4684ddb6SLionel Sambuc    >::type
1492*4684ddb6SLionel Sambuc    operator*=(const _Expr& __v) const;
1493*4684ddb6SLionel Sambuc
1494*4684ddb6SLionel Sambuc    template <class _Expr>
1495*4684ddb6SLionel Sambuc    typename enable_if
1496*4684ddb6SLionel Sambuc    <
1497*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1498*4684ddb6SLionel Sambuc        void
1499*4684ddb6SLionel Sambuc    >::type
1500*4684ddb6SLionel Sambuc    operator/=(const _Expr& __v) const;
1501*4684ddb6SLionel Sambuc
1502*4684ddb6SLionel Sambuc    template <class _Expr>
1503*4684ddb6SLionel Sambuc    typename enable_if
1504*4684ddb6SLionel Sambuc    <
1505*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1506*4684ddb6SLionel Sambuc        void
1507*4684ddb6SLionel Sambuc    >::type
1508*4684ddb6SLionel Sambuc    operator%=(const _Expr& __v) const;
1509*4684ddb6SLionel Sambuc
1510*4684ddb6SLionel Sambuc    template <class _Expr>
1511*4684ddb6SLionel Sambuc    typename enable_if
1512*4684ddb6SLionel Sambuc    <
1513*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1514*4684ddb6SLionel Sambuc        void
1515*4684ddb6SLionel Sambuc    >::type
1516*4684ddb6SLionel Sambuc    operator+=(const _Expr& __v) const;
1517*4684ddb6SLionel Sambuc
1518*4684ddb6SLionel Sambuc    template <class _Expr>
1519*4684ddb6SLionel Sambuc    typename enable_if
1520*4684ddb6SLionel Sambuc    <
1521*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1522*4684ddb6SLionel Sambuc        void
1523*4684ddb6SLionel Sambuc    >::type
1524*4684ddb6SLionel Sambuc    operator-=(const _Expr& __v) const;
1525*4684ddb6SLionel Sambuc
1526*4684ddb6SLionel Sambuc    template <class _Expr>
1527*4684ddb6SLionel Sambuc    typename enable_if
1528*4684ddb6SLionel Sambuc    <
1529*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1530*4684ddb6SLionel Sambuc        void
1531*4684ddb6SLionel Sambuc    >::type
1532*4684ddb6SLionel Sambuc    operator^=(const _Expr& __v) const;
1533*4684ddb6SLionel Sambuc
1534*4684ddb6SLionel Sambuc    template <class _Expr>
1535*4684ddb6SLionel Sambuc    typename enable_if
1536*4684ddb6SLionel Sambuc    <
1537*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1538*4684ddb6SLionel Sambuc        void
1539*4684ddb6SLionel Sambuc    >::type
1540*4684ddb6SLionel Sambuc    operator&=(const _Expr& __v) const;
1541*4684ddb6SLionel Sambuc
1542*4684ddb6SLionel Sambuc    template <class _Expr>
1543*4684ddb6SLionel Sambuc    typename enable_if
1544*4684ddb6SLionel Sambuc    <
1545*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1546*4684ddb6SLionel Sambuc        void
1547*4684ddb6SLionel Sambuc    >::type
1548*4684ddb6SLionel Sambuc    operator|=(const _Expr& __v) const;
1549*4684ddb6SLionel Sambuc
1550*4684ddb6SLionel Sambuc    template <class _Expr>
1551*4684ddb6SLionel Sambuc    typename enable_if
1552*4684ddb6SLionel Sambuc    <
1553*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1554*4684ddb6SLionel Sambuc        void
1555*4684ddb6SLionel Sambuc    >::type
1556*4684ddb6SLionel Sambuc    operator<<=(const _Expr& __v) const;
1557*4684ddb6SLionel Sambuc
1558*4684ddb6SLionel Sambuc    template <class _Expr>
1559*4684ddb6SLionel Sambuc    typename enable_if
1560*4684ddb6SLionel Sambuc    <
1561*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1562*4684ddb6SLionel Sambuc        void
1563*4684ddb6SLionel Sambuc    >::type
1564*4684ddb6SLionel Sambuc    operator>>=(const _Expr& __v) const;
1565*4684ddb6SLionel Sambuc
1566*4684ddb6SLionel Sambuc    const gslice_array& operator=(const gslice_array& __ga) const;
1567*4684ddb6SLionel Sambuc
1568*4684ddb6SLionel Sambuc    void operator=(const value_type& __x) const;
1569*4684ddb6SLionel Sambuc
1570*4684ddb6SLionel Sambuc//  gslice_array(const gslice_array&)            = default;
1571*4684ddb6SLionel Sambuc//  gslice_array(gslice_array&&)                 = default;
1572*4684ddb6SLionel Sambuc//  gslice_array& operator=(const gslice_array&) = default;
1573*4684ddb6SLionel Sambuc//  gslice_array& operator=(gslice_array&&)      = default;
1574*4684ddb6SLionel Sambuc
1575*4684ddb6SLionel Sambucprivate:
1576*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1577*4684ddb6SLionel Sambuc    gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1578*4684ddb6SLionel Sambuc        : __vp_(const_cast<value_type*>(__v.__begin_)),
1579*4684ddb6SLionel Sambuc          __1d_(__gs.__1d_)
1580*4684ddb6SLionel Sambuc        {}
1581*4684ddb6SLionel Sambuc
1582*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1583*4684ddb6SLionel Sambuc
1584*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1585*4684ddb6SLionel Sambuc    gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1586*4684ddb6SLionel Sambuc        : __vp_(const_cast<value_type*>(__v.__begin_)),
1587*4684ddb6SLionel Sambuc          __1d_(move(__gs.__1d_))
1588*4684ddb6SLionel Sambuc        {}
1589*4684ddb6SLionel Sambuc
1590*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1591*4684ddb6SLionel Sambuc
1592*4684ddb6SLionel Sambuc    template <class> friend class valarray;
1593*4684ddb6SLionel Sambuc};
1594*4684ddb6SLionel Sambuc
1595*4684ddb6SLionel Sambuctemplate <class _Tp>
1596*4684ddb6SLionel Sambuctemplate <class _Expr>
1597*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1598*4684ddb6SLionel Sambuctypename enable_if
1599*4684ddb6SLionel Sambuc<
1600*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1601*4684ddb6SLionel Sambuc    void
1602*4684ddb6SLionel Sambuc>::type
1603*4684ddb6SLionel Sambucgslice_array<_Tp>::operator=(const _Expr& __v) const
1604*4684ddb6SLionel Sambuc{
1605*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1606*4684ddb6SLionel Sambuc    size_t __j = 0;
1607*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1608*4684ddb6SLionel Sambuc        __vp_[*__i] = __v[__j];
1609*4684ddb6SLionel Sambuc}
1610*4684ddb6SLionel Sambuc
1611*4684ddb6SLionel Sambuctemplate <class _Tp>
1612*4684ddb6SLionel Sambuctemplate <class _Expr>
1613*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1614*4684ddb6SLionel Sambuctypename enable_if
1615*4684ddb6SLionel Sambuc<
1616*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1617*4684ddb6SLionel Sambuc    void
1618*4684ddb6SLionel Sambuc>::type
1619*4684ddb6SLionel Sambucgslice_array<_Tp>::operator*=(const _Expr& __v) const
1620*4684ddb6SLionel Sambuc{
1621*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1622*4684ddb6SLionel Sambuc    size_t __j = 0;
1623*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1624*4684ddb6SLionel Sambuc        __vp_[*__i] *= __v[__j];
1625*4684ddb6SLionel Sambuc}
1626*4684ddb6SLionel Sambuc
1627*4684ddb6SLionel Sambuctemplate <class _Tp>
1628*4684ddb6SLionel Sambuctemplate <class _Expr>
1629*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1630*4684ddb6SLionel Sambuctypename enable_if
1631*4684ddb6SLionel Sambuc<
1632*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1633*4684ddb6SLionel Sambuc    void
1634*4684ddb6SLionel Sambuc>::type
1635*4684ddb6SLionel Sambucgslice_array<_Tp>::operator/=(const _Expr& __v) const
1636*4684ddb6SLionel Sambuc{
1637*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1638*4684ddb6SLionel Sambuc    size_t __j = 0;
1639*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1640*4684ddb6SLionel Sambuc        __vp_[*__i] /= __v[__j];
1641*4684ddb6SLionel Sambuc}
1642*4684ddb6SLionel Sambuc
1643*4684ddb6SLionel Sambuctemplate <class _Tp>
1644*4684ddb6SLionel Sambuctemplate <class _Expr>
1645*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1646*4684ddb6SLionel Sambuctypename enable_if
1647*4684ddb6SLionel Sambuc<
1648*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1649*4684ddb6SLionel Sambuc    void
1650*4684ddb6SLionel Sambuc>::type
1651*4684ddb6SLionel Sambucgslice_array<_Tp>::operator%=(const _Expr& __v) const
1652*4684ddb6SLionel Sambuc{
1653*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1654*4684ddb6SLionel Sambuc    size_t __j = 0;
1655*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1656*4684ddb6SLionel Sambuc        __vp_[*__i] %= __v[__j];
1657*4684ddb6SLionel Sambuc}
1658*4684ddb6SLionel Sambuc
1659*4684ddb6SLionel Sambuctemplate <class _Tp>
1660*4684ddb6SLionel Sambuctemplate <class _Expr>
1661*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1662*4684ddb6SLionel Sambuctypename enable_if
1663*4684ddb6SLionel Sambuc<
1664*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1665*4684ddb6SLionel Sambuc    void
1666*4684ddb6SLionel Sambuc>::type
1667*4684ddb6SLionel Sambucgslice_array<_Tp>::operator+=(const _Expr& __v) const
1668*4684ddb6SLionel Sambuc{
1669*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1670*4684ddb6SLionel Sambuc    size_t __j = 0;
1671*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1672*4684ddb6SLionel Sambuc        __vp_[*__i] += __v[__j];
1673*4684ddb6SLionel Sambuc}
1674*4684ddb6SLionel Sambuc
1675*4684ddb6SLionel Sambuctemplate <class _Tp>
1676*4684ddb6SLionel Sambuctemplate <class _Expr>
1677*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1678*4684ddb6SLionel Sambuctypename enable_if
1679*4684ddb6SLionel Sambuc<
1680*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1681*4684ddb6SLionel Sambuc    void
1682*4684ddb6SLionel Sambuc>::type
1683*4684ddb6SLionel Sambucgslice_array<_Tp>::operator-=(const _Expr& __v) const
1684*4684ddb6SLionel Sambuc{
1685*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1686*4684ddb6SLionel Sambuc    size_t __j = 0;
1687*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1688*4684ddb6SLionel Sambuc        __vp_[*__i] -= __v[__j];
1689*4684ddb6SLionel Sambuc}
1690*4684ddb6SLionel Sambuc
1691*4684ddb6SLionel Sambuctemplate <class _Tp>
1692*4684ddb6SLionel Sambuctemplate <class _Expr>
1693*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1694*4684ddb6SLionel Sambuctypename enable_if
1695*4684ddb6SLionel Sambuc<
1696*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1697*4684ddb6SLionel Sambuc    void
1698*4684ddb6SLionel Sambuc>::type
1699*4684ddb6SLionel Sambucgslice_array<_Tp>::operator^=(const _Expr& __v) const
1700*4684ddb6SLionel Sambuc{
1701*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1702*4684ddb6SLionel Sambuc    size_t __j = 0;
1703*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1704*4684ddb6SLionel Sambuc        __vp_[*__i] ^= __v[__j];
1705*4684ddb6SLionel Sambuc}
1706*4684ddb6SLionel Sambuc
1707*4684ddb6SLionel Sambuctemplate <class _Tp>
1708*4684ddb6SLionel Sambuctemplate <class _Expr>
1709*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1710*4684ddb6SLionel Sambuctypename enable_if
1711*4684ddb6SLionel Sambuc<
1712*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1713*4684ddb6SLionel Sambuc    void
1714*4684ddb6SLionel Sambuc>::type
1715*4684ddb6SLionel Sambucgslice_array<_Tp>::operator&=(const _Expr& __v) const
1716*4684ddb6SLionel Sambuc{
1717*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1718*4684ddb6SLionel Sambuc    size_t __j = 0;
1719*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1720*4684ddb6SLionel Sambuc        __vp_[*__i] &= __v[__j];
1721*4684ddb6SLionel Sambuc}
1722*4684ddb6SLionel Sambuc
1723*4684ddb6SLionel Sambuctemplate <class _Tp>
1724*4684ddb6SLionel Sambuctemplate <class _Expr>
1725*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1726*4684ddb6SLionel Sambuctypename enable_if
1727*4684ddb6SLionel Sambuc<
1728*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1729*4684ddb6SLionel Sambuc    void
1730*4684ddb6SLionel Sambuc>::type
1731*4684ddb6SLionel Sambucgslice_array<_Tp>::operator|=(const _Expr& __v) const
1732*4684ddb6SLionel Sambuc{
1733*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1734*4684ddb6SLionel Sambuc    size_t __j = 0;
1735*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1736*4684ddb6SLionel Sambuc        __vp_[*__i] |= __v[__j];
1737*4684ddb6SLionel Sambuc}
1738*4684ddb6SLionel Sambuc
1739*4684ddb6SLionel Sambuctemplate <class _Tp>
1740*4684ddb6SLionel Sambuctemplate <class _Expr>
1741*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1742*4684ddb6SLionel Sambuctypename enable_if
1743*4684ddb6SLionel Sambuc<
1744*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1745*4684ddb6SLionel Sambuc    void
1746*4684ddb6SLionel Sambuc>::type
1747*4684ddb6SLionel Sambucgslice_array<_Tp>::operator<<=(const _Expr& __v) const
1748*4684ddb6SLionel Sambuc{
1749*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1750*4684ddb6SLionel Sambuc    size_t __j = 0;
1751*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1752*4684ddb6SLionel Sambuc        __vp_[*__i] <<= __v[__j];
1753*4684ddb6SLionel Sambuc}
1754*4684ddb6SLionel Sambuc
1755*4684ddb6SLionel Sambuctemplate <class _Tp>
1756*4684ddb6SLionel Sambuctemplate <class _Expr>
1757*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1758*4684ddb6SLionel Sambuctypename enable_if
1759*4684ddb6SLionel Sambuc<
1760*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1761*4684ddb6SLionel Sambuc    void
1762*4684ddb6SLionel Sambuc>::type
1763*4684ddb6SLionel Sambucgslice_array<_Tp>::operator>>=(const _Expr& __v) const
1764*4684ddb6SLionel Sambuc{
1765*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1766*4684ddb6SLionel Sambuc    size_t __j = 0;
1767*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1768*4684ddb6SLionel Sambuc        __vp_[*__i] >>= __v[__j];
1769*4684ddb6SLionel Sambuc}
1770*4684ddb6SLionel Sambuc
1771*4684ddb6SLionel Sambuctemplate <class _Tp>
1772*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1773*4684ddb6SLionel Sambucconst gslice_array<_Tp>&
1774*4684ddb6SLionel Sambucgslice_array<_Tp>::operator=(const gslice_array& __ga) const
1775*4684ddb6SLionel Sambuc{
1776*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1777*4684ddb6SLionel Sambuc    const value_type* __s = __ga.__vp_;
1778*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1779*4684ddb6SLionel Sambuc            __i != __e; ++__i, ++__j)
1780*4684ddb6SLionel Sambuc        __vp_[*__i] = __s[*__j];
1781*4684ddb6SLionel Sambuc    return *this;
1782*4684ddb6SLionel Sambuc}
1783*4684ddb6SLionel Sambuc
1784*4684ddb6SLionel Sambuctemplate <class _Tp>
1785*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1786*4684ddb6SLionel Sambucvoid
1787*4684ddb6SLionel Sambucgslice_array<_Tp>::operator=(const value_type& __x) const
1788*4684ddb6SLionel Sambuc{
1789*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
1790*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1791*4684ddb6SLionel Sambuc        __vp_[*__i] = __x;
1792*4684ddb6SLionel Sambuc}
1793*4684ddb6SLionel Sambuc
1794*4684ddb6SLionel Sambuc// mask_array
1795*4684ddb6SLionel Sambuc
1796*4684ddb6SLionel Sambuctemplate <class _Tp>
1797*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY mask_array
1798*4684ddb6SLionel Sambuc{
1799*4684ddb6SLionel Sambucpublic:
1800*4684ddb6SLionel Sambuc    typedef _Tp value_type;
1801*4684ddb6SLionel Sambuc
1802*4684ddb6SLionel Sambucprivate:
1803*4684ddb6SLionel Sambuc    value_type*      __vp_;
1804*4684ddb6SLionel Sambuc    valarray<size_t> __1d_;
1805*4684ddb6SLionel Sambuc
1806*4684ddb6SLionel Sambucpublic:
1807*4684ddb6SLionel Sambuc    template <class _Expr>
1808*4684ddb6SLionel Sambuc    typename enable_if
1809*4684ddb6SLionel Sambuc    <
1810*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1811*4684ddb6SLionel Sambuc        void
1812*4684ddb6SLionel Sambuc    >::type
1813*4684ddb6SLionel Sambuc    operator=(const _Expr& __v) const;
1814*4684ddb6SLionel Sambuc
1815*4684ddb6SLionel Sambuc    template <class _Expr>
1816*4684ddb6SLionel Sambuc    typename enable_if
1817*4684ddb6SLionel Sambuc    <
1818*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1819*4684ddb6SLionel Sambuc        void
1820*4684ddb6SLionel Sambuc    >::type
1821*4684ddb6SLionel Sambuc    operator*=(const _Expr& __v) const;
1822*4684ddb6SLionel Sambuc
1823*4684ddb6SLionel Sambuc    template <class _Expr>
1824*4684ddb6SLionel Sambuc    typename enable_if
1825*4684ddb6SLionel Sambuc    <
1826*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1827*4684ddb6SLionel Sambuc        void
1828*4684ddb6SLionel Sambuc    >::type
1829*4684ddb6SLionel Sambuc    operator/=(const _Expr& __v) const;
1830*4684ddb6SLionel Sambuc
1831*4684ddb6SLionel Sambuc    template <class _Expr>
1832*4684ddb6SLionel Sambuc    typename enable_if
1833*4684ddb6SLionel Sambuc    <
1834*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1835*4684ddb6SLionel Sambuc        void
1836*4684ddb6SLionel Sambuc    >::type
1837*4684ddb6SLionel Sambuc    operator%=(const _Expr& __v) const;
1838*4684ddb6SLionel Sambuc
1839*4684ddb6SLionel Sambuc    template <class _Expr>
1840*4684ddb6SLionel Sambuc    typename enable_if
1841*4684ddb6SLionel Sambuc    <
1842*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1843*4684ddb6SLionel Sambuc        void
1844*4684ddb6SLionel Sambuc    >::type
1845*4684ddb6SLionel Sambuc    operator+=(const _Expr& __v) const;
1846*4684ddb6SLionel Sambuc
1847*4684ddb6SLionel Sambuc    template <class _Expr>
1848*4684ddb6SLionel Sambuc    typename enable_if
1849*4684ddb6SLionel Sambuc    <
1850*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1851*4684ddb6SLionel Sambuc        void
1852*4684ddb6SLionel Sambuc    >::type
1853*4684ddb6SLionel Sambuc    operator-=(const _Expr& __v) const;
1854*4684ddb6SLionel Sambuc
1855*4684ddb6SLionel Sambuc    template <class _Expr>
1856*4684ddb6SLionel Sambuc    typename enable_if
1857*4684ddb6SLionel Sambuc    <
1858*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1859*4684ddb6SLionel Sambuc        void
1860*4684ddb6SLionel Sambuc    >::type
1861*4684ddb6SLionel Sambuc    operator^=(const _Expr& __v) const;
1862*4684ddb6SLionel Sambuc
1863*4684ddb6SLionel Sambuc    template <class _Expr>
1864*4684ddb6SLionel Sambuc    typename enable_if
1865*4684ddb6SLionel Sambuc    <
1866*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1867*4684ddb6SLionel Sambuc        void
1868*4684ddb6SLionel Sambuc    >::type
1869*4684ddb6SLionel Sambuc    operator&=(const _Expr& __v) const;
1870*4684ddb6SLionel Sambuc
1871*4684ddb6SLionel Sambuc    template <class _Expr>
1872*4684ddb6SLionel Sambuc    typename enable_if
1873*4684ddb6SLionel Sambuc    <
1874*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1875*4684ddb6SLionel Sambuc        void
1876*4684ddb6SLionel Sambuc    >::type
1877*4684ddb6SLionel Sambuc    operator|=(const _Expr& __v) const;
1878*4684ddb6SLionel Sambuc
1879*4684ddb6SLionel Sambuc    template <class _Expr>
1880*4684ddb6SLionel Sambuc    typename enable_if
1881*4684ddb6SLionel Sambuc    <
1882*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1883*4684ddb6SLionel Sambuc        void
1884*4684ddb6SLionel Sambuc    >::type
1885*4684ddb6SLionel Sambuc    operator<<=(const _Expr& __v) const;
1886*4684ddb6SLionel Sambuc
1887*4684ddb6SLionel Sambuc    template <class _Expr>
1888*4684ddb6SLionel Sambuc    typename enable_if
1889*4684ddb6SLionel Sambuc    <
1890*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
1891*4684ddb6SLionel Sambuc        void
1892*4684ddb6SLionel Sambuc    >::type
1893*4684ddb6SLionel Sambuc    operator>>=(const _Expr& __v) const;
1894*4684ddb6SLionel Sambuc
1895*4684ddb6SLionel Sambuc    const mask_array& operator=(const mask_array& __ma) const;
1896*4684ddb6SLionel Sambuc
1897*4684ddb6SLionel Sambuc    void operator=(const value_type& __x) const;
1898*4684ddb6SLionel Sambuc
1899*4684ddb6SLionel Sambuc//  mask_array(const mask_array&)            = default;
1900*4684ddb6SLionel Sambuc//  mask_array(mask_array&&)                 = default;
1901*4684ddb6SLionel Sambuc//  mask_array& operator=(const mask_array&) = default;
1902*4684ddb6SLionel Sambuc//  mask_array& operator=(mask_array&&)      = default;
1903*4684ddb6SLionel Sambuc
1904*4684ddb6SLionel Sambucprivate:
1905*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
1906*4684ddb6SLionel Sambuc    mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1907*4684ddb6SLionel Sambuc        : __vp_(const_cast<value_type*>(__v.__begin_)),
1908*4684ddb6SLionel Sambuc          __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1909*4684ddb6SLionel Sambuc          {
1910*4684ddb6SLionel Sambuc              size_t __j = 0;
1911*4684ddb6SLionel Sambuc              for (size_t __i = 0; __i < __vb.size(); ++__i)
1912*4684ddb6SLionel Sambuc                  if (__vb[__i])
1913*4684ddb6SLionel Sambuc                      __1d_[__j++] = __i;
1914*4684ddb6SLionel Sambuc          }
1915*4684ddb6SLionel Sambuc
1916*4684ddb6SLionel Sambuc    template <class> friend class valarray;
1917*4684ddb6SLionel Sambuc};
1918*4684ddb6SLionel Sambuc
1919*4684ddb6SLionel Sambuctemplate <class _Tp>
1920*4684ddb6SLionel Sambuctemplate <class _Expr>
1921*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1922*4684ddb6SLionel Sambuctypename enable_if
1923*4684ddb6SLionel Sambuc<
1924*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1925*4684ddb6SLionel Sambuc    void
1926*4684ddb6SLionel Sambuc>::type
1927*4684ddb6SLionel Sambucmask_array<_Tp>::operator=(const _Expr& __v) const
1928*4684ddb6SLionel Sambuc{
1929*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
1930*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
1931*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] = __v[__i];
1932*4684ddb6SLionel Sambuc}
1933*4684ddb6SLionel Sambuc
1934*4684ddb6SLionel Sambuctemplate <class _Tp>
1935*4684ddb6SLionel Sambuctemplate <class _Expr>
1936*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1937*4684ddb6SLionel Sambuctypename enable_if
1938*4684ddb6SLionel Sambuc<
1939*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1940*4684ddb6SLionel Sambuc    void
1941*4684ddb6SLionel Sambuc>::type
1942*4684ddb6SLionel Sambucmask_array<_Tp>::operator*=(const _Expr& __v) const
1943*4684ddb6SLionel Sambuc{
1944*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
1945*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
1946*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] *= __v[__i];
1947*4684ddb6SLionel Sambuc}
1948*4684ddb6SLionel Sambuc
1949*4684ddb6SLionel Sambuctemplate <class _Tp>
1950*4684ddb6SLionel Sambuctemplate <class _Expr>
1951*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1952*4684ddb6SLionel Sambuctypename enable_if
1953*4684ddb6SLionel Sambuc<
1954*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1955*4684ddb6SLionel Sambuc    void
1956*4684ddb6SLionel Sambuc>::type
1957*4684ddb6SLionel Sambucmask_array<_Tp>::operator/=(const _Expr& __v) const
1958*4684ddb6SLionel Sambuc{
1959*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
1960*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
1961*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] /= __v[__i];
1962*4684ddb6SLionel Sambuc}
1963*4684ddb6SLionel Sambuc
1964*4684ddb6SLionel Sambuctemplate <class _Tp>
1965*4684ddb6SLionel Sambuctemplate <class _Expr>
1966*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1967*4684ddb6SLionel Sambuctypename enable_if
1968*4684ddb6SLionel Sambuc<
1969*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1970*4684ddb6SLionel Sambuc    void
1971*4684ddb6SLionel Sambuc>::type
1972*4684ddb6SLionel Sambucmask_array<_Tp>::operator%=(const _Expr& __v) const
1973*4684ddb6SLionel Sambuc{
1974*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
1975*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
1976*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] %= __v[__i];
1977*4684ddb6SLionel Sambuc}
1978*4684ddb6SLionel Sambuc
1979*4684ddb6SLionel Sambuctemplate <class _Tp>
1980*4684ddb6SLionel Sambuctemplate <class _Expr>
1981*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1982*4684ddb6SLionel Sambuctypename enable_if
1983*4684ddb6SLionel Sambuc<
1984*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
1985*4684ddb6SLionel Sambuc    void
1986*4684ddb6SLionel Sambuc>::type
1987*4684ddb6SLionel Sambucmask_array<_Tp>::operator+=(const _Expr& __v) const
1988*4684ddb6SLionel Sambuc{
1989*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
1990*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
1991*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] += __v[__i];
1992*4684ddb6SLionel Sambuc}
1993*4684ddb6SLionel Sambuc
1994*4684ddb6SLionel Sambuctemplate <class _Tp>
1995*4684ddb6SLionel Sambuctemplate <class _Expr>
1996*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
1997*4684ddb6SLionel Sambuctypename enable_if
1998*4684ddb6SLionel Sambuc<
1999*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2000*4684ddb6SLionel Sambuc    void
2001*4684ddb6SLionel Sambuc>::type
2002*4684ddb6SLionel Sambucmask_array<_Tp>::operator-=(const _Expr& __v) const
2003*4684ddb6SLionel Sambuc{
2004*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2005*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2006*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] -= __v[__i];
2007*4684ddb6SLionel Sambuc}
2008*4684ddb6SLionel Sambuc
2009*4684ddb6SLionel Sambuctemplate <class _Tp>
2010*4684ddb6SLionel Sambuctemplate <class _Expr>
2011*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2012*4684ddb6SLionel Sambuctypename enable_if
2013*4684ddb6SLionel Sambuc<
2014*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2015*4684ddb6SLionel Sambuc    void
2016*4684ddb6SLionel Sambuc>::type
2017*4684ddb6SLionel Sambucmask_array<_Tp>::operator^=(const _Expr& __v) const
2018*4684ddb6SLionel Sambuc{
2019*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2020*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2021*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] ^= __v[__i];
2022*4684ddb6SLionel Sambuc}
2023*4684ddb6SLionel Sambuc
2024*4684ddb6SLionel Sambuctemplate <class _Tp>
2025*4684ddb6SLionel Sambuctemplate <class _Expr>
2026*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2027*4684ddb6SLionel Sambuctypename enable_if
2028*4684ddb6SLionel Sambuc<
2029*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2030*4684ddb6SLionel Sambuc    void
2031*4684ddb6SLionel Sambuc>::type
2032*4684ddb6SLionel Sambucmask_array<_Tp>::operator&=(const _Expr& __v) const
2033*4684ddb6SLionel Sambuc{
2034*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2035*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2036*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] &= __v[__i];
2037*4684ddb6SLionel Sambuc}
2038*4684ddb6SLionel Sambuc
2039*4684ddb6SLionel Sambuctemplate <class _Tp>
2040*4684ddb6SLionel Sambuctemplate <class _Expr>
2041*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2042*4684ddb6SLionel Sambuctypename enable_if
2043*4684ddb6SLionel Sambuc<
2044*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2045*4684ddb6SLionel Sambuc    void
2046*4684ddb6SLionel Sambuc>::type
2047*4684ddb6SLionel Sambucmask_array<_Tp>::operator|=(const _Expr& __v) const
2048*4684ddb6SLionel Sambuc{
2049*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2050*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2051*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] |= __v[__i];
2052*4684ddb6SLionel Sambuc}
2053*4684ddb6SLionel Sambuc
2054*4684ddb6SLionel Sambuctemplate <class _Tp>
2055*4684ddb6SLionel Sambuctemplate <class _Expr>
2056*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2057*4684ddb6SLionel Sambuctypename enable_if
2058*4684ddb6SLionel Sambuc<
2059*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2060*4684ddb6SLionel Sambuc    void
2061*4684ddb6SLionel Sambuc>::type
2062*4684ddb6SLionel Sambucmask_array<_Tp>::operator<<=(const _Expr& __v) const
2063*4684ddb6SLionel Sambuc{
2064*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2065*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2066*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] <<= __v[__i];
2067*4684ddb6SLionel Sambuc}
2068*4684ddb6SLionel Sambuc
2069*4684ddb6SLionel Sambuctemplate <class _Tp>
2070*4684ddb6SLionel Sambuctemplate <class _Expr>
2071*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2072*4684ddb6SLionel Sambuctypename enable_if
2073*4684ddb6SLionel Sambuc<
2074*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2075*4684ddb6SLionel Sambuc    void
2076*4684ddb6SLionel Sambuc>::type
2077*4684ddb6SLionel Sambucmask_array<_Tp>::operator>>=(const _Expr& __v) const
2078*4684ddb6SLionel Sambuc{
2079*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2080*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2081*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] >>= __v[__i];
2082*4684ddb6SLionel Sambuc}
2083*4684ddb6SLionel Sambuc
2084*4684ddb6SLionel Sambuctemplate <class _Tp>
2085*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2086*4684ddb6SLionel Sambucconst mask_array<_Tp>&
2087*4684ddb6SLionel Sambucmask_array<_Tp>::operator=(const mask_array& __ma) const
2088*4684ddb6SLionel Sambuc{
2089*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2090*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2091*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
2092*4684ddb6SLionel Sambuc}
2093*4684ddb6SLionel Sambuc
2094*4684ddb6SLionel Sambuctemplate <class _Tp>
2095*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2096*4684ddb6SLionel Sambucvoid
2097*4684ddb6SLionel Sambucmask_array<_Tp>::operator=(const value_type& __x) const
2098*4684ddb6SLionel Sambuc{
2099*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2100*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2101*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] = __x;
2102*4684ddb6SLionel Sambuc}
2103*4684ddb6SLionel Sambuc
2104*4684ddb6SLionel Sambuctemplate <class _ValExpr>
2105*4684ddb6SLionel Sambucclass __mask_expr
2106*4684ddb6SLionel Sambuc{
2107*4684ddb6SLionel Sambuc    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
2108*4684ddb6SLionel Sambucpublic:
2109*4684ddb6SLionel Sambuc    typedef typename _RmExpr::value_type value_type;
2110*4684ddb6SLionel Sambuc    typedef value_type result_type;
2111*4684ddb6SLionel Sambuc
2112*4684ddb6SLionel Sambucprivate:
2113*4684ddb6SLionel Sambuc    _ValExpr __expr_;
2114*4684ddb6SLionel Sambuc    valarray<size_t> __1d_;
2115*4684ddb6SLionel Sambuc
2116*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2117*4684ddb6SLionel Sambuc    __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2118*4684ddb6SLionel Sambuc        : __expr_(__e),
2119*4684ddb6SLionel Sambuc          __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2120*4684ddb6SLionel Sambuc          {
2121*4684ddb6SLionel Sambuc              size_t __j = 0;
2122*4684ddb6SLionel Sambuc              for (size_t __i = 0; __i < __vb.size(); ++__i)
2123*4684ddb6SLionel Sambuc                  if (__vb[__i])
2124*4684ddb6SLionel Sambuc                      __1d_[__j++] = __i;
2125*4684ddb6SLionel Sambuc          }
2126*4684ddb6SLionel Sambuc
2127*4684ddb6SLionel Sambucpublic:
2128*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2129*4684ddb6SLionel Sambuc    result_type operator[](size_t __i) const
2130*4684ddb6SLionel Sambuc        {return __expr_[__1d_[__i]];}
2131*4684ddb6SLionel Sambuc
2132*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2133*4684ddb6SLionel Sambuc    size_t size() const {return __1d_.size();}
2134*4684ddb6SLionel Sambuc
2135*4684ddb6SLionel Sambuc    template <class> friend class valarray;
2136*4684ddb6SLionel Sambuc};
2137*4684ddb6SLionel Sambuc
2138*4684ddb6SLionel Sambuc// indirect_array
2139*4684ddb6SLionel Sambuc
2140*4684ddb6SLionel Sambuctemplate <class _Tp>
2141*4684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY indirect_array
2142*4684ddb6SLionel Sambuc{
2143*4684ddb6SLionel Sambucpublic:
2144*4684ddb6SLionel Sambuc    typedef _Tp value_type;
2145*4684ddb6SLionel Sambuc
2146*4684ddb6SLionel Sambucprivate:
2147*4684ddb6SLionel Sambuc    value_type*      __vp_;
2148*4684ddb6SLionel Sambuc    valarray<size_t> __1d_;
2149*4684ddb6SLionel Sambuc
2150*4684ddb6SLionel Sambucpublic:
2151*4684ddb6SLionel Sambuc    template <class _Expr>
2152*4684ddb6SLionel Sambuc    typename enable_if
2153*4684ddb6SLionel Sambuc    <
2154*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2155*4684ddb6SLionel Sambuc        void
2156*4684ddb6SLionel Sambuc    >::type
2157*4684ddb6SLionel Sambuc    operator=(const _Expr& __v) const;
2158*4684ddb6SLionel Sambuc
2159*4684ddb6SLionel Sambuc    template <class _Expr>
2160*4684ddb6SLionel Sambuc    typename enable_if
2161*4684ddb6SLionel Sambuc    <
2162*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2163*4684ddb6SLionel Sambuc        void
2164*4684ddb6SLionel Sambuc    >::type
2165*4684ddb6SLionel Sambuc    operator*=(const _Expr& __v) const;
2166*4684ddb6SLionel Sambuc
2167*4684ddb6SLionel Sambuc    template <class _Expr>
2168*4684ddb6SLionel Sambuc    typename enable_if
2169*4684ddb6SLionel Sambuc    <
2170*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2171*4684ddb6SLionel Sambuc        void
2172*4684ddb6SLionel Sambuc    >::type
2173*4684ddb6SLionel Sambuc    operator/=(const _Expr& __v) const;
2174*4684ddb6SLionel Sambuc
2175*4684ddb6SLionel Sambuc    template <class _Expr>
2176*4684ddb6SLionel Sambuc    typename enable_if
2177*4684ddb6SLionel Sambuc    <
2178*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2179*4684ddb6SLionel Sambuc        void
2180*4684ddb6SLionel Sambuc    >::type
2181*4684ddb6SLionel Sambuc    operator%=(const _Expr& __v) const;
2182*4684ddb6SLionel Sambuc
2183*4684ddb6SLionel Sambuc    template <class _Expr>
2184*4684ddb6SLionel Sambuc    typename enable_if
2185*4684ddb6SLionel Sambuc    <
2186*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2187*4684ddb6SLionel Sambuc        void
2188*4684ddb6SLionel Sambuc    >::type
2189*4684ddb6SLionel Sambuc    operator+=(const _Expr& __v) const;
2190*4684ddb6SLionel Sambuc
2191*4684ddb6SLionel Sambuc    template <class _Expr>
2192*4684ddb6SLionel Sambuc    typename enable_if
2193*4684ddb6SLionel Sambuc    <
2194*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2195*4684ddb6SLionel Sambuc        void
2196*4684ddb6SLionel Sambuc    >::type
2197*4684ddb6SLionel Sambuc    operator-=(const _Expr& __v) const;
2198*4684ddb6SLionel Sambuc
2199*4684ddb6SLionel Sambuc    template <class _Expr>
2200*4684ddb6SLionel Sambuc    typename enable_if
2201*4684ddb6SLionel Sambuc    <
2202*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2203*4684ddb6SLionel Sambuc        void
2204*4684ddb6SLionel Sambuc    >::type
2205*4684ddb6SLionel Sambuc    operator^=(const _Expr& __v) const;
2206*4684ddb6SLionel Sambuc
2207*4684ddb6SLionel Sambuc    template <class _Expr>
2208*4684ddb6SLionel Sambuc    typename enable_if
2209*4684ddb6SLionel Sambuc    <
2210*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2211*4684ddb6SLionel Sambuc        void
2212*4684ddb6SLionel Sambuc    >::type
2213*4684ddb6SLionel Sambuc    operator&=(const _Expr& __v) const;
2214*4684ddb6SLionel Sambuc
2215*4684ddb6SLionel Sambuc    template <class _Expr>
2216*4684ddb6SLionel Sambuc    typename enable_if
2217*4684ddb6SLionel Sambuc    <
2218*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2219*4684ddb6SLionel Sambuc        void
2220*4684ddb6SLionel Sambuc    >::type
2221*4684ddb6SLionel Sambuc    operator|=(const _Expr& __v) const;
2222*4684ddb6SLionel Sambuc
2223*4684ddb6SLionel Sambuc    template <class _Expr>
2224*4684ddb6SLionel Sambuc    typename enable_if
2225*4684ddb6SLionel Sambuc    <
2226*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2227*4684ddb6SLionel Sambuc        void
2228*4684ddb6SLionel Sambuc    >::type
2229*4684ddb6SLionel Sambuc    operator<<=(const _Expr& __v) const;
2230*4684ddb6SLionel Sambuc
2231*4684ddb6SLionel Sambuc    template <class _Expr>
2232*4684ddb6SLionel Sambuc    typename enable_if
2233*4684ddb6SLionel Sambuc    <
2234*4684ddb6SLionel Sambuc        __is_val_expr<_Expr>::value,
2235*4684ddb6SLionel Sambuc        void
2236*4684ddb6SLionel Sambuc    >::type
2237*4684ddb6SLionel Sambuc    operator>>=(const _Expr& __v) const;
2238*4684ddb6SLionel Sambuc
2239*4684ddb6SLionel Sambuc    const indirect_array& operator=(const indirect_array& __ia) const;
2240*4684ddb6SLionel Sambuc
2241*4684ddb6SLionel Sambuc    void operator=(const value_type& __x) const;
2242*4684ddb6SLionel Sambuc
2243*4684ddb6SLionel Sambuc//  indirect_array(const indirect_array&)            = default;
2244*4684ddb6SLionel Sambuc//  indirect_array(indirect_array&&)                 = default;
2245*4684ddb6SLionel Sambuc//  indirect_array& operator=(const indirect_array&) = default;
2246*4684ddb6SLionel Sambuc//  indirect_array& operator=(indirect_array&&)      = default;
2247*4684ddb6SLionel Sambuc
2248*4684ddb6SLionel Sambucprivate:
2249*4684ddb6SLionel Sambuc     _LIBCPP_INLINE_VISIBILITY
2250*4684ddb6SLionel Sambuc   indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2251*4684ddb6SLionel Sambuc        : __vp_(const_cast<value_type*>(__v.__begin_)),
2252*4684ddb6SLionel Sambuc          __1d_(__ia)
2253*4684ddb6SLionel Sambuc        {}
2254*4684ddb6SLionel Sambuc
2255*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2256*4684ddb6SLionel Sambuc
2257*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2258*4684ddb6SLionel Sambuc    indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2259*4684ddb6SLionel Sambuc        : __vp_(const_cast<value_type*>(__v.__begin_)),
2260*4684ddb6SLionel Sambuc          __1d_(move(__ia))
2261*4684ddb6SLionel Sambuc        {}
2262*4684ddb6SLionel Sambuc
2263*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2264*4684ddb6SLionel Sambuc
2265*4684ddb6SLionel Sambuc    template <class> friend class valarray;
2266*4684ddb6SLionel Sambuc};
2267*4684ddb6SLionel Sambuc
2268*4684ddb6SLionel Sambuctemplate <class _Tp>
2269*4684ddb6SLionel Sambuctemplate <class _Expr>
2270*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2271*4684ddb6SLionel Sambuctypename enable_if
2272*4684ddb6SLionel Sambuc<
2273*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2274*4684ddb6SLionel Sambuc    void
2275*4684ddb6SLionel Sambuc>::type
2276*4684ddb6SLionel Sambucindirect_array<_Tp>::operator=(const _Expr& __v) const
2277*4684ddb6SLionel Sambuc{
2278*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2279*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2280*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] = __v[__i];
2281*4684ddb6SLionel Sambuc}
2282*4684ddb6SLionel Sambuc
2283*4684ddb6SLionel Sambuctemplate <class _Tp>
2284*4684ddb6SLionel Sambuctemplate <class _Expr>
2285*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2286*4684ddb6SLionel Sambuctypename enable_if
2287*4684ddb6SLionel Sambuc<
2288*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2289*4684ddb6SLionel Sambuc    void
2290*4684ddb6SLionel Sambuc>::type
2291*4684ddb6SLionel Sambucindirect_array<_Tp>::operator*=(const _Expr& __v) const
2292*4684ddb6SLionel Sambuc{
2293*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2294*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2295*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] *= __v[__i];
2296*4684ddb6SLionel Sambuc}
2297*4684ddb6SLionel Sambuc
2298*4684ddb6SLionel Sambuctemplate <class _Tp>
2299*4684ddb6SLionel Sambuctemplate <class _Expr>
2300*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2301*4684ddb6SLionel Sambuctypename enable_if
2302*4684ddb6SLionel Sambuc<
2303*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2304*4684ddb6SLionel Sambuc    void
2305*4684ddb6SLionel Sambuc>::type
2306*4684ddb6SLionel Sambucindirect_array<_Tp>::operator/=(const _Expr& __v) const
2307*4684ddb6SLionel Sambuc{
2308*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2309*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2310*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] /= __v[__i];
2311*4684ddb6SLionel Sambuc}
2312*4684ddb6SLionel Sambuc
2313*4684ddb6SLionel Sambuctemplate <class _Tp>
2314*4684ddb6SLionel Sambuctemplate <class _Expr>
2315*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2316*4684ddb6SLionel Sambuctypename enable_if
2317*4684ddb6SLionel Sambuc<
2318*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2319*4684ddb6SLionel Sambuc    void
2320*4684ddb6SLionel Sambuc>::type
2321*4684ddb6SLionel Sambucindirect_array<_Tp>::operator%=(const _Expr& __v) const
2322*4684ddb6SLionel Sambuc{
2323*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2324*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2325*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] %= __v[__i];
2326*4684ddb6SLionel Sambuc}
2327*4684ddb6SLionel Sambuc
2328*4684ddb6SLionel Sambuctemplate <class _Tp>
2329*4684ddb6SLionel Sambuctemplate <class _Expr>
2330*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2331*4684ddb6SLionel Sambuctypename enable_if
2332*4684ddb6SLionel Sambuc<
2333*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2334*4684ddb6SLionel Sambuc    void
2335*4684ddb6SLionel Sambuc>::type
2336*4684ddb6SLionel Sambucindirect_array<_Tp>::operator+=(const _Expr& __v) const
2337*4684ddb6SLionel Sambuc{
2338*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2339*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2340*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] += __v[__i];
2341*4684ddb6SLionel Sambuc}
2342*4684ddb6SLionel Sambuc
2343*4684ddb6SLionel Sambuctemplate <class _Tp>
2344*4684ddb6SLionel Sambuctemplate <class _Expr>
2345*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2346*4684ddb6SLionel Sambuctypename enable_if
2347*4684ddb6SLionel Sambuc<
2348*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2349*4684ddb6SLionel Sambuc    void
2350*4684ddb6SLionel Sambuc>::type
2351*4684ddb6SLionel Sambucindirect_array<_Tp>::operator-=(const _Expr& __v) const
2352*4684ddb6SLionel Sambuc{
2353*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2354*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2355*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] -= __v[__i];
2356*4684ddb6SLionel Sambuc}
2357*4684ddb6SLionel Sambuc
2358*4684ddb6SLionel Sambuctemplate <class _Tp>
2359*4684ddb6SLionel Sambuctemplate <class _Expr>
2360*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2361*4684ddb6SLionel Sambuctypename enable_if
2362*4684ddb6SLionel Sambuc<
2363*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2364*4684ddb6SLionel Sambuc    void
2365*4684ddb6SLionel Sambuc>::type
2366*4684ddb6SLionel Sambucindirect_array<_Tp>::operator^=(const _Expr& __v) const
2367*4684ddb6SLionel Sambuc{
2368*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2369*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2370*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] ^= __v[__i];
2371*4684ddb6SLionel Sambuc}
2372*4684ddb6SLionel Sambuc
2373*4684ddb6SLionel Sambuctemplate <class _Tp>
2374*4684ddb6SLionel Sambuctemplate <class _Expr>
2375*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2376*4684ddb6SLionel Sambuctypename enable_if
2377*4684ddb6SLionel Sambuc<
2378*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2379*4684ddb6SLionel Sambuc    void
2380*4684ddb6SLionel Sambuc>::type
2381*4684ddb6SLionel Sambucindirect_array<_Tp>::operator&=(const _Expr& __v) const
2382*4684ddb6SLionel Sambuc{
2383*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2384*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2385*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] &= __v[__i];
2386*4684ddb6SLionel Sambuc}
2387*4684ddb6SLionel Sambuc
2388*4684ddb6SLionel Sambuctemplate <class _Tp>
2389*4684ddb6SLionel Sambuctemplate <class _Expr>
2390*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2391*4684ddb6SLionel Sambuctypename enable_if
2392*4684ddb6SLionel Sambuc<
2393*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2394*4684ddb6SLionel Sambuc    void
2395*4684ddb6SLionel Sambuc>::type
2396*4684ddb6SLionel Sambucindirect_array<_Tp>::operator|=(const _Expr& __v) const
2397*4684ddb6SLionel Sambuc{
2398*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2399*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2400*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] |= __v[__i];
2401*4684ddb6SLionel Sambuc}
2402*4684ddb6SLionel Sambuc
2403*4684ddb6SLionel Sambuctemplate <class _Tp>
2404*4684ddb6SLionel Sambuctemplate <class _Expr>
2405*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2406*4684ddb6SLionel Sambuctypename enable_if
2407*4684ddb6SLionel Sambuc<
2408*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2409*4684ddb6SLionel Sambuc    void
2410*4684ddb6SLionel Sambuc>::type
2411*4684ddb6SLionel Sambucindirect_array<_Tp>::operator<<=(const _Expr& __v) const
2412*4684ddb6SLionel Sambuc{
2413*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2414*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2415*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] <<= __v[__i];
2416*4684ddb6SLionel Sambuc}
2417*4684ddb6SLionel Sambuc
2418*4684ddb6SLionel Sambuctemplate <class _Tp>
2419*4684ddb6SLionel Sambuctemplate <class _Expr>
2420*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2421*4684ddb6SLionel Sambuctypename enable_if
2422*4684ddb6SLionel Sambuc<
2423*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
2424*4684ddb6SLionel Sambuc    void
2425*4684ddb6SLionel Sambuc>::type
2426*4684ddb6SLionel Sambucindirect_array<_Tp>::operator>>=(const _Expr& __v) const
2427*4684ddb6SLionel Sambuc{
2428*4684ddb6SLionel Sambuc    size_t __n = __1d_.size();
2429*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i < __n; ++__i)
2430*4684ddb6SLionel Sambuc        __vp_[__1d_[__i]] >>= __v[__i];
2431*4684ddb6SLionel Sambuc}
2432*4684ddb6SLionel Sambuc
2433*4684ddb6SLionel Sambuctemplate <class _Tp>
2434*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2435*4684ddb6SLionel Sambucconst indirect_array<_Tp>&
2436*4684ddb6SLionel Sambucindirect_array<_Tp>::operator=(const indirect_array& __ia) const
2437*4684ddb6SLionel Sambuc{
2438*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
2439*4684ddb6SLionel Sambuc    const value_type* __s = __ia.__vp_;
2440*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2441*4684ddb6SLionel Sambuc            __i != __e; ++__i, ++__j)
2442*4684ddb6SLionel Sambuc        __vp_[*__i] = __s[*__j];
2443*4684ddb6SLionel Sambuc    return *this;
2444*4684ddb6SLionel Sambuc}
2445*4684ddb6SLionel Sambuc
2446*4684ddb6SLionel Sambuctemplate <class _Tp>
2447*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2448*4684ddb6SLionel Sambucvoid
2449*4684ddb6SLionel Sambucindirect_array<_Tp>::operator=(const value_type& __x) const
2450*4684ddb6SLionel Sambuc{
2451*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
2452*4684ddb6SLionel Sambuc    for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2453*4684ddb6SLionel Sambuc        __vp_[*__i] = __x;
2454*4684ddb6SLionel Sambuc}
2455*4684ddb6SLionel Sambuc
2456*4684ddb6SLionel Sambuctemplate <class _ValExpr>
2457*4684ddb6SLionel Sambucclass __indirect_expr
2458*4684ddb6SLionel Sambuc{
2459*4684ddb6SLionel Sambuc    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
2460*4684ddb6SLionel Sambucpublic:
2461*4684ddb6SLionel Sambuc    typedef typename _RmExpr::value_type value_type;
2462*4684ddb6SLionel Sambuc    typedef value_type result_type;
2463*4684ddb6SLionel Sambuc
2464*4684ddb6SLionel Sambucprivate:
2465*4684ddb6SLionel Sambuc    _ValExpr __expr_;
2466*4684ddb6SLionel Sambuc    valarray<size_t> __1d_;
2467*4684ddb6SLionel Sambuc
2468*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2469*4684ddb6SLionel Sambuc    __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2470*4684ddb6SLionel Sambuc        : __expr_(__e),
2471*4684ddb6SLionel Sambuc          __1d_(__ia)
2472*4684ddb6SLionel Sambuc          {}
2473*4684ddb6SLionel Sambuc
2474*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2475*4684ddb6SLionel Sambuc
2476*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2477*4684ddb6SLionel Sambuc    __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2478*4684ddb6SLionel Sambuc        : __expr_(__e),
2479*4684ddb6SLionel Sambuc          __1d_(move(__ia))
2480*4684ddb6SLionel Sambuc          {}
2481*4684ddb6SLionel Sambuc
2482*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2483*4684ddb6SLionel Sambuc
2484*4684ddb6SLionel Sambucpublic:
2485*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2486*4684ddb6SLionel Sambuc    result_type operator[](size_t __i) const
2487*4684ddb6SLionel Sambuc        {return __expr_[__1d_[__i]];}
2488*4684ddb6SLionel Sambuc
2489*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2490*4684ddb6SLionel Sambuc    size_t size() const {return __1d_.size();}
2491*4684ddb6SLionel Sambuc
2492*4684ddb6SLionel Sambuc    template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
2493*4684ddb6SLionel Sambuc};
2494*4684ddb6SLionel Sambuc
2495*4684ddb6SLionel Sambuctemplate<class _ValExpr>
2496*4684ddb6SLionel Sambucclass __val_expr
2497*4684ddb6SLionel Sambuc{
2498*4684ddb6SLionel Sambuc    typedef typename remove_reference<_ValExpr>::type  _RmExpr;
2499*4684ddb6SLionel Sambuc
2500*4684ddb6SLionel Sambuc    _ValExpr __expr_;
2501*4684ddb6SLionel Sambucpublic:
2502*4684ddb6SLionel Sambuc    typedef typename _RmExpr::value_type value_type;
2503*4684ddb6SLionel Sambuc    typedef typename _RmExpr::result_type result_type;
2504*4684ddb6SLionel Sambuc
2505*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2506*4684ddb6SLionel Sambuc    explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2507*4684ddb6SLionel Sambuc
2508*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2509*4684ddb6SLionel Sambuc    result_type operator[](size_t __i) const
2510*4684ddb6SLionel Sambuc        {return __expr_[__i];}
2511*4684ddb6SLionel Sambuc
2512*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2513*4684ddb6SLionel Sambuc    __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2514*4684ddb6SLionel Sambuc        {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2515*4684ddb6SLionel Sambuc
2516*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2517*4684ddb6SLionel Sambuc    __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2518*4684ddb6SLionel Sambuc        {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2519*4684ddb6SLionel Sambuc
2520*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2521*4684ddb6SLionel Sambuc    __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2522*4684ddb6SLionel Sambuc        {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2523*4684ddb6SLionel Sambuc
2524*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2525*4684ddb6SLionel Sambuc    __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2526*4684ddb6SLionel Sambuc        {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2527*4684ddb6SLionel Sambuc
2528*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2529*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2530*4684ddb6SLionel Sambuc    operator+() const
2531*4684ddb6SLionel Sambuc    {
2532*4684ddb6SLionel Sambuc        typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2533*4684ddb6SLionel Sambuc        return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2534*4684ddb6SLionel Sambuc    }
2535*4684ddb6SLionel Sambuc
2536*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2537*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2538*4684ddb6SLionel Sambuc    operator-() const
2539*4684ddb6SLionel Sambuc    {
2540*4684ddb6SLionel Sambuc        typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2541*4684ddb6SLionel Sambuc        return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2542*4684ddb6SLionel Sambuc    }
2543*4684ddb6SLionel Sambuc
2544*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2545*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2546*4684ddb6SLionel Sambuc    operator~() const
2547*4684ddb6SLionel Sambuc    {
2548*4684ddb6SLionel Sambuc        typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2549*4684ddb6SLionel Sambuc        return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2550*4684ddb6SLionel Sambuc    }
2551*4684ddb6SLionel Sambuc
2552*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2553*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2554*4684ddb6SLionel Sambuc    operator!() const
2555*4684ddb6SLionel Sambuc    {
2556*4684ddb6SLionel Sambuc        typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2557*4684ddb6SLionel Sambuc        return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2558*4684ddb6SLionel Sambuc    }
2559*4684ddb6SLionel Sambuc
2560*4684ddb6SLionel Sambuc    operator valarray<result_type>() const;
2561*4684ddb6SLionel Sambuc
2562*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2563*4684ddb6SLionel Sambuc    size_t size() const {return __expr_.size();}
2564*4684ddb6SLionel Sambuc
2565*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2566*4684ddb6SLionel Sambuc    result_type sum() const
2567*4684ddb6SLionel Sambuc    {
2568*4684ddb6SLionel Sambuc        size_t __n = __expr_.size();
2569*4684ddb6SLionel Sambuc        result_type __r = __n ? __expr_[0] : result_type();
2570*4684ddb6SLionel Sambuc        for (size_t __i = 1; __i < __n; ++__i)
2571*4684ddb6SLionel Sambuc            __r += __expr_[__i];
2572*4684ddb6SLionel Sambuc        return __r;
2573*4684ddb6SLionel Sambuc    }
2574*4684ddb6SLionel Sambuc
2575*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2576*4684ddb6SLionel Sambuc    result_type min() const
2577*4684ddb6SLionel Sambuc    {
2578*4684ddb6SLionel Sambuc        size_t __n = size();
2579*4684ddb6SLionel Sambuc        result_type __r = __n ? (*this)[0] : result_type();
2580*4684ddb6SLionel Sambuc        for (size_t __i = 1; __i < __n; ++__i)
2581*4684ddb6SLionel Sambuc        {
2582*4684ddb6SLionel Sambuc            result_type __x = __expr_[__i];
2583*4684ddb6SLionel Sambuc            if (__x < __r)
2584*4684ddb6SLionel Sambuc                __r = __x;
2585*4684ddb6SLionel Sambuc        }
2586*4684ddb6SLionel Sambuc        return __r;
2587*4684ddb6SLionel Sambuc    }
2588*4684ddb6SLionel Sambuc
2589*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2590*4684ddb6SLionel Sambuc    result_type max() const
2591*4684ddb6SLionel Sambuc    {
2592*4684ddb6SLionel Sambuc        size_t __n = size();
2593*4684ddb6SLionel Sambuc        result_type __r = __n ? (*this)[0] : result_type();
2594*4684ddb6SLionel Sambuc        for (size_t __i = 1; __i < __n; ++__i)
2595*4684ddb6SLionel Sambuc        {
2596*4684ddb6SLionel Sambuc            result_type __x = __expr_[__i];
2597*4684ddb6SLionel Sambuc            if (__r < __x)
2598*4684ddb6SLionel Sambuc                __r = __x;
2599*4684ddb6SLionel Sambuc        }
2600*4684ddb6SLionel Sambuc        return __r;
2601*4684ddb6SLionel Sambuc    }
2602*4684ddb6SLionel Sambuc
2603*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2604*4684ddb6SLionel Sambuc    __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2605*4684ddb6SLionel Sambuc        {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2606*4684ddb6SLionel Sambuc
2607*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2608*4684ddb6SLionel Sambuc    __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2609*4684ddb6SLionel Sambuc        {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2610*4684ddb6SLionel Sambuc
2611*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2612*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2613*4684ddb6SLionel Sambuc    apply(value_type __f(value_type)) const
2614*4684ddb6SLionel Sambuc    {
2615*4684ddb6SLionel Sambuc        typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2616*4684ddb6SLionel Sambuc        typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2617*4684ddb6SLionel Sambuc        return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2618*4684ddb6SLionel Sambuc    }
2619*4684ddb6SLionel Sambuc
2620*4684ddb6SLionel Sambuc    _LIBCPP_INLINE_VISIBILITY
2621*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2622*4684ddb6SLionel Sambuc    apply(value_type __f(const value_type&)) const
2623*4684ddb6SLionel Sambuc    {
2624*4684ddb6SLionel Sambuc        typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2625*4684ddb6SLionel Sambuc        typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2626*4684ddb6SLionel Sambuc        return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2627*4684ddb6SLionel Sambuc    }
2628*4684ddb6SLionel Sambuc};
2629*4684ddb6SLionel Sambuc
2630*4684ddb6SLionel Sambuctemplate<class _ValExpr>
2631*4684ddb6SLionel Sambuc__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
2632*4684ddb6SLionel Sambuc{
2633*4684ddb6SLionel Sambuc    valarray<result_type> __r;
2634*4684ddb6SLionel Sambuc    size_t __n = __expr_.size();
2635*4684ddb6SLionel Sambuc    if (__n)
2636*4684ddb6SLionel Sambuc    {
2637*4684ddb6SLionel Sambuc        __r.__begin_ =
2638*4684ddb6SLionel Sambuc            __r.__end_ =
2639*4684ddb6SLionel Sambuc                static_cast<result_type*>(::operator new(__n * sizeof(result_type)));
2640*4684ddb6SLionel Sambuc        for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2641*4684ddb6SLionel Sambuc            ::new (__r.__end_) result_type(__expr_[__i]);
2642*4684ddb6SLionel Sambuc    }
2643*4684ddb6SLionel Sambuc    return __r;
2644*4684ddb6SLionel Sambuc}
2645*4684ddb6SLionel Sambuc
2646*4684ddb6SLionel Sambuc// valarray
2647*4684ddb6SLionel Sambuc
2648*4684ddb6SLionel Sambuctemplate <class _Tp>
2649*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2650*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(size_t __n)
2651*4684ddb6SLionel Sambuc    : __begin_(0),
2652*4684ddb6SLionel Sambuc      __end_(0)
2653*4684ddb6SLionel Sambuc{
2654*4684ddb6SLionel Sambuc    resize(__n);
2655*4684ddb6SLionel Sambuc}
2656*4684ddb6SLionel Sambuc
2657*4684ddb6SLionel Sambuctemplate <class _Tp>
2658*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2659*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(const value_type& __x, size_t __n)
2660*4684ddb6SLionel Sambuc    : __begin_(0),
2661*4684ddb6SLionel Sambuc      __end_(0)
2662*4684ddb6SLionel Sambuc{
2663*4684ddb6SLionel Sambuc    resize(__n, __x);
2664*4684ddb6SLionel Sambuc}
2665*4684ddb6SLionel Sambuc
2666*4684ddb6SLionel Sambuctemplate <class _Tp>
2667*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(const value_type* __p, size_t __n)
2668*4684ddb6SLionel Sambuc    : __begin_(0),
2669*4684ddb6SLionel Sambuc      __end_(0)
2670*4684ddb6SLionel Sambuc{
2671*4684ddb6SLionel Sambuc    if (__n)
2672*4684ddb6SLionel Sambuc    {
2673*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2674*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2675*4684ddb6SLionel Sambuc        try
2676*4684ddb6SLionel Sambuc        {
2677*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2678*4684ddb6SLionel Sambuc            for (; __n; ++__end_, ++__p, --__n)
2679*4684ddb6SLionel Sambuc                ::new (__end_) value_type(*__p);
2680*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2681*4684ddb6SLionel Sambuc        }
2682*4684ddb6SLionel Sambuc        catch (...)
2683*4684ddb6SLionel Sambuc        {
2684*4684ddb6SLionel Sambuc            resize(0);
2685*4684ddb6SLionel Sambuc            throw;
2686*4684ddb6SLionel Sambuc        }
2687*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2688*4684ddb6SLionel Sambuc    }
2689*4684ddb6SLionel Sambuc}
2690*4684ddb6SLionel Sambuc
2691*4684ddb6SLionel Sambuctemplate <class _Tp>
2692*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(const valarray& __v)
2693*4684ddb6SLionel Sambuc    : __begin_(0),
2694*4684ddb6SLionel Sambuc      __end_(0)
2695*4684ddb6SLionel Sambuc{
2696*4684ddb6SLionel Sambuc    if (__v.size())
2697*4684ddb6SLionel Sambuc    {
2698*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__v.size() * sizeof(value_type)));
2699*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2700*4684ddb6SLionel Sambuc        try
2701*4684ddb6SLionel Sambuc        {
2702*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2703*4684ddb6SLionel Sambuc            for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2704*4684ddb6SLionel Sambuc                ::new (__end_) value_type(*__p);
2705*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2706*4684ddb6SLionel Sambuc        }
2707*4684ddb6SLionel Sambuc        catch (...)
2708*4684ddb6SLionel Sambuc        {
2709*4684ddb6SLionel Sambuc            resize(0);
2710*4684ddb6SLionel Sambuc            throw;
2711*4684ddb6SLionel Sambuc        }
2712*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2713*4684ddb6SLionel Sambuc    }
2714*4684ddb6SLionel Sambuc}
2715*4684ddb6SLionel Sambuc
2716*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2717*4684ddb6SLionel Sambuc
2718*4684ddb6SLionel Sambuctemplate <class _Tp>
2719*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2720*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2721*4684ddb6SLionel Sambuc    : __begin_(__v.__begin_),
2722*4684ddb6SLionel Sambuc      __end_(__v.__end_)
2723*4684ddb6SLionel Sambuc{
2724*4684ddb6SLionel Sambuc    __v.__begin_ = __v.__end_ = nullptr;
2725*4684ddb6SLionel Sambuc}
2726*4684ddb6SLionel Sambuc
2727*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2728*4684ddb6SLionel Sambuc
2729*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2730*4684ddb6SLionel Sambuc
2731*4684ddb6SLionel Sambuctemplate <class _Tp>
2732*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(initializer_list<value_type> __il)
2733*4684ddb6SLionel Sambuc    : __begin_(0),
2734*4684ddb6SLionel Sambuc      __end_(0)
2735*4684ddb6SLionel Sambuc{
2736*4684ddb6SLionel Sambuc    size_t __n = __il.size();
2737*4684ddb6SLionel Sambuc    if (__n)
2738*4684ddb6SLionel Sambuc    {
2739*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2740*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2741*4684ddb6SLionel Sambuc        try
2742*4684ddb6SLionel Sambuc        {
2743*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2744*4684ddb6SLionel Sambuc            for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2745*4684ddb6SLionel Sambuc                ::new (__end_) value_type(*__p);
2746*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2747*4684ddb6SLionel Sambuc        }
2748*4684ddb6SLionel Sambuc        catch (...)
2749*4684ddb6SLionel Sambuc        {
2750*4684ddb6SLionel Sambuc            resize(0);
2751*4684ddb6SLionel Sambuc            throw;
2752*4684ddb6SLionel Sambuc        }
2753*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2754*4684ddb6SLionel Sambuc    }
2755*4684ddb6SLionel Sambuc}
2756*4684ddb6SLionel Sambuc
2757*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2758*4684ddb6SLionel Sambuc
2759*4684ddb6SLionel Sambuctemplate <class _Tp>
2760*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2761*4684ddb6SLionel Sambuc    : __begin_(0),
2762*4684ddb6SLionel Sambuc      __end_(0)
2763*4684ddb6SLionel Sambuc{
2764*4684ddb6SLionel Sambuc    size_t __n = __sa.__size_;
2765*4684ddb6SLionel Sambuc    if (__n)
2766*4684ddb6SLionel Sambuc    {
2767*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2768*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2769*4684ddb6SLionel Sambuc        try
2770*4684ddb6SLionel Sambuc        {
2771*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2772*4684ddb6SLionel Sambuc            for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2773*4684ddb6SLionel Sambuc                ::new (__end_) value_type(*__p);
2774*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2775*4684ddb6SLionel Sambuc        }
2776*4684ddb6SLionel Sambuc        catch (...)
2777*4684ddb6SLionel Sambuc        {
2778*4684ddb6SLionel Sambuc            resize(0);
2779*4684ddb6SLionel Sambuc            throw;
2780*4684ddb6SLionel Sambuc        }
2781*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2782*4684ddb6SLionel Sambuc    }
2783*4684ddb6SLionel Sambuc}
2784*4684ddb6SLionel Sambuc
2785*4684ddb6SLionel Sambuctemplate <class _Tp>
2786*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2787*4684ddb6SLionel Sambuc    : __begin_(0),
2788*4684ddb6SLionel Sambuc      __end_(0)
2789*4684ddb6SLionel Sambuc{
2790*4684ddb6SLionel Sambuc    size_t __n = __ga.__1d_.size();
2791*4684ddb6SLionel Sambuc    if (__n)
2792*4684ddb6SLionel Sambuc    {
2793*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2794*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2795*4684ddb6SLionel Sambuc        try
2796*4684ddb6SLionel Sambuc        {
2797*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2798*4684ddb6SLionel Sambuc            typedef const size_t* _Ip;
2799*4684ddb6SLionel Sambuc            const value_type* __s = __ga.__vp_;
2800*4684ddb6SLionel Sambuc            for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2801*4684ddb6SLionel Sambuc                    __i != __e; ++__i, ++__end_)
2802*4684ddb6SLionel Sambuc                ::new (__end_) value_type(__s[*__i]);
2803*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2804*4684ddb6SLionel Sambuc        }
2805*4684ddb6SLionel Sambuc        catch (...)
2806*4684ddb6SLionel Sambuc        {
2807*4684ddb6SLionel Sambuc            resize(0);
2808*4684ddb6SLionel Sambuc            throw;
2809*4684ddb6SLionel Sambuc        }
2810*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2811*4684ddb6SLionel Sambuc    }
2812*4684ddb6SLionel Sambuc}
2813*4684ddb6SLionel Sambuc
2814*4684ddb6SLionel Sambuctemplate <class _Tp>
2815*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2816*4684ddb6SLionel Sambuc    : __begin_(0),
2817*4684ddb6SLionel Sambuc      __end_(0)
2818*4684ddb6SLionel Sambuc{
2819*4684ddb6SLionel Sambuc    size_t __n = __ma.__1d_.size();
2820*4684ddb6SLionel Sambuc    if (__n)
2821*4684ddb6SLionel Sambuc    {
2822*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2823*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2824*4684ddb6SLionel Sambuc        try
2825*4684ddb6SLionel Sambuc        {
2826*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2827*4684ddb6SLionel Sambuc            typedef const size_t* _Ip;
2828*4684ddb6SLionel Sambuc            const value_type* __s = __ma.__vp_;
2829*4684ddb6SLionel Sambuc            for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2830*4684ddb6SLionel Sambuc                    __i != __e; ++__i, ++__end_)
2831*4684ddb6SLionel Sambuc                ::new (__end_) value_type(__s[*__i]);
2832*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2833*4684ddb6SLionel Sambuc        }
2834*4684ddb6SLionel Sambuc        catch (...)
2835*4684ddb6SLionel Sambuc        {
2836*4684ddb6SLionel Sambuc            resize(0);
2837*4684ddb6SLionel Sambuc            throw;
2838*4684ddb6SLionel Sambuc        }
2839*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2840*4684ddb6SLionel Sambuc    }
2841*4684ddb6SLionel Sambuc}
2842*4684ddb6SLionel Sambuc
2843*4684ddb6SLionel Sambuctemplate <class _Tp>
2844*4684ddb6SLionel Sambucvalarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2845*4684ddb6SLionel Sambuc    : __begin_(0),
2846*4684ddb6SLionel Sambuc      __end_(0)
2847*4684ddb6SLionel Sambuc{
2848*4684ddb6SLionel Sambuc    size_t __n = __ia.__1d_.size();
2849*4684ddb6SLionel Sambuc    if (__n)
2850*4684ddb6SLionel Sambuc    {
2851*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2852*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2853*4684ddb6SLionel Sambuc        try
2854*4684ddb6SLionel Sambuc        {
2855*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2856*4684ddb6SLionel Sambuc            typedef const size_t* _Ip;
2857*4684ddb6SLionel Sambuc            const value_type* __s = __ia.__vp_;
2858*4684ddb6SLionel Sambuc            for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2859*4684ddb6SLionel Sambuc                    __i != __e; ++__i, ++__end_)
2860*4684ddb6SLionel Sambuc                ::new (__end_) value_type(__s[*__i]);
2861*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
2862*4684ddb6SLionel Sambuc        }
2863*4684ddb6SLionel Sambuc        catch (...)
2864*4684ddb6SLionel Sambuc        {
2865*4684ddb6SLionel Sambuc            resize(0);
2866*4684ddb6SLionel Sambuc            throw;
2867*4684ddb6SLionel Sambuc        }
2868*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
2869*4684ddb6SLionel Sambuc    }
2870*4684ddb6SLionel Sambuc}
2871*4684ddb6SLionel Sambuc
2872*4684ddb6SLionel Sambuctemplate <class _Tp>
2873*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2874*4684ddb6SLionel Sambucvalarray<_Tp>::~valarray()
2875*4684ddb6SLionel Sambuc{
2876*4684ddb6SLionel Sambuc    resize(0);
2877*4684ddb6SLionel Sambuc}
2878*4684ddb6SLionel Sambuc
2879*4684ddb6SLionel Sambuctemplate <class _Tp>
2880*4684ddb6SLionel Sambucvalarray<_Tp>&
2881*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(const valarray& __v)
2882*4684ddb6SLionel Sambuc{
2883*4684ddb6SLionel Sambuc    if (this != &__v)
2884*4684ddb6SLionel Sambuc    {
2885*4684ddb6SLionel Sambuc        if (size() != __v.size())
2886*4684ddb6SLionel Sambuc            resize(__v.size());
2887*4684ddb6SLionel Sambuc        _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
2888*4684ddb6SLionel Sambuc    }
2889*4684ddb6SLionel Sambuc    return *this;
2890*4684ddb6SLionel Sambuc}
2891*4684ddb6SLionel Sambuc
2892*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2893*4684ddb6SLionel Sambuc
2894*4684ddb6SLionel Sambuctemplate <class _Tp>
2895*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2896*4684ddb6SLionel Sambucvalarray<_Tp>&
2897*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
2898*4684ddb6SLionel Sambuc{
2899*4684ddb6SLionel Sambuc    resize(0);
2900*4684ddb6SLionel Sambuc    __begin_ = __v.__begin_;
2901*4684ddb6SLionel Sambuc    __end_ = __v.__end_;
2902*4684ddb6SLionel Sambuc    __v.__begin_ = nullptr;
2903*4684ddb6SLionel Sambuc    __v.__end_ = nullptr;
2904*4684ddb6SLionel Sambuc    return *this;
2905*4684ddb6SLionel Sambuc}
2906*4684ddb6SLionel Sambuc
2907*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2908*4684ddb6SLionel Sambuc
2909*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2910*4684ddb6SLionel Sambuc
2911*4684ddb6SLionel Sambuctemplate <class _Tp>
2912*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2913*4684ddb6SLionel Sambucvalarray<_Tp>&
2914*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(initializer_list<value_type> __il)
2915*4684ddb6SLionel Sambuc{
2916*4684ddb6SLionel Sambuc    if (size() != __il.size())
2917*4684ddb6SLionel Sambuc        resize(__il.size());
2918*4684ddb6SLionel Sambuc    _VSTD::copy(__il.begin(), __il.end(), __begin_);
2919*4684ddb6SLionel Sambuc    return *this;
2920*4684ddb6SLionel Sambuc}
2921*4684ddb6SLionel Sambuc
2922*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2923*4684ddb6SLionel Sambuc
2924*4684ddb6SLionel Sambuctemplate <class _Tp>
2925*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2926*4684ddb6SLionel Sambucvalarray<_Tp>&
2927*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(const value_type& __x)
2928*4684ddb6SLionel Sambuc{
2929*4684ddb6SLionel Sambuc    _VSTD::fill(__begin_, __end_, __x);
2930*4684ddb6SLionel Sambuc    return *this;
2931*4684ddb6SLionel Sambuc}
2932*4684ddb6SLionel Sambuc
2933*4684ddb6SLionel Sambuctemplate <class _Tp>
2934*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2935*4684ddb6SLionel Sambucvalarray<_Tp>&
2936*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(const slice_array<value_type>& __sa)
2937*4684ddb6SLionel Sambuc{
2938*4684ddb6SLionel Sambuc    value_type* __t = __begin_;
2939*4684ddb6SLionel Sambuc    const value_type* __s = __sa.__vp_;
2940*4684ddb6SLionel Sambuc    for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
2941*4684ddb6SLionel Sambuc        *__t = *__s;
2942*4684ddb6SLionel Sambuc    return *this;
2943*4684ddb6SLionel Sambuc}
2944*4684ddb6SLionel Sambuc
2945*4684ddb6SLionel Sambuctemplate <class _Tp>
2946*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2947*4684ddb6SLionel Sambucvalarray<_Tp>&
2948*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
2949*4684ddb6SLionel Sambuc{
2950*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
2951*4684ddb6SLionel Sambuc    value_type* __t = __begin_;
2952*4684ddb6SLionel Sambuc    const value_type* __s = __ga.__vp_;
2953*4684ddb6SLionel Sambuc    for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2954*4684ddb6SLionel Sambuc                    __i != __e; ++__i, ++__t)
2955*4684ddb6SLionel Sambuc        *__t = __s[*__i];
2956*4684ddb6SLionel Sambuc    return *this;
2957*4684ddb6SLionel Sambuc}
2958*4684ddb6SLionel Sambuc
2959*4684ddb6SLionel Sambuctemplate <class _Tp>
2960*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2961*4684ddb6SLionel Sambucvalarray<_Tp>&
2962*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(const mask_array<value_type>& __ma)
2963*4684ddb6SLionel Sambuc{
2964*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
2965*4684ddb6SLionel Sambuc    value_type* __t = __begin_;
2966*4684ddb6SLionel Sambuc    const value_type* __s = __ma.__vp_;
2967*4684ddb6SLionel Sambuc    for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2968*4684ddb6SLionel Sambuc                    __i != __e; ++__i, ++__t)
2969*4684ddb6SLionel Sambuc        *__t = __s[*__i];
2970*4684ddb6SLionel Sambuc    return *this;
2971*4684ddb6SLionel Sambuc}
2972*4684ddb6SLionel Sambuc
2973*4684ddb6SLionel Sambuctemplate <class _Tp>
2974*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2975*4684ddb6SLionel Sambucvalarray<_Tp>&
2976*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
2977*4684ddb6SLionel Sambuc{
2978*4684ddb6SLionel Sambuc    typedef const size_t* _Ip;
2979*4684ddb6SLionel Sambuc    value_type* __t = __begin_;
2980*4684ddb6SLionel Sambuc    const value_type* __s = __ia.__vp_;
2981*4684ddb6SLionel Sambuc    for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2982*4684ddb6SLionel Sambuc                    __i != __e; ++__i, ++__t)
2983*4684ddb6SLionel Sambuc        *__t = __s[*__i];
2984*4684ddb6SLionel Sambuc    return *this;
2985*4684ddb6SLionel Sambuc}
2986*4684ddb6SLionel Sambuc
2987*4684ddb6SLionel Sambuctemplate <class _Tp>
2988*4684ddb6SLionel Sambuctemplate <class _ValExpr>
2989*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2990*4684ddb6SLionel Sambucvalarray<_Tp>&
2991*4684ddb6SLionel Sambucvalarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
2992*4684ddb6SLionel Sambuc{
2993*4684ddb6SLionel Sambuc    size_t __n = __v.size();
2994*4684ddb6SLionel Sambuc    if (size() != __n)
2995*4684ddb6SLionel Sambuc        resize(__n);
2996*4684ddb6SLionel Sambuc    value_type* __t = __begin_;
2997*4684ddb6SLionel Sambuc    for (size_t __i = 0; __i != __n; ++__t, ++__i)
2998*4684ddb6SLionel Sambuc        *__t = result_type(__v[__i]);
2999*4684ddb6SLionel Sambuc    return *this;
3000*4684ddb6SLionel Sambuc}
3001*4684ddb6SLionel Sambuc
3002*4684ddb6SLionel Sambuctemplate <class _Tp>
3003*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3004*4684ddb6SLionel Sambuc__val_expr<__slice_expr<const valarray<_Tp>&> >
3005*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](slice __s) const
3006*4684ddb6SLionel Sambuc{
3007*4684ddb6SLionel Sambuc    return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3008*4684ddb6SLionel Sambuc}
3009*4684ddb6SLionel Sambuc
3010*4684ddb6SLionel Sambuctemplate <class _Tp>
3011*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3012*4684ddb6SLionel Sambucslice_array<_Tp>
3013*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](slice __s)
3014*4684ddb6SLionel Sambuc{
3015*4684ddb6SLionel Sambuc    return slice_array<value_type>(__s, *this);
3016*4684ddb6SLionel Sambuc}
3017*4684ddb6SLionel Sambuc
3018*4684ddb6SLionel Sambuctemplate <class _Tp>
3019*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3020*4684ddb6SLionel Sambuc__val_expr<__indirect_expr<const valarray<_Tp>&> >
3021*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](const gslice& __gs) const
3022*4684ddb6SLionel Sambuc{
3023*4684ddb6SLionel Sambuc    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3024*4684ddb6SLionel Sambuc}
3025*4684ddb6SLionel Sambuc
3026*4684ddb6SLionel Sambuctemplate <class _Tp>
3027*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3028*4684ddb6SLionel Sambucgslice_array<_Tp>
3029*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](const gslice& __gs)
3030*4684ddb6SLionel Sambuc{
3031*4684ddb6SLionel Sambuc    return gslice_array<value_type>(__gs, *this);
3032*4684ddb6SLionel Sambuc}
3033*4684ddb6SLionel Sambuc
3034*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3035*4684ddb6SLionel Sambuc
3036*4684ddb6SLionel Sambuctemplate <class _Tp>
3037*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3038*4684ddb6SLionel Sambuc__val_expr<__indirect_expr<const valarray<_Tp>&> >
3039*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](gslice&& __gs) const
3040*4684ddb6SLionel Sambuc{
3041*4684ddb6SLionel Sambuc    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3042*4684ddb6SLionel Sambuc}
3043*4684ddb6SLionel Sambuc
3044*4684ddb6SLionel Sambuctemplate <class _Tp>
3045*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3046*4684ddb6SLionel Sambucgslice_array<_Tp>
3047*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](gslice&& __gs)
3048*4684ddb6SLionel Sambuc{
3049*4684ddb6SLionel Sambuc    return gslice_array<value_type>(move(__gs), *this);
3050*4684ddb6SLionel Sambuc}
3051*4684ddb6SLionel Sambuc
3052*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3053*4684ddb6SLionel Sambuc
3054*4684ddb6SLionel Sambuctemplate <class _Tp>
3055*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3056*4684ddb6SLionel Sambuc__val_expr<__mask_expr<const valarray<_Tp>&> >
3057*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](const valarray<bool>& __vb) const
3058*4684ddb6SLionel Sambuc{
3059*4684ddb6SLionel Sambuc    return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3060*4684ddb6SLionel Sambuc}
3061*4684ddb6SLionel Sambuc
3062*4684ddb6SLionel Sambuctemplate <class _Tp>
3063*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3064*4684ddb6SLionel Sambucmask_array<_Tp>
3065*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](const valarray<bool>& __vb)
3066*4684ddb6SLionel Sambuc{
3067*4684ddb6SLionel Sambuc    return mask_array<value_type>(__vb, *this);
3068*4684ddb6SLionel Sambuc}
3069*4684ddb6SLionel Sambuc
3070*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3071*4684ddb6SLionel Sambuc
3072*4684ddb6SLionel Sambuctemplate <class _Tp>
3073*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3074*4684ddb6SLionel Sambuc__val_expr<__mask_expr<const valarray<_Tp>&> >
3075*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](valarray<bool>&& __vb) const
3076*4684ddb6SLionel Sambuc{
3077*4684ddb6SLionel Sambuc    return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3078*4684ddb6SLionel Sambuc}
3079*4684ddb6SLionel Sambuc
3080*4684ddb6SLionel Sambuctemplate <class _Tp>
3081*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3082*4684ddb6SLionel Sambucmask_array<_Tp>
3083*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](valarray<bool>&& __vb)
3084*4684ddb6SLionel Sambuc{
3085*4684ddb6SLionel Sambuc    return mask_array<value_type>(move(__vb), *this);
3086*4684ddb6SLionel Sambuc}
3087*4684ddb6SLionel Sambuc
3088*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3089*4684ddb6SLionel Sambuc
3090*4684ddb6SLionel Sambuctemplate <class _Tp>
3091*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3092*4684ddb6SLionel Sambuc__val_expr<__indirect_expr<const valarray<_Tp>&> >
3093*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3094*4684ddb6SLionel Sambuc{
3095*4684ddb6SLionel Sambuc    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3096*4684ddb6SLionel Sambuc}
3097*4684ddb6SLionel Sambuc
3098*4684ddb6SLionel Sambuctemplate <class _Tp>
3099*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3100*4684ddb6SLionel Sambucindirect_array<_Tp>
3101*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](const valarray<size_t>& __vs)
3102*4684ddb6SLionel Sambuc{
3103*4684ddb6SLionel Sambuc    return indirect_array<value_type>(__vs, *this);
3104*4684ddb6SLionel Sambuc}
3105*4684ddb6SLionel Sambuc
3106*4684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3107*4684ddb6SLionel Sambuc
3108*4684ddb6SLionel Sambuctemplate <class _Tp>
3109*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3110*4684ddb6SLionel Sambuc__val_expr<__indirect_expr<const valarray<_Tp>&> >
3111*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3112*4684ddb6SLionel Sambuc{
3113*4684ddb6SLionel Sambuc    return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3114*4684ddb6SLionel Sambuc}
3115*4684ddb6SLionel Sambuc
3116*4684ddb6SLionel Sambuctemplate <class _Tp>
3117*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3118*4684ddb6SLionel Sambucindirect_array<_Tp>
3119*4684ddb6SLionel Sambucvalarray<_Tp>::operator[](valarray<size_t>&& __vs)
3120*4684ddb6SLionel Sambuc{
3121*4684ddb6SLionel Sambuc    return indirect_array<value_type>(move(__vs), *this);
3122*4684ddb6SLionel Sambuc}
3123*4684ddb6SLionel Sambuc
3124*4684ddb6SLionel Sambuc#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3125*4684ddb6SLionel Sambuc
3126*4684ddb6SLionel Sambuctemplate <class _Tp>
3127*4684ddb6SLionel Sambucvalarray<_Tp>
3128*4684ddb6SLionel Sambucvalarray<_Tp>::operator+() const
3129*4684ddb6SLionel Sambuc{
3130*4684ddb6SLionel Sambuc    valarray<value_type> __r;
3131*4684ddb6SLionel Sambuc    size_t __n = size();
3132*4684ddb6SLionel Sambuc    if (__n)
3133*4684ddb6SLionel Sambuc    {
3134*4684ddb6SLionel Sambuc        __r.__begin_ =
3135*4684ddb6SLionel Sambuc            __r.__end_ =
3136*4684ddb6SLionel Sambuc                static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3137*4684ddb6SLionel Sambuc        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3138*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(+*__p);
3139*4684ddb6SLionel Sambuc    }
3140*4684ddb6SLionel Sambuc    return __r;
3141*4684ddb6SLionel Sambuc}
3142*4684ddb6SLionel Sambuc
3143*4684ddb6SLionel Sambuctemplate <class _Tp>
3144*4684ddb6SLionel Sambucvalarray<_Tp>
3145*4684ddb6SLionel Sambucvalarray<_Tp>::operator-() const
3146*4684ddb6SLionel Sambuc{
3147*4684ddb6SLionel Sambuc    valarray<value_type> __r;
3148*4684ddb6SLionel Sambuc    size_t __n = size();
3149*4684ddb6SLionel Sambuc    if (__n)
3150*4684ddb6SLionel Sambuc    {
3151*4684ddb6SLionel Sambuc        __r.__begin_ =
3152*4684ddb6SLionel Sambuc            __r.__end_ =
3153*4684ddb6SLionel Sambuc                static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3154*4684ddb6SLionel Sambuc        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3155*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(-*__p);
3156*4684ddb6SLionel Sambuc    }
3157*4684ddb6SLionel Sambuc    return __r;
3158*4684ddb6SLionel Sambuc}
3159*4684ddb6SLionel Sambuc
3160*4684ddb6SLionel Sambuctemplate <class _Tp>
3161*4684ddb6SLionel Sambucvalarray<_Tp>
3162*4684ddb6SLionel Sambucvalarray<_Tp>::operator~() const
3163*4684ddb6SLionel Sambuc{
3164*4684ddb6SLionel Sambuc    valarray<value_type> __r;
3165*4684ddb6SLionel Sambuc    size_t __n = size();
3166*4684ddb6SLionel Sambuc    if (__n)
3167*4684ddb6SLionel Sambuc    {
3168*4684ddb6SLionel Sambuc        __r.__begin_ =
3169*4684ddb6SLionel Sambuc            __r.__end_ =
3170*4684ddb6SLionel Sambuc                static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3171*4684ddb6SLionel Sambuc        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3172*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(~*__p);
3173*4684ddb6SLionel Sambuc    }
3174*4684ddb6SLionel Sambuc    return __r;
3175*4684ddb6SLionel Sambuc}
3176*4684ddb6SLionel Sambuc
3177*4684ddb6SLionel Sambuctemplate <class _Tp>
3178*4684ddb6SLionel Sambucvalarray<bool>
3179*4684ddb6SLionel Sambucvalarray<_Tp>::operator!() const
3180*4684ddb6SLionel Sambuc{
3181*4684ddb6SLionel Sambuc    valarray<bool> __r;
3182*4684ddb6SLionel Sambuc    size_t __n = size();
3183*4684ddb6SLionel Sambuc    if (__n)
3184*4684ddb6SLionel Sambuc    {
3185*4684ddb6SLionel Sambuc        __r.__begin_ =
3186*4684ddb6SLionel Sambuc            __r.__end_ =
3187*4684ddb6SLionel Sambuc                static_cast<bool*>(::operator new(__n * sizeof(bool)));
3188*4684ddb6SLionel Sambuc        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3189*4684ddb6SLionel Sambuc            ::new (__r.__end_) bool(!*__p);
3190*4684ddb6SLionel Sambuc    }
3191*4684ddb6SLionel Sambuc    return __r;
3192*4684ddb6SLionel Sambuc}
3193*4684ddb6SLionel Sambuc
3194*4684ddb6SLionel Sambuctemplate <class _Tp>
3195*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3196*4684ddb6SLionel Sambucvalarray<_Tp>&
3197*4684ddb6SLionel Sambucvalarray<_Tp>::operator*=(const value_type& __x)
3198*4684ddb6SLionel Sambuc{
3199*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3200*4684ddb6SLionel Sambuc        *__p *= __x;
3201*4684ddb6SLionel Sambuc    return *this;
3202*4684ddb6SLionel Sambuc}
3203*4684ddb6SLionel Sambuc
3204*4684ddb6SLionel Sambuctemplate <class _Tp>
3205*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3206*4684ddb6SLionel Sambucvalarray<_Tp>&
3207*4684ddb6SLionel Sambucvalarray<_Tp>::operator/=(const value_type& __x)
3208*4684ddb6SLionel Sambuc{
3209*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3210*4684ddb6SLionel Sambuc        *__p /= __x;
3211*4684ddb6SLionel Sambuc    return *this;
3212*4684ddb6SLionel Sambuc}
3213*4684ddb6SLionel Sambuc
3214*4684ddb6SLionel Sambuctemplate <class _Tp>
3215*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3216*4684ddb6SLionel Sambucvalarray<_Tp>&
3217*4684ddb6SLionel Sambucvalarray<_Tp>::operator%=(const value_type& __x)
3218*4684ddb6SLionel Sambuc{
3219*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3220*4684ddb6SLionel Sambuc        *__p %= __x;
3221*4684ddb6SLionel Sambuc    return *this;
3222*4684ddb6SLionel Sambuc}
3223*4684ddb6SLionel Sambuc
3224*4684ddb6SLionel Sambuctemplate <class _Tp>
3225*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3226*4684ddb6SLionel Sambucvalarray<_Tp>&
3227*4684ddb6SLionel Sambucvalarray<_Tp>::operator+=(const value_type& __x)
3228*4684ddb6SLionel Sambuc{
3229*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3230*4684ddb6SLionel Sambuc        *__p += __x;
3231*4684ddb6SLionel Sambuc    return *this;
3232*4684ddb6SLionel Sambuc}
3233*4684ddb6SLionel Sambuc
3234*4684ddb6SLionel Sambuctemplate <class _Tp>
3235*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3236*4684ddb6SLionel Sambucvalarray<_Tp>&
3237*4684ddb6SLionel Sambucvalarray<_Tp>::operator-=(const value_type& __x)
3238*4684ddb6SLionel Sambuc{
3239*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3240*4684ddb6SLionel Sambuc        *__p -= __x;
3241*4684ddb6SLionel Sambuc    return *this;
3242*4684ddb6SLionel Sambuc}
3243*4684ddb6SLionel Sambuc
3244*4684ddb6SLionel Sambuctemplate <class _Tp>
3245*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3246*4684ddb6SLionel Sambucvalarray<_Tp>&
3247*4684ddb6SLionel Sambucvalarray<_Tp>::operator^=(const value_type& __x)
3248*4684ddb6SLionel Sambuc{
3249*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3250*4684ddb6SLionel Sambuc        *__p ^= __x;
3251*4684ddb6SLionel Sambuc    return *this;
3252*4684ddb6SLionel Sambuc}
3253*4684ddb6SLionel Sambuc
3254*4684ddb6SLionel Sambuctemplate <class _Tp>
3255*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3256*4684ddb6SLionel Sambucvalarray<_Tp>&
3257*4684ddb6SLionel Sambucvalarray<_Tp>::operator&=(const value_type& __x)
3258*4684ddb6SLionel Sambuc{
3259*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3260*4684ddb6SLionel Sambuc        *__p &= __x;
3261*4684ddb6SLionel Sambuc    return *this;
3262*4684ddb6SLionel Sambuc}
3263*4684ddb6SLionel Sambuc
3264*4684ddb6SLionel Sambuctemplate <class _Tp>
3265*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3266*4684ddb6SLionel Sambucvalarray<_Tp>&
3267*4684ddb6SLionel Sambucvalarray<_Tp>::operator|=(const value_type& __x)
3268*4684ddb6SLionel Sambuc{
3269*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3270*4684ddb6SLionel Sambuc        *__p |= __x;
3271*4684ddb6SLionel Sambuc    return *this;
3272*4684ddb6SLionel Sambuc}
3273*4684ddb6SLionel Sambuc
3274*4684ddb6SLionel Sambuctemplate <class _Tp>
3275*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3276*4684ddb6SLionel Sambucvalarray<_Tp>&
3277*4684ddb6SLionel Sambucvalarray<_Tp>::operator<<=(const value_type& __x)
3278*4684ddb6SLionel Sambuc{
3279*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3280*4684ddb6SLionel Sambuc        *__p <<= __x;
3281*4684ddb6SLionel Sambuc    return *this;
3282*4684ddb6SLionel Sambuc}
3283*4684ddb6SLionel Sambuc
3284*4684ddb6SLionel Sambuctemplate <class _Tp>
3285*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3286*4684ddb6SLionel Sambucvalarray<_Tp>&
3287*4684ddb6SLionel Sambucvalarray<_Tp>::operator>>=(const value_type& __x)
3288*4684ddb6SLionel Sambuc{
3289*4684ddb6SLionel Sambuc    for (value_type* __p = __begin_; __p != __end_; ++__p)
3290*4684ddb6SLionel Sambuc        *__p >>= __x;
3291*4684ddb6SLionel Sambuc    return *this;
3292*4684ddb6SLionel Sambuc}
3293*4684ddb6SLionel Sambuc
3294*4684ddb6SLionel Sambuctemplate <class _Tp>
3295*4684ddb6SLionel Sambuctemplate <class _Expr>
3296*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3297*4684ddb6SLionel Sambuctypename enable_if
3298*4684ddb6SLionel Sambuc<
3299*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3300*4684ddb6SLionel Sambuc    valarray<_Tp>&
3301*4684ddb6SLionel Sambuc>::type
3302*4684ddb6SLionel Sambucvalarray<_Tp>::operator*=(const _Expr& __v)
3303*4684ddb6SLionel Sambuc{
3304*4684ddb6SLionel Sambuc    size_t __i = 0;
3305*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3306*4684ddb6SLionel Sambuc        *__t *= __v[__i];
3307*4684ddb6SLionel Sambuc    return *this;
3308*4684ddb6SLionel Sambuc}
3309*4684ddb6SLionel Sambuc
3310*4684ddb6SLionel Sambuctemplate <class _Tp>
3311*4684ddb6SLionel Sambuctemplate <class _Expr>
3312*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3313*4684ddb6SLionel Sambuctypename enable_if
3314*4684ddb6SLionel Sambuc<
3315*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3316*4684ddb6SLionel Sambuc    valarray<_Tp>&
3317*4684ddb6SLionel Sambuc>::type
3318*4684ddb6SLionel Sambucvalarray<_Tp>::operator/=(const _Expr& __v)
3319*4684ddb6SLionel Sambuc{
3320*4684ddb6SLionel Sambuc    size_t __i = 0;
3321*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3322*4684ddb6SLionel Sambuc        *__t /= __v[__i];
3323*4684ddb6SLionel Sambuc    return *this;
3324*4684ddb6SLionel Sambuc}
3325*4684ddb6SLionel Sambuc
3326*4684ddb6SLionel Sambuctemplate <class _Tp>
3327*4684ddb6SLionel Sambuctemplate <class _Expr>
3328*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3329*4684ddb6SLionel Sambuctypename enable_if
3330*4684ddb6SLionel Sambuc<
3331*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3332*4684ddb6SLionel Sambuc    valarray<_Tp>&
3333*4684ddb6SLionel Sambuc>::type
3334*4684ddb6SLionel Sambucvalarray<_Tp>::operator%=(const _Expr& __v)
3335*4684ddb6SLionel Sambuc{
3336*4684ddb6SLionel Sambuc    size_t __i = 0;
3337*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3338*4684ddb6SLionel Sambuc        *__t %= __v[__i];
3339*4684ddb6SLionel Sambuc    return *this;
3340*4684ddb6SLionel Sambuc}
3341*4684ddb6SLionel Sambuc
3342*4684ddb6SLionel Sambuctemplate <class _Tp>
3343*4684ddb6SLionel Sambuctemplate <class _Expr>
3344*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3345*4684ddb6SLionel Sambuctypename enable_if
3346*4684ddb6SLionel Sambuc<
3347*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3348*4684ddb6SLionel Sambuc    valarray<_Tp>&
3349*4684ddb6SLionel Sambuc>::type
3350*4684ddb6SLionel Sambucvalarray<_Tp>::operator+=(const _Expr& __v)
3351*4684ddb6SLionel Sambuc{
3352*4684ddb6SLionel Sambuc    size_t __i = 0;
3353*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3354*4684ddb6SLionel Sambuc        *__t += __v[__i];
3355*4684ddb6SLionel Sambuc    return *this;
3356*4684ddb6SLionel Sambuc}
3357*4684ddb6SLionel Sambuc
3358*4684ddb6SLionel Sambuctemplate <class _Tp>
3359*4684ddb6SLionel Sambuctemplate <class _Expr>
3360*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3361*4684ddb6SLionel Sambuctypename enable_if
3362*4684ddb6SLionel Sambuc<
3363*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3364*4684ddb6SLionel Sambuc    valarray<_Tp>&
3365*4684ddb6SLionel Sambuc>::type
3366*4684ddb6SLionel Sambucvalarray<_Tp>::operator-=(const _Expr& __v)
3367*4684ddb6SLionel Sambuc{
3368*4684ddb6SLionel Sambuc    size_t __i = 0;
3369*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3370*4684ddb6SLionel Sambuc        *__t -= __v[__i];
3371*4684ddb6SLionel Sambuc    return *this;
3372*4684ddb6SLionel Sambuc}
3373*4684ddb6SLionel Sambuc
3374*4684ddb6SLionel Sambuctemplate <class _Tp>
3375*4684ddb6SLionel Sambuctemplate <class _Expr>
3376*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3377*4684ddb6SLionel Sambuctypename enable_if
3378*4684ddb6SLionel Sambuc<
3379*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3380*4684ddb6SLionel Sambuc    valarray<_Tp>&
3381*4684ddb6SLionel Sambuc>::type
3382*4684ddb6SLionel Sambucvalarray<_Tp>::operator^=(const _Expr& __v)
3383*4684ddb6SLionel Sambuc{
3384*4684ddb6SLionel Sambuc    size_t __i = 0;
3385*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3386*4684ddb6SLionel Sambuc        *__t ^= __v[__i];
3387*4684ddb6SLionel Sambuc    return *this;
3388*4684ddb6SLionel Sambuc}
3389*4684ddb6SLionel Sambuc
3390*4684ddb6SLionel Sambuctemplate <class _Tp>
3391*4684ddb6SLionel Sambuctemplate <class _Expr>
3392*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3393*4684ddb6SLionel Sambuctypename enable_if
3394*4684ddb6SLionel Sambuc<
3395*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3396*4684ddb6SLionel Sambuc    valarray<_Tp>&
3397*4684ddb6SLionel Sambuc>::type
3398*4684ddb6SLionel Sambucvalarray<_Tp>::operator|=(const _Expr& __v)
3399*4684ddb6SLionel Sambuc{
3400*4684ddb6SLionel Sambuc    size_t __i = 0;
3401*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3402*4684ddb6SLionel Sambuc        *__t |= __v[__i];
3403*4684ddb6SLionel Sambuc    return *this;
3404*4684ddb6SLionel Sambuc}
3405*4684ddb6SLionel Sambuc
3406*4684ddb6SLionel Sambuctemplate <class _Tp>
3407*4684ddb6SLionel Sambuctemplate <class _Expr>
3408*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3409*4684ddb6SLionel Sambuctypename enable_if
3410*4684ddb6SLionel Sambuc<
3411*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3412*4684ddb6SLionel Sambuc    valarray<_Tp>&
3413*4684ddb6SLionel Sambuc>::type
3414*4684ddb6SLionel Sambucvalarray<_Tp>::operator&=(const _Expr& __v)
3415*4684ddb6SLionel Sambuc{
3416*4684ddb6SLionel Sambuc    size_t __i = 0;
3417*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3418*4684ddb6SLionel Sambuc        *__t &= __v[__i];
3419*4684ddb6SLionel Sambuc    return *this;
3420*4684ddb6SLionel Sambuc}
3421*4684ddb6SLionel Sambuc
3422*4684ddb6SLionel Sambuctemplate <class _Tp>
3423*4684ddb6SLionel Sambuctemplate <class _Expr>
3424*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3425*4684ddb6SLionel Sambuctypename enable_if
3426*4684ddb6SLionel Sambuc<
3427*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3428*4684ddb6SLionel Sambuc    valarray<_Tp>&
3429*4684ddb6SLionel Sambuc>::type
3430*4684ddb6SLionel Sambucvalarray<_Tp>::operator<<=(const _Expr& __v)
3431*4684ddb6SLionel Sambuc{
3432*4684ddb6SLionel Sambuc    size_t __i = 0;
3433*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3434*4684ddb6SLionel Sambuc        *__t <<= __v[__i];
3435*4684ddb6SLionel Sambuc    return *this;
3436*4684ddb6SLionel Sambuc}
3437*4684ddb6SLionel Sambuc
3438*4684ddb6SLionel Sambuctemplate <class _Tp>
3439*4684ddb6SLionel Sambuctemplate <class _Expr>
3440*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3441*4684ddb6SLionel Sambuctypename enable_if
3442*4684ddb6SLionel Sambuc<
3443*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3444*4684ddb6SLionel Sambuc    valarray<_Tp>&
3445*4684ddb6SLionel Sambuc>::type
3446*4684ddb6SLionel Sambucvalarray<_Tp>::operator>>=(const _Expr& __v)
3447*4684ddb6SLionel Sambuc{
3448*4684ddb6SLionel Sambuc    size_t __i = 0;
3449*4684ddb6SLionel Sambuc    for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3450*4684ddb6SLionel Sambuc        *__t >>= __v[__i];
3451*4684ddb6SLionel Sambuc    return *this;
3452*4684ddb6SLionel Sambuc}
3453*4684ddb6SLionel Sambuc
3454*4684ddb6SLionel Sambuctemplate <class _Tp>
3455*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3456*4684ddb6SLionel Sambucvoid
3457*4684ddb6SLionel Sambucvalarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3458*4684ddb6SLionel Sambuc{
3459*4684ddb6SLionel Sambuc    _VSTD::swap(__begin_, __v.__begin_);
3460*4684ddb6SLionel Sambuc    _VSTD::swap(__end_, __v.__end_);
3461*4684ddb6SLionel Sambuc}
3462*4684ddb6SLionel Sambuc
3463*4684ddb6SLionel Sambuctemplate <class _Tp>
3464*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3465*4684ddb6SLionel Sambuc_Tp
3466*4684ddb6SLionel Sambucvalarray<_Tp>::sum() const
3467*4684ddb6SLionel Sambuc{
3468*4684ddb6SLionel Sambuc    if (__begin_ == __end_)
3469*4684ddb6SLionel Sambuc        return value_type();
3470*4684ddb6SLionel Sambuc    const value_type* __p = __begin_;
3471*4684ddb6SLionel Sambuc    _Tp __r = *__p;
3472*4684ddb6SLionel Sambuc    for (++__p; __p != __end_; ++__p)
3473*4684ddb6SLionel Sambuc        __r += *__p;
3474*4684ddb6SLionel Sambuc    return __r;
3475*4684ddb6SLionel Sambuc}
3476*4684ddb6SLionel Sambuc
3477*4684ddb6SLionel Sambuctemplate <class _Tp>
3478*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3479*4684ddb6SLionel Sambuc_Tp
3480*4684ddb6SLionel Sambucvalarray<_Tp>::min() const
3481*4684ddb6SLionel Sambuc{
3482*4684ddb6SLionel Sambuc    if (__begin_ == __end_)
3483*4684ddb6SLionel Sambuc        return value_type();
3484*4684ddb6SLionel Sambuc    return *_VSTD::min_element(__begin_, __end_);
3485*4684ddb6SLionel Sambuc}
3486*4684ddb6SLionel Sambuc
3487*4684ddb6SLionel Sambuctemplate <class _Tp>
3488*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3489*4684ddb6SLionel Sambuc_Tp
3490*4684ddb6SLionel Sambucvalarray<_Tp>::max() const
3491*4684ddb6SLionel Sambuc{
3492*4684ddb6SLionel Sambuc    if (__begin_ == __end_)
3493*4684ddb6SLionel Sambuc        return value_type();
3494*4684ddb6SLionel Sambuc    return *_VSTD::max_element(__begin_, __end_);
3495*4684ddb6SLionel Sambuc}
3496*4684ddb6SLionel Sambuc
3497*4684ddb6SLionel Sambuctemplate <class _Tp>
3498*4684ddb6SLionel Sambucvalarray<_Tp>
3499*4684ddb6SLionel Sambucvalarray<_Tp>::shift(int __i) const
3500*4684ddb6SLionel Sambuc{
3501*4684ddb6SLionel Sambuc    valarray<value_type> __r;
3502*4684ddb6SLionel Sambuc    size_t __n = size();
3503*4684ddb6SLionel Sambuc    if (__n)
3504*4684ddb6SLionel Sambuc    {
3505*4684ddb6SLionel Sambuc        __r.__begin_ =
3506*4684ddb6SLionel Sambuc            __r.__end_ =
3507*4684ddb6SLionel Sambuc                static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3508*4684ddb6SLionel Sambuc        const value_type* __sb;
3509*4684ddb6SLionel Sambuc        value_type* __tb;
3510*4684ddb6SLionel Sambuc        value_type* __te;
3511*4684ddb6SLionel Sambuc        if (__i >= 0)
3512*4684ddb6SLionel Sambuc        {
3513*4684ddb6SLionel Sambuc            __i = _VSTD::min(__i, static_cast<int>(__n));
3514*4684ddb6SLionel Sambuc            __sb = __begin_ + __i;
3515*4684ddb6SLionel Sambuc            __tb = __r.__begin_;
3516*4684ddb6SLionel Sambuc            __te = __r.__begin_ + (__n - __i);
3517*4684ddb6SLionel Sambuc        }
3518*4684ddb6SLionel Sambuc        else
3519*4684ddb6SLionel Sambuc        {
3520*4684ddb6SLionel Sambuc            __i = _VSTD::min(-__i, static_cast<int>(__n));
3521*4684ddb6SLionel Sambuc            __sb = __begin_;
3522*4684ddb6SLionel Sambuc            __tb = __r.__begin_ + __i;
3523*4684ddb6SLionel Sambuc            __te = __r.__begin_ + __n;
3524*4684ddb6SLionel Sambuc        }
3525*4684ddb6SLionel Sambuc        for (; __r.__end_ != __tb; ++__r.__end_)
3526*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type();
3527*4684ddb6SLionel Sambuc        for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3528*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(*__sb);
3529*4684ddb6SLionel Sambuc        for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3530*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type();
3531*4684ddb6SLionel Sambuc    }
3532*4684ddb6SLionel Sambuc    return __r;
3533*4684ddb6SLionel Sambuc}
3534*4684ddb6SLionel Sambuc
3535*4684ddb6SLionel Sambuctemplate <class _Tp>
3536*4684ddb6SLionel Sambucvalarray<_Tp>
3537*4684ddb6SLionel Sambucvalarray<_Tp>::cshift(int __i) const
3538*4684ddb6SLionel Sambuc{
3539*4684ddb6SLionel Sambuc    valarray<value_type> __r;
3540*4684ddb6SLionel Sambuc    size_t __n = size();
3541*4684ddb6SLionel Sambuc    if (__n)
3542*4684ddb6SLionel Sambuc    {
3543*4684ddb6SLionel Sambuc        __r.__begin_ =
3544*4684ddb6SLionel Sambuc            __r.__end_ =
3545*4684ddb6SLionel Sambuc                static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3546*4684ddb6SLionel Sambuc        __i %= static_cast<int>(__n);
3547*4684ddb6SLionel Sambuc        const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3548*4684ddb6SLionel Sambuc        for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3549*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(*__s);
3550*4684ddb6SLionel Sambuc        for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3551*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(*__s);
3552*4684ddb6SLionel Sambuc    }
3553*4684ddb6SLionel Sambuc    return __r;
3554*4684ddb6SLionel Sambuc}
3555*4684ddb6SLionel Sambuc
3556*4684ddb6SLionel Sambuctemplate <class _Tp>
3557*4684ddb6SLionel Sambucvalarray<_Tp>
3558*4684ddb6SLionel Sambucvalarray<_Tp>::apply(value_type __f(value_type)) const
3559*4684ddb6SLionel Sambuc{
3560*4684ddb6SLionel Sambuc    valarray<value_type> __r;
3561*4684ddb6SLionel Sambuc    size_t __n = size();
3562*4684ddb6SLionel Sambuc    if (__n)
3563*4684ddb6SLionel Sambuc    {
3564*4684ddb6SLionel Sambuc        __r.__begin_ =
3565*4684ddb6SLionel Sambuc            __r.__end_ =
3566*4684ddb6SLionel Sambuc                static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3567*4684ddb6SLionel Sambuc        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3568*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(__f(*__p));
3569*4684ddb6SLionel Sambuc    }
3570*4684ddb6SLionel Sambuc    return __r;
3571*4684ddb6SLionel Sambuc}
3572*4684ddb6SLionel Sambuc
3573*4684ddb6SLionel Sambuctemplate <class _Tp>
3574*4684ddb6SLionel Sambucvalarray<_Tp>
3575*4684ddb6SLionel Sambucvalarray<_Tp>::apply(value_type __f(const value_type&)) const
3576*4684ddb6SLionel Sambuc{
3577*4684ddb6SLionel Sambuc    valarray<value_type> __r;
3578*4684ddb6SLionel Sambuc    size_t __n = size();
3579*4684ddb6SLionel Sambuc    if (__n)
3580*4684ddb6SLionel Sambuc    {
3581*4684ddb6SLionel Sambuc        __r.__begin_ =
3582*4684ddb6SLionel Sambuc            __r.__end_ =
3583*4684ddb6SLionel Sambuc                static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3584*4684ddb6SLionel Sambuc        for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3585*4684ddb6SLionel Sambuc            ::new (__r.__end_) value_type(__f(*__p));
3586*4684ddb6SLionel Sambuc    }
3587*4684ddb6SLionel Sambuc    return __r;
3588*4684ddb6SLionel Sambuc}
3589*4684ddb6SLionel Sambuc
3590*4684ddb6SLionel Sambuctemplate <class _Tp>
3591*4684ddb6SLionel Sambucvoid
3592*4684ddb6SLionel Sambucvalarray<_Tp>::resize(size_t __n, value_type __x)
3593*4684ddb6SLionel Sambuc{
3594*4684ddb6SLionel Sambuc    if (__begin_ != nullptr)
3595*4684ddb6SLionel Sambuc    {
3596*4684ddb6SLionel Sambuc        while (__end_ != __begin_)
3597*4684ddb6SLionel Sambuc            (--__end_)->~value_type();
3598*4684ddb6SLionel Sambuc        ::operator delete(__begin_);
3599*4684ddb6SLionel Sambuc        __begin_ = __end_ = nullptr;
3600*4684ddb6SLionel Sambuc    }
3601*4684ddb6SLionel Sambuc    if (__n)
3602*4684ddb6SLionel Sambuc    {
3603*4684ddb6SLionel Sambuc        __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3604*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
3605*4684ddb6SLionel Sambuc        try
3606*4684ddb6SLionel Sambuc        {
3607*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
3608*4684ddb6SLionel Sambuc            for (; __n; --__n, ++__end_)
3609*4684ddb6SLionel Sambuc                ::new (__end_) value_type(__x);
3610*4684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS
3611*4684ddb6SLionel Sambuc        }
3612*4684ddb6SLionel Sambuc        catch (...)
3613*4684ddb6SLionel Sambuc        {
3614*4684ddb6SLionel Sambuc            resize(0);
3615*4684ddb6SLionel Sambuc            throw;
3616*4684ddb6SLionel Sambuc        }
3617*4684ddb6SLionel Sambuc#endif  // _LIBCPP_NO_EXCEPTIONS
3618*4684ddb6SLionel Sambuc    }
3619*4684ddb6SLionel Sambuc}
3620*4684ddb6SLionel Sambuc
3621*4684ddb6SLionel Sambuctemplate<class _Tp>
3622*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3623*4684ddb6SLionel Sambucvoid
3624*4684ddb6SLionel Sambucswap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3625*4684ddb6SLionel Sambuc{
3626*4684ddb6SLionel Sambuc    __x.swap(__y);
3627*4684ddb6SLionel Sambuc}
3628*4684ddb6SLionel Sambuc
3629*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3630*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3631*4684ddb6SLionel Sambuctypename enable_if
3632*4684ddb6SLionel Sambuc<
3633*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3634*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3635*4684ddb6SLionel Sambuc>::type
3636*4684ddb6SLionel Sambucoperator*(const _Expr1& __x, const _Expr2& __y)
3637*4684ddb6SLionel Sambuc{
3638*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3639*4684ddb6SLionel Sambuc    typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3640*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3641*4684ddb6SLionel Sambuc}
3642*4684ddb6SLionel Sambuc
3643*4684ddb6SLionel Sambuctemplate<class _Expr>
3644*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3645*4684ddb6SLionel Sambuctypename enable_if
3646*4684ddb6SLionel Sambuc<
3647*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3648*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3649*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3650*4684ddb6SLionel Sambuc>::type
3651*4684ddb6SLionel Sambucoperator*(const _Expr& __x, const typename _Expr::value_type& __y)
3652*4684ddb6SLionel Sambuc{
3653*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3654*4684ddb6SLionel Sambuc    typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3655*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(multiplies<value_type>(),
3656*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3657*4684ddb6SLionel Sambuc}
3658*4684ddb6SLionel Sambuc
3659*4684ddb6SLionel Sambuctemplate<class _Expr>
3660*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3661*4684ddb6SLionel Sambuctypename enable_if
3662*4684ddb6SLionel Sambuc<
3663*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3664*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3665*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3666*4684ddb6SLionel Sambuc>::type
3667*4684ddb6SLionel Sambucoperator*(const typename _Expr::value_type& __x, const _Expr& __y)
3668*4684ddb6SLionel Sambuc{
3669*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3670*4684ddb6SLionel Sambuc    typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3671*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(multiplies<value_type>(),
3672*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3673*4684ddb6SLionel Sambuc}
3674*4684ddb6SLionel Sambuc
3675*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3676*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3677*4684ddb6SLionel Sambuctypename enable_if
3678*4684ddb6SLionel Sambuc<
3679*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3680*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3681*4684ddb6SLionel Sambuc>::type
3682*4684ddb6SLionel Sambucoperator/(const _Expr1& __x, const _Expr2& __y)
3683*4684ddb6SLionel Sambuc{
3684*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3685*4684ddb6SLionel Sambuc    typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3686*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3687*4684ddb6SLionel Sambuc}
3688*4684ddb6SLionel Sambuc
3689*4684ddb6SLionel Sambuctemplate<class _Expr>
3690*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3691*4684ddb6SLionel Sambuctypename enable_if
3692*4684ddb6SLionel Sambuc<
3693*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3694*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3695*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3696*4684ddb6SLionel Sambuc>::type
3697*4684ddb6SLionel Sambucoperator/(const _Expr& __x, const typename _Expr::value_type& __y)
3698*4684ddb6SLionel Sambuc{
3699*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3700*4684ddb6SLionel Sambuc    typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3701*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(divides<value_type>(),
3702*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3703*4684ddb6SLionel Sambuc}
3704*4684ddb6SLionel Sambuc
3705*4684ddb6SLionel Sambuctemplate<class _Expr>
3706*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3707*4684ddb6SLionel Sambuctypename enable_if
3708*4684ddb6SLionel Sambuc<
3709*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3710*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3711*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3712*4684ddb6SLionel Sambuc>::type
3713*4684ddb6SLionel Sambucoperator/(const typename _Expr::value_type& __x, const _Expr& __y)
3714*4684ddb6SLionel Sambuc{
3715*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3716*4684ddb6SLionel Sambuc    typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3717*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(divides<value_type>(),
3718*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3719*4684ddb6SLionel Sambuc}
3720*4684ddb6SLionel Sambuc
3721*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3722*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3723*4684ddb6SLionel Sambuctypename enable_if
3724*4684ddb6SLionel Sambuc<
3725*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3726*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3727*4684ddb6SLionel Sambuc>::type
3728*4684ddb6SLionel Sambucoperator%(const _Expr1& __x, const _Expr2& __y)
3729*4684ddb6SLionel Sambuc{
3730*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3731*4684ddb6SLionel Sambuc    typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3732*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3733*4684ddb6SLionel Sambuc}
3734*4684ddb6SLionel Sambuc
3735*4684ddb6SLionel Sambuctemplate<class _Expr>
3736*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3737*4684ddb6SLionel Sambuctypename enable_if
3738*4684ddb6SLionel Sambuc<
3739*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3740*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3741*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3742*4684ddb6SLionel Sambuc>::type
3743*4684ddb6SLionel Sambucoperator%(const _Expr& __x, const typename _Expr::value_type& __y)
3744*4684ddb6SLionel Sambuc{
3745*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3746*4684ddb6SLionel Sambuc    typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3747*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(modulus<value_type>(),
3748*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3749*4684ddb6SLionel Sambuc}
3750*4684ddb6SLionel Sambuc
3751*4684ddb6SLionel Sambuctemplate<class _Expr>
3752*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3753*4684ddb6SLionel Sambuctypename enable_if
3754*4684ddb6SLionel Sambuc<
3755*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3756*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3757*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3758*4684ddb6SLionel Sambuc>::type
3759*4684ddb6SLionel Sambucoperator%(const typename _Expr::value_type& __x, const _Expr& __y)
3760*4684ddb6SLionel Sambuc{
3761*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3762*4684ddb6SLionel Sambuc    typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3763*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(modulus<value_type>(),
3764*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3765*4684ddb6SLionel Sambuc}
3766*4684ddb6SLionel Sambuc
3767*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3768*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3769*4684ddb6SLionel Sambuctypename enable_if
3770*4684ddb6SLionel Sambuc<
3771*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3772*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3773*4684ddb6SLionel Sambuc>::type
3774*4684ddb6SLionel Sambucoperator+(const _Expr1& __x, const _Expr2& __y)
3775*4684ddb6SLionel Sambuc{
3776*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3777*4684ddb6SLionel Sambuc    typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3778*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3779*4684ddb6SLionel Sambuc}
3780*4684ddb6SLionel Sambuc
3781*4684ddb6SLionel Sambuctemplate<class _Expr>
3782*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3783*4684ddb6SLionel Sambuctypename enable_if
3784*4684ddb6SLionel Sambuc<
3785*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3786*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3787*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3788*4684ddb6SLionel Sambuc>::type
3789*4684ddb6SLionel Sambucoperator+(const _Expr& __x, const typename _Expr::value_type& __y)
3790*4684ddb6SLionel Sambuc{
3791*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3792*4684ddb6SLionel Sambuc    typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3793*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(plus<value_type>(),
3794*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3795*4684ddb6SLionel Sambuc}
3796*4684ddb6SLionel Sambuc
3797*4684ddb6SLionel Sambuctemplate<class _Expr>
3798*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3799*4684ddb6SLionel Sambuctypename enable_if
3800*4684ddb6SLionel Sambuc<
3801*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3802*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3803*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3804*4684ddb6SLionel Sambuc>::type
3805*4684ddb6SLionel Sambucoperator+(const typename _Expr::value_type& __x, const _Expr& __y)
3806*4684ddb6SLionel Sambuc{
3807*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3808*4684ddb6SLionel Sambuc    typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3809*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(plus<value_type>(),
3810*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3811*4684ddb6SLionel Sambuc}
3812*4684ddb6SLionel Sambuc
3813*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3814*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3815*4684ddb6SLionel Sambuctypename enable_if
3816*4684ddb6SLionel Sambuc<
3817*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3818*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3819*4684ddb6SLionel Sambuc>::type
3820*4684ddb6SLionel Sambucoperator-(const _Expr1& __x, const _Expr2& __y)
3821*4684ddb6SLionel Sambuc{
3822*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3823*4684ddb6SLionel Sambuc    typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3824*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3825*4684ddb6SLionel Sambuc}
3826*4684ddb6SLionel Sambuc
3827*4684ddb6SLionel Sambuctemplate<class _Expr>
3828*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3829*4684ddb6SLionel Sambuctypename enable_if
3830*4684ddb6SLionel Sambuc<
3831*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3832*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3833*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3834*4684ddb6SLionel Sambuc>::type
3835*4684ddb6SLionel Sambucoperator-(const _Expr& __x, const typename _Expr::value_type& __y)
3836*4684ddb6SLionel Sambuc{
3837*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3838*4684ddb6SLionel Sambuc    typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3839*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(minus<value_type>(),
3840*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3841*4684ddb6SLionel Sambuc}
3842*4684ddb6SLionel Sambuc
3843*4684ddb6SLionel Sambuctemplate<class _Expr>
3844*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3845*4684ddb6SLionel Sambuctypename enable_if
3846*4684ddb6SLionel Sambuc<
3847*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3848*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3849*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3850*4684ddb6SLionel Sambuc>::type
3851*4684ddb6SLionel Sambucoperator-(const typename _Expr::value_type& __x, const _Expr& __y)
3852*4684ddb6SLionel Sambuc{
3853*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3854*4684ddb6SLionel Sambuc    typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3855*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(minus<value_type>(),
3856*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3857*4684ddb6SLionel Sambuc}
3858*4684ddb6SLionel Sambuc
3859*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3860*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3861*4684ddb6SLionel Sambuctypename enable_if
3862*4684ddb6SLionel Sambuc<
3863*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3864*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3865*4684ddb6SLionel Sambuc>::type
3866*4684ddb6SLionel Sambucoperator^(const _Expr1& __x, const _Expr2& __y)
3867*4684ddb6SLionel Sambuc{
3868*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3869*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3870*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3871*4684ddb6SLionel Sambuc}
3872*4684ddb6SLionel Sambuc
3873*4684ddb6SLionel Sambuctemplate<class _Expr>
3874*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3875*4684ddb6SLionel Sambuctypename enable_if
3876*4684ddb6SLionel Sambuc<
3877*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3878*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3879*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3880*4684ddb6SLionel Sambuc>::type
3881*4684ddb6SLionel Sambucoperator^(const _Expr& __x, const typename _Expr::value_type& __y)
3882*4684ddb6SLionel Sambuc{
3883*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3884*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3885*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3886*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3887*4684ddb6SLionel Sambuc}
3888*4684ddb6SLionel Sambuc
3889*4684ddb6SLionel Sambuctemplate<class _Expr>
3890*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3891*4684ddb6SLionel Sambuctypename enable_if
3892*4684ddb6SLionel Sambuc<
3893*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3894*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3895*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3896*4684ddb6SLionel Sambuc>::type
3897*4684ddb6SLionel Sambucoperator^(const typename _Expr::value_type& __x, const _Expr& __y)
3898*4684ddb6SLionel Sambuc{
3899*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3900*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3901*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3902*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3903*4684ddb6SLionel Sambuc}
3904*4684ddb6SLionel Sambuc
3905*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3906*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3907*4684ddb6SLionel Sambuctypename enable_if
3908*4684ddb6SLionel Sambuc<
3909*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3910*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
3911*4684ddb6SLionel Sambuc>::type
3912*4684ddb6SLionel Sambucoperator&(const _Expr1& __x, const _Expr2& __y)
3913*4684ddb6SLionel Sambuc{
3914*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3915*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
3916*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
3917*4684ddb6SLionel Sambuc}
3918*4684ddb6SLionel Sambuc
3919*4684ddb6SLionel Sambuctemplate<class _Expr>
3920*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3921*4684ddb6SLionel Sambuctypename enable_if
3922*4684ddb6SLionel Sambuc<
3923*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3924*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3925*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3926*4684ddb6SLionel Sambuc>::type
3927*4684ddb6SLionel Sambucoperator&(const _Expr& __x, const typename _Expr::value_type& __y)
3928*4684ddb6SLionel Sambuc{
3929*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3930*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3931*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_and<value_type>(),
3932*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3933*4684ddb6SLionel Sambuc}
3934*4684ddb6SLionel Sambuc
3935*4684ddb6SLionel Sambuctemplate<class _Expr>
3936*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3937*4684ddb6SLionel Sambuctypename enable_if
3938*4684ddb6SLionel Sambuc<
3939*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3940*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3941*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3942*4684ddb6SLionel Sambuc>::type
3943*4684ddb6SLionel Sambucoperator&(const typename _Expr::value_type& __x, const _Expr& __y)
3944*4684ddb6SLionel Sambuc{
3945*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3946*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3947*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_and<value_type>(),
3948*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3949*4684ddb6SLionel Sambuc}
3950*4684ddb6SLionel Sambuc
3951*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3952*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3953*4684ddb6SLionel Sambuctypename enable_if
3954*4684ddb6SLionel Sambuc<
3955*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3956*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
3957*4684ddb6SLionel Sambuc>::type
3958*4684ddb6SLionel Sambucoperator|(const _Expr1& __x, const _Expr2& __y)
3959*4684ddb6SLionel Sambuc{
3960*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
3961*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
3962*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
3963*4684ddb6SLionel Sambuc}
3964*4684ddb6SLionel Sambuc
3965*4684ddb6SLionel Sambuctemplate<class _Expr>
3966*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3967*4684ddb6SLionel Sambuctypename enable_if
3968*4684ddb6SLionel Sambuc<
3969*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3970*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3971*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
3972*4684ddb6SLionel Sambuc>::type
3973*4684ddb6SLionel Sambucoperator|(const _Expr& __x, const typename _Expr::value_type& __y)
3974*4684ddb6SLionel Sambuc{
3975*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3976*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3977*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_or<value_type>(),
3978*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
3979*4684ddb6SLionel Sambuc}
3980*4684ddb6SLionel Sambuc
3981*4684ddb6SLionel Sambuctemplate<class _Expr>
3982*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3983*4684ddb6SLionel Sambuctypename enable_if
3984*4684ddb6SLionel Sambuc<
3985*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
3986*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3987*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
3988*4684ddb6SLionel Sambuc>::type
3989*4684ddb6SLionel Sambucoperator|(const typename _Expr::value_type& __x, const _Expr& __y)
3990*4684ddb6SLionel Sambuc{
3991*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
3992*4684ddb6SLionel Sambuc    typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3993*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(bit_or<value_type>(),
3994*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
3995*4684ddb6SLionel Sambuc}
3996*4684ddb6SLionel Sambuc
3997*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
3998*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3999*4684ddb6SLionel Sambuctypename enable_if
4000*4684ddb6SLionel Sambuc<
4001*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4002*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4003*4684ddb6SLionel Sambuc>::type
4004*4684ddb6SLionel Sambucoperator<<(const _Expr1& __x, const _Expr2& __y)
4005*4684ddb6SLionel Sambuc{
4006*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4007*4684ddb6SLionel Sambuc    typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4008*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4009*4684ddb6SLionel Sambuc}
4010*4684ddb6SLionel Sambuc
4011*4684ddb6SLionel Sambuctemplate<class _Expr>
4012*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4013*4684ddb6SLionel Sambuctypename enable_if
4014*4684ddb6SLionel Sambuc<
4015*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4016*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4017*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4018*4684ddb6SLionel Sambuc>::type
4019*4684ddb6SLionel Sambucoperator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4020*4684ddb6SLionel Sambuc{
4021*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4022*4684ddb6SLionel Sambuc    typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4023*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4024*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4025*4684ddb6SLionel Sambuc}
4026*4684ddb6SLionel Sambuc
4027*4684ddb6SLionel Sambuctemplate<class _Expr>
4028*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4029*4684ddb6SLionel Sambuctypename enable_if
4030*4684ddb6SLionel Sambuc<
4031*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4032*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4033*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4034*4684ddb6SLionel Sambuc>::type
4035*4684ddb6SLionel Sambucoperator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4036*4684ddb6SLionel Sambuc{
4037*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4038*4684ddb6SLionel Sambuc    typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4039*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4040*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4041*4684ddb6SLionel Sambuc}
4042*4684ddb6SLionel Sambuc
4043*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4044*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4045*4684ddb6SLionel Sambuctypename enable_if
4046*4684ddb6SLionel Sambuc<
4047*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4048*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4049*4684ddb6SLionel Sambuc>::type
4050*4684ddb6SLionel Sambucoperator>>(const _Expr1& __x, const _Expr2& __y)
4051*4684ddb6SLionel Sambuc{
4052*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4053*4684ddb6SLionel Sambuc    typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4054*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4055*4684ddb6SLionel Sambuc}
4056*4684ddb6SLionel Sambuc
4057*4684ddb6SLionel Sambuctemplate<class _Expr>
4058*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4059*4684ddb6SLionel Sambuctypename enable_if
4060*4684ddb6SLionel Sambuc<
4061*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4062*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4063*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4064*4684ddb6SLionel Sambuc>::type
4065*4684ddb6SLionel Sambucoperator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4066*4684ddb6SLionel Sambuc{
4067*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4068*4684ddb6SLionel Sambuc    typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4069*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4070*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4071*4684ddb6SLionel Sambuc}
4072*4684ddb6SLionel Sambuc
4073*4684ddb6SLionel Sambuctemplate<class _Expr>
4074*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4075*4684ddb6SLionel Sambuctypename enable_if
4076*4684ddb6SLionel Sambuc<
4077*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4078*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4079*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4080*4684ddb6SLionel Sambuc>::type
4081*4684ddb6SLionel Sambucoperator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4082*4684ddb6SLionel Sambuc{
4083*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4084*4684ddb6SLionel Sambuc    typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4085*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4086*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4087*4684ddb6SLionel Sambuc}
4088*4684ddb6SLionel Sambuc
4089*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4090*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4091*4684ddb6SLionel Sambuctypename enable_if
4092*4684ddb6SLionel Sambuc<
4093*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4094*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4095*4684ddb6SLionel Sambuc>::type
4096*4684ddb6SLionel Sambucoperator&&(const _Expr1& __x, const _Expr2& __y)
4097*4684ddb6SLionel Sambuc{
4098*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4099*4684ddb6SLionel Sambuc    typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4100*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4101*4684ddb6SLionel Sambuc}
4102*4684ddb6SLionel Sambuc
4103*4684ddb6SLionel Sambuctemplate<class _Expr>
4104*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4105*4684ddb6SLionel Sambuctypename enable_if
4106*4684ddb6SLionel Sambuc<
4107*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4108*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4109*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4110*4684ddb6SLionel Sambuc>::type
4111*4684ddb6SLionel Sambucoperator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4112*4684ddb6SLionel Sambuc{
4113*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4114*4684ddb6SLionel Sambuc    typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4115*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(logical_and<value_type>(),
4116*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4117*4684ddb6SLionel Sambuc}
4118*4684ddb6SLionel Sambuc
4119*4684ddb6SLionel Sambuctemplate<class _Expr>
4120*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4121*4684ddb6SLionel Sambuctypename enable_if
4122*4684ddb6SLionel Sambuc<
4123*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4124*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4125*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4126*4684ddb6SLionel Sambuc>::type
4127*4684ddb6SLionel Sambucoperator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4128*4684ddb6SLionel Sambuc{
4129*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4130*4684ddb6SLionel Sambuc    typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4131*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(logical_and<value_type>(),
4132*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4133*4684ddb6SLionel Sambuc}
4134*4684ddb6SLionel Sambuc
4135*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4136*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4137*4684ddb6SLionel Sambuctypename enable_if
4138*4684ddb6SLionel Sambuc<
4139*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4140*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4141*4684ddb6SLionel Sambuc>::type
4142*4684ddb6SLionel Sambucoperator||(const _Expr1& __x, const _Expr2& __y)
4143*4684ddb6SLionel Sambuc{
4144*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4145*4684ddb6SLionel Sambuc    typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4146*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4147*4684ddb6SLionel Sambuc}
4148*4684ddb6SLionel Sambuc
4149*4684ddb6SLionel Sambuctemplate<class _Expr>
4150*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4151*4684ddb6SLionel Sambuctypename enable_if
4152*4684ddb6SLionel Sambuc<
4153*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4154*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4155*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4156*4684ddb6SLionel Sambuc>::type
4157*4684ddb6SLionel Sambucoperator||(const _Expr& __x, const typename _Expr::value_type& __y)
4158*4684ddb6SLionel Sambuc{
4159*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4160*4684ddb6SLionel Sambuc    typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4161*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(logical_or<value_type>(),
4162*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4163*4684ddb6SLionel Sambuc}
4164*4684ddb6SLionel Sambuc
4165*4684ddb6SLionel Sambuctemplate<class _Expr>
4166*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4167*4684ddb6SLionel Sambuctypename enable_if
4168*4684ddb6SLionel Sambuc<
4169*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4170*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4171*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4172*4684ddb6SLionel Sambuc>::type
4173*4684ddb6SLionel Sambucoperator||(const typename _Expr::value_type& __x, const _Expr& __y)
4174*4684ddb6SLionel Sambuc{
4175*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4176*4684ddb6SLionel Sambuc    typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4177*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(logical_or<value_type>(),
4178*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4179*4684ddb6SLionel Sambuc}
4180*4684ddb6SLionel Sambuc
4181*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4182*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4183*4684ddb6SLionel Sambuctypename enable_if
4184*4684ddb6SLionel Sambuc<
4185*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4186*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4187*4684ddb6SLionel Sambuc>::type
4188*4684ddb6SLionel Sambucoperator==(const _Expr1& __x, const _Expr2& __y)
4189*4684ddb6SLionel Sambuc{
4190*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4191*4684ddb6SLionel Sambuc    typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4192*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4193*4684ddb6SLionel Sambuc}
4194*4684ddb6SLionel Sambuc
4195*4684ddb6SLionel Sambuctemplate<class _Expr>
4196*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4197*4684ddb6SLionel Sambuctypename enable_if
4198*4684ddb6SLionel Sambuc<
4199*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4200*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4201*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4202*4684ddb6SLionel Sambuc>::type
4203*4684ddb6SLionel Sambucoperator==(const _Expr& __x, const typename _Expr::value_type& __y)
4204*4684ddb6SLionel Sambuc{
4205*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4206*4684ddb6SLionel Sambuc    typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4207*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(equal_to<value_type>(),
4208*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4209*4684ddb6SLionel Sambuc}
4210*4684ddb6SLionel Sambuc
4211*4684ddb6SLionel Sambuctemplate<class _Expr>
4212*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4213*4684ddb6SLionel Sambuctypename enable_if
4214*4684ddb6SLionel Sambuc<
4215*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4216*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4217*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4218*4684ddb6SLionel Sambuc>::type
4219*4684ddb6SLionel Sambucoperator==(const typename _Expr::value_type& __x, const _Expr& __y)
4220*4684ddb6SLionel Sambuc{
4221*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4222*4684ddb6SLionel Sambuc    typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4223*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(equal_to<value_type>(),
4224*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4225*4684ddb6SLionel Sambuc}
4226*4684ddb6SLionel Sambuc
4227*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4228*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4229*4684ddb6SLionel Sambuctypename enable_if
4230*4684ddb6SLionel Sambuc<
4231*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4232*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4233*4684ddb6SLionel Sambuc>::type
4234*4684ddb6SLionel Sambucoperator!=(const _Expr1& __x, const _Expr2& __y)
4235*4684ddb6SLionel Sambuc{
4236*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4237*4684ddb6SLionel Sambuc    typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4238*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4239*4684ddb6SLionel Sambuc}
4240*4684ddb6SLionel Sambuc
4241*4684ddb6SLionel Sambuctemplate<class _Expr>
4242*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4243*4684ddb6SLionel Sambuctypename enable_if
4244*4684ddb6SLionel Sambuc<
4245*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4246*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4247*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4248*4684ddb6SLionel Sambuc>::type
4249*4684ddb6SLionel Sambucoperator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4250*4684ddb6SLionel Sambuc{
4251*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4252*4684ddb6SLionel Sambuc    typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4253*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4254*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4255*4684ddb6SLionel Sambuc}
4256*4684ddb6SLionel Sambuc
4257*4684ddb6SLionel Sambuctemplate<class _Expr>
4258*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4259*4684ddb6SLionel Sambuctypename enable_if
4260*4684ddb6SLionel Sambuc<
4261*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4262*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4263*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4264*4684ddb6SLionel Sambuc>::type
4265*4684ddb6SLionel Sambucoperator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4266*4684ddb6SLionel Sambuc{
4267*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4268*4684ddb6SLionel Sambuc    typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4269*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4270*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4271*4684ddb6SLionel Sambuc}
4272*4684ddb6SLionel Sambuc
4273*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4274*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4275*4684ddb6SLionel Sambuctypename enable_if
4276*4684ddb6SLionel Sambuc<
4277*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4278*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4279*4684ddb6SLionel Sambuc>::type
4280*4684ddb6SLionel Sambucoperator<(const _Expr1& __x, const _Expr2& __y)
4281*4684ddb6SLionel Sambuc{
4282*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4283*4684ddb6SLionel Sambuc    typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4284*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4285*4684ddb6SLionel Sambuc}
4286*4684ddb6SLionel Sambuc
4287*4684ddb6SLionel Sambuctemplate<class _Expr>
4288*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4289*4684ddb6SLionel Sambuctypename enable_if
4290*4684ddb6SLionel Sambuc<
4291*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4292*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4293*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4294*4684ddb6SLionel Sambuc>::type
4295*4684ddb6SLionel Sambucoperator<(const _Expr& __x, const typename _Expr::value_type& __y)
4296*4684ddb6SLionel Sambuc{
4297*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4298*4684ddb6SLionel Sambuc    typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4299*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(less<value_type>(),
4300*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4301*4684ddb6SLionel Sambuc}
4302*4684ddb6SLionel Sambuc
4303*4684ddb6SLionel Sambuctemplate<class _Expr>
4304*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4305*4684ddb6SLionel Sambuctypename enable_if
4306*4684ddb6SLionel Sambuc<
4307*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4308*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4309*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4310*4684ddb6SLionel Sambuc>::type
4311*4684ddb6SLionel Sambucoperator<(const typename _Expr::value_type& __x, const _Expr& __y)
4312*4684ddb6SLionel Sambuc{
4313*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4314*4684ddb6SLionel Sambuc    typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4315*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(less<value_type>(),
4316*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4317*4684ddb6SLionel Sambuc}
4318*4684ddb6SLionel Sambuc
4319*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4320*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4321*4684ddb6SLionel Sambuctypename enable_if
4322*4684ddb6SLionel Sambuc<
4323*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4324*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4325*4684ddb6SLionel Sambuc>::type
4326*4684ddb6SLionel Sambucoperator>(const _Expr1& __x, const _Expr2& __y)
4327*4684ddb6SLionel Sambuc{
4328*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4329*4684ddb6SLionel Sambuc    typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4330*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4331*4684ddb6SLionel Sambuc}
4332*4684ddb6SLionel Sambuc
4333*4684ddb6SLionel Sambuctemplate<class _Expr>
4334*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4335*4684ddb6SLionel Sambuctypename enable_if
4336*4684ddb6SLionel Sambuc<
4337*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4338*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4339*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4340*4684ddb6SLionel Sambuc>::type
4341*4684ddb6SLionel Sambucoperator>(const _Expr& __x, const typename _Expr::value_type& __y)
4342*4684ddb6SLionel Sambuc{
4343*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4344*4684ddb6SLionel Sambuc    typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4345*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(greater<value_type>(),
4346*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4347*4684ddb6SLionel Sambuc}
4348*4684ddb6SLionel Sambuc
4349*4684ddb6SLionel Sambuctemplate<class _Expr>
4350*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4351*4684ddb6SLionel Sambuctypename enable_if
4352*4684ddb6SLionel Sambuc<
4353*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4354*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4355*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4356*4684ddb6SLionel Sambuc>::type
4357*4684ddb6SLionel Sambucoperator>(const typename _Expr::value_type& __x, const _Expr& __y)
4358*4684ddb6SLionel Sambuc{
4359*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4360*4684ddb6SLionel Sambuc    typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4361*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(greater<value_type>(),
4362*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4363*4684ddb6SLionel Sambuc}
4364*4684ddb6SLionel Sambuc
4365*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4366*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4367*4684ddb6SLionel Sambuctypename enable_if
4368*4684ddb6SLionel Sambuc<
4369*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4370*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4371*4684ddb6SLionel Sambuc>::type
4372*4684ddb6SLionel Sambucoperator<=(const _Expr1& __x, const _Expr2& __y)
4373*4684ddb6SLionel Sambuc{
4374*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4375*4684ddb6SLionel Sambuc    typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4376*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4377*4684ddb6SLionel Sambuc}
4378*4684ddb6SLionel Sambuc
4379*4684ddb6SLionel Sambuctemplate<class _Expr>
4380*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4381*4684ddb6SLionel Sambuctypename enable_if
4382*4684ddb6SLionel Sambuc<
4383*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4384*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4385*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4386*4684ddb6SLionel Sambuc>::type
4387*4684ddb6SLionel Sambucoperator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4388*4684ddb6SLionel Sambuc{
4389*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4390*4684ddb6SLionel Sambuc    typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4391*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(less_equal<value_type>(),
4392*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4393*4684ddb6SLionel Sambuc}
4394*4684ddb6SLionel Sambuc
4395*4684ddb6SLionel Sambuctemplate<class _Expr>
4396*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4397*4684ddb6SLionel Sambuctypename enable_if
4398*4684ddb6SLionel Sambuc<
4399*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4400*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4401*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4402*4684ddb6SLionel Sambuc>::type
4403*4684ddb6SLionel Sambucoperator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4404*4684ddb6SLionel Sambuc{
4405*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4406*4684ddb6SLionel Sambuc    typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4407*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(less_equal<value_type>(),
4408*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4409*4684ddb6SLionel Sambuc}
4410*4684ddb6SLionel Sambuc
4411*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4412*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4413*4684ddb6SLionel Sambuctypename enable_if
4414*4684ddb6SLionel Sambuc<
4415*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4416*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4417*4684ddb6SLionel Sambuc>::type
4418*4684ddb6SLionel Sambucoperator>=(const _Expr1& __x, const _Expr2& __y)
4419*4684ddb6SLionel Sambuc{
4420*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4421*4684ddb6SLionel Sambuc    typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4422*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4423*4684ddb6SLionel Sambuc}
4424*4684ddb6SLionel Sambuc
4425*4684ddb6SLionel Sambuctemplate<class _Expr>
4426*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4427*4684ddb6SLionel Sambuctypename enable_if
4428*4684ddb6SLionel Sambuc<
4429*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4430*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4431*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4432*4684ddb6SLionel Sambuc>::type
4433*4684ddb6SLionel Sambucoperator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4434*4684ddb6SLionel Sambuc{
4435*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4436*4684ddb6SLionel Sambuc    typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4437*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4438*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4439*4684ddb6SLionel Sambuc}
4440*4684ddb6SLionel Sambuc
4441*4684ddb6SLionel Sambuctemplate<class _Expr>
4442*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4443*4684ddb6SLionel Sambuctypename enable_if
4444*4684ddb6SLionel Sambuc<
4445*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4446*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4447*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4448*4684ddb6SLionel Sambuc>::type
4449*4684ddb6SLionel Sambucoperator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4450*4684ddb6SLionel Sambuc{
4451*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4452*4684ddb6SLionel Sambuc    typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4453*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4454*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4455*4684ddb6SLionel Sambuc}
4456*4684ddb6SLionel Sambuc
4457*4684ddb6SLionel Sambuctemplate<class _Expr>
4458*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4459*4684ddb6SLionel Sambuctypename enable_if
4460*4684ddb6SLionel Sambuc<
4461*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4462*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4463*4684ddb6SLionel Sambuc>::type
4464*4684ddb6SLionel Sambucabs(const _Expr& __x)
4465*4684ddb6SLionel Sambuc{
4466*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4467*4684ddb6SLionel Sambuc    typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4468*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4469*4684ddb6SLionel Sambuc}
4470*4684ddb6SLionel Sambuc
4471*4684ddb6SLionel Sambuctemplate<class _Expr>
4472*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4473*4684ddb6SLionel Sambuctypename enable_if
4474*4684ddb6SLionel Sambuc<
4475*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4476*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4477*4684ddb6SLionel Sambuc>::type
4478*4684ddb6SLionel Sambucacos(const _Expr& __x)
4479*4684ddb6SLionel Sambuc{
4480*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4481*4684ddb6SLionel Sambuc    typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4482*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4483*4684ddb6SLionel Sambuc}
4484*4684ddb6SLionel Sambuc
4485*4684ddb6SLionel Sambuctemplate<class _Expr>
4486*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4487*4684ddb6SLionel Sambuctypename enable_if
4488*4684ddb6SLionel Sambuc<
4489*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4490*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4491*4684ddb6SLionel Sambuc>::type
4492*4684ddb6SLionel Sambucasin(const _Expr& __x)
4493*4684ddb6SLionel Sambuc{
4494*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4495*4684ddb6SLionel Sambuc    typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4496*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4497*4684ddb6SLionel Sambuc}
4498*4684ddb6SLionel Sambuc
4499*4684ddb6SLionel Sambuctemplate<class _Expr>
4500*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4501*4684ddb6SLionel Sambuctypename enable_if
4502*4684ddb6SLionel Sambuc<
4503*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4504*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4505*4684ddb6SLionel Sambuc>::type
4506*4684ddb6SLionel Sambucatan(const _Expr& __x)
4507*4684ddb6SLionel Sambuc{
4508*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4509*4684ddb6SLionel Sambuc    typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4510*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4511*4684ddb6SLionel Sambuc}
4512*4684ddb6SLionel Sambuc
4513*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4514*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4515*4684ddb6SLionel Sambuctypename enable_if
4516*4684ddb6SLionel Sambuc<
4517*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4518*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4519*4684ddb6SLionel Sambuc>::type
4520*4684ddb6SLionel Sambucatan2(const _Expr1& __x, const _Expr2& __y)
4521*4684ddb6SLionel Sambuc{
4522*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4523*4684ddb6SLionel Sambuc    typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4524*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4525*4684ddb6SLionel Sambuc}
4526*4684ddb6SLionel Sambuc
4527*4684ddb6SLionel Sambuctemplate<class _Expr>
4528*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4529*4684ddb6SLionel Sambuctypename enable_if
4530*4684ddb6SLionel Sambuc<
4531*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4532*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4533*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4534*4684ddb6SLionel Sambuc>::type
4535*4684ddb6SLionel Sambucatan2(const _Expr& __x, const typename _Expr::value_type& __y)
4536*4684ddb6SLionel Sambuc{
4537*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4538*4684ddb6SLionel Sambuc    typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4539*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4540*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4541*4684ddb6SLionel Sambuc}
4542*4684ddb6SLionel Sambuc
4543*4684ddb6SLionel Sambuctemplate<class _Expr>
4544*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4545*4684ddb6SLionel Sambuctypename enable_if
4546*4684ddb6SLionel Sambuc<
4547*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4548*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4549*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4550*4684ddb6SLionel Sambuc>::type
4551*4684ddb6SLionel Sambucatan2(const typename _Expr::value_type& __x, const _Expr& __y)
4552*4684ddb6SLionel Sambuc{
4553*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4554*4684ddb6SLionel Sambuc    typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4555*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4556*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4557*4684ddb6SLionel Sambuc}
4558*4684ddb6SLionel Sambuc
4559*4684ddb6SLionel Sambuctemplate<class _Expr>
4560*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4561*4684ddb6SLionel Sambuctypename enable_if
4562*4684ddb6SLionel Sambuc<
4563*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4564*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4565*4684ddb6SLionel Sambuc>::type
4566*4684ddb6SLionel Sambuccos(const _Expr& __x)
4567*4684ddb6SLionel Sambuc{
4568*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4569*4684ddb6SLionel Sambuc    typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4570*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4571*4684ddb6SLionel Sambuc}
4572*4684ddb6SLionel Sambuc
4573*4684ddb6SLionel Sambuctemplate<class _Expr>
4574*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4575*4684ddb6SLionel Sambuctypename enable_if
4576*4684ddb6SLionel Sambuc<
4577*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4578*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4579*4684ddb6SLionel Sambuc>::type
4580*4684ddb6SLionel Sambuccosh(const _Expr& __x)
4581*4684ddb6SLionel Sambuc{
4582*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4583*4684ddb6SLionel Sambuc    typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4584*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4585*4684ddb6SLionel Sambuc}
4586*4684ddb6SLionel Sambuc
4587*4684ddb6SLionel Sambuctemplate<class _Expr>
4588*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4589*4684ddb6SLionel Sambuctypename enable_if
4590*4684ddb6SLionel Sambuc<
4591*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4592*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4593*4684ddb6SLionel Sambuc>::type
4594*4684ddb6SLionel Sambucexp(const _Expr& __x)
4595*4684ddb6SLionel Sambuc{
4596*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4597*4684ddb6SLionel Sambuc    typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4598*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4599*4684ddb6SLionel Sambuc}
4600*4684ddb6SLionel Sambuc
4601*4684ddb6SLionel Sambuctemplate<class _Expr>
4602*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4603*4684ddb6SLionel Sambuctypename enable_if
4604*4684ddb6SLionel Sambuc<
4605*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4606*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4607*4684ddb6SLionel Sambuc>::type
4608*4684ddb6SLionel Sambuclog(const _Expr& __x)
4609*4684ddb6SLionel Sambuc{
4610*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4611*4684ddb6SLionel Sambuc    typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4612*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4613*4684ddb6SLionel Sambuc}
4614*4684ddb6SLionel Sambuc
4615*4684ddb6SLionel Sambuctemplate<class _Expr>
4616*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4617*4684ddb6SLionel Sambuctypename enable_if
4618*4684ddb6SLionel Sambuc<
4619*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4620*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4621*4684ddb6SLionel Sambuc>::type
4622*4684ddb6SLionel Sambuclog10(const _Expr& __x)
4623*4684ddb6SLionel Sambuc{
4624*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4625*4684ddb6SLionel Sambuc    typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4626*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4627*4684ddb6SLionel Sambuc}
4628*4684ddb6SLionel Sambuc
4629*4684ddb6SLionel Sambuctemplate<class _Expr1, class _Expr2>
4630*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4631*4684ddb6SLionel Sambuctypename enable_if
4632*4684ddb6SLionel Sambuc<
4633*4684ddb6SLionel Sambuc    __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4634*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4635*4684ddb6SLionel Sambuc>::type
4636*4684ddb6SLionel Sambucpow(const _Expr1& __x, const _Expr2& __y)
4637*4684ddb6SLionel Sambuc{
4638*4684ddb6SLionel Sambuc    typedef typename _Expr1::value_type value_type;
4639*4684ddb6SLionel Sambuc    typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4640*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4641*4684ddb6SLionel Sambuc}
4642*4684ddb6SLionel Sambuc
4643*4684ddb6SLionel Sambuctemplate<class _Expr>
4644*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4645*4684ddb6SLionel Sambuctypename enable_if
4646*4684ddb6SLionel Sambuc<
4647*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4648*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4649*4684ddb6SLionel Sambuc               _Expr, __scalar_expr<typename _Expr::value_type> > >
4650*4684ddb6SLionel Sambuc>::type
4651*4684ddb6SLionel Sambucpow(const _Expr& __x, const typename _Expr::value_type& __y)
4652*4684ddb6SLionel Sambuc{
4653*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4654*4684ddb6SLionel Sambuc    typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4655*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4656*4684ddb6SLionel Sambuc                           __x, __scalar_expr<value_type>(__y, __x.size())));
4657*4684ddb6SLionel Sambuc}
4658*4684ddb6SLionel Sambuc
4659*4684ddb6SLionel Sambuctemplate<class _Expr>
4660*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4661*4684ddb6SLionel Sambuctypename enable_if
4662*4684ddb6SLionel Sambuc<
4663*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4664*4684ddb6SLionel Sambuc    __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4665*4684ddb6SLionel Sambuc               __scalar_expr<typename _Expr::value_type>, _Expr> >
4666*4684ddb6SLionel Sambuc>::type
4667*4684ddb6SLionel Sambucpow(const typename _Expr::value_type& __x, const _Expr& __y)
4668*4684ddb6SLionel Sambuc{
4669*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4670*4684ddb6SLionel Sambuc    typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4671*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4672*4684ddb6SLionel Sambuc                           __scalar_expr<value_type>(__x, __y.size()), __y));
4673*4684ddb6SLionel Sambuc}
4674*4684ddb6SLionel Sambuc
4675*4684ddb6SLionel Sambuctemplate<class _Expr>
4676*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4677*4684ddb6SLionel Sambuctypename enable_if
4678*4684ddb6SLionel Sambuc<
4679*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4680*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4681*4684ddb6SLionel Sambuc>::type
4682*4684ddb6SLionel Sambucsin(const _Expr& __x)
4683*4684ddb6SLionel Sambuc{
4684*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4685*4684ddb6SLionel Sambuc    typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4686*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4687*4684ddb6SLionel Sambuc}
4688*4684ddb6SLionel Sambuc
4689*4684ddb6SLionel Sambuctemplate<class _Expr>
4690*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4691*4684ddb6SLionel Sambuctypename enable_if
4692*4684ddb6SLionel Sambuc<
4693*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4694*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4695*4684ddb6SLionel Sambuc>::type
4696*4684ddb6SLionel Sambucsinh(const _Expr& __x)
4697*4684ddb6SLionel Sambuc{
4698*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4699*4684ddb6SLionel Sambuc    typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4700*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4701*4684ddb6SLionel Sambuc}
4702*4684ddb6SLionel Sambuc
4703*4684ddb6SLionel Sambuctemplate<class _Expr>
4704*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4705*4684ddb6SLionel Sambuctypename enable_if
4706*4684ddb6SLionel Sambuc<
4707*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4708*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4709*4684ddb6SLionel Sambuc>::type
4710*4684ddb6SLionel Sambucsqrt(const _Expr& __x)
4711*4684ddb6SLionel Sambuc{
4712*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4713*4684ddb6SLionel Sambuc    typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4714*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4715*4684ddb6SLionel Sambuc}
4716*4684ddb6SLionel Sambuc
4717*4684ddb6SLionel Sambuctemplate<class _Expr>
4718*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4719*4684ddb6SLionel Sambuctypename enable_if
4720*4684ddb6SLionel Sambuc<
4721*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4722*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4723*4684ddb6SLionel Sambuc>::type
4724*4684ddb6SLionel Sambuctan(const _Expr& __x)
4725*4684ddb6SLionel Sambuc{
4726*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4727*4684ddb6SLionel Sambuc    typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4728*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4729*4684ddb6SLionel Sambuc}
4730*4684ddb6SLionel Sambuc
4731*4684ddb6SLionel Sambuctemplate<class _Expr>
4732*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4733*4684ddb6SLionel Sambuctypename enable_if
4734*4684ddb6SLionel Sambuc<
4735*4684ddb6SLionel Sambuc    __is_val_expr<_Expr>::value,
4736*4684ddb6SLionel Sambuc    __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4737*4684ddb6SLionel Sambuc>::type
4738*4684ddb6SLionel Sambuctanh(const _Expr& __x)
4739*4684ddb6SLionel Sambuc{
4740*4684ddb6SLionel Sambuc    typedef typename _Expr::value_type value_type;
4741*4684ddb6SLionel Sambuc    typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4742*4684ddb6SLionel Sambuc    return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4743*4684ddb6SLionel Sambuc}
4744*4684ddb6SLionel Sambuc
4745*4684ddb6SLionel Sambuctemplate <class _Tp>
4746*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4747*4684ddb6SLionel Sambuc_Tp*
4748*4684ddb6SLionel Sambucbegin(valarray<_Tp>& __v)
4749*4684ddb6SLionel Sambuc{
4750*4684ddb6SLionel Sambuc    return __v.__begin_;
4751*4684ddb6SLionel Sambuc}
4752*4684ddb6SLionel Sambuc
4753*4684ddb6SLionel Sambuctemplate <class _Tp>
4754*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4755*4684ddb6SLionel Sambucconst _Tp*
4756*4684ddb6SLionel Sambucbegin(const valarray<_Tp>& __v)
4757*4684ddb6SLionel Sambuc{
4758*4684ddb6SLionel Sambuc    return __v.__begin_;
4759*4684ddb6SLionel Sambuc}
4760*4684ddb6SLionel Sambuc
4761*4684ddb6SLionel Sambuctemplate <class _Tp>
4762*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4763*4684ddb6SLionel Sambuc_Tp*
4764*4684ddb6SLionel Sambucend(valarray<_Tp>& __v)
4765*4684ddb6SLionel Sambuc{
4766*4684ddb6SLionel Sambuc    return __v.__end_;
4767*4684ddb6SLionel Sambuc}
4768*4684ddb6SLionel Sambuc
4769*4684ddb6SLionel Sambuctemplate <class _Tp>
4770*4684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4771*4684ddb6SLionel Sambucconst _Tp*
4772*4684ddb6SLionel Sambucend(const valarray<_Tp>& __v)
4773*4684ddb6SLionel Sambuc{
4774*4684ddb6SLionel Sambuc    return __v.__end_;
4775*4684ddb6SLionel Sambuc}
4776*4684ddb6SLionel Sambuc
4777*4684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
4778*4684ddb6SLionel Sambuc
4779*4684ddb6SLionel Sambuc#endif  // _LIBCPP_VALARRAY
4780