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