]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/std/valarray
objc-act.c: Fix comment typos.
[thirdparty/gcc.git] / libstdc++-v3 / include / std / valarray
CommitLineData
54c1bf78 1// The template and inlines for the -*- C++ -*- valarray class.
de96ac46 2
681a6919
PC
3// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4// 2006, 2007
ffe94f83 5// Free Software Foundation, Inc.
de96ac46
BK
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
10// Free Software Foundation; either version 2, or (at your option)
11// any later version.
12
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
af13a7a6
BK
18// You should have received a copy of the GNU General Public License
19// along with this library; see the file COPYING. If not, write to
20// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21// Boston, MA 02110-1301, USA.
de96ac46
BK
22
23// As a special exception, you may use this file as part of a free software
24// library without restriction. Specifically, if other files instantiate
25// templates or use macros or inline functions from this file, or you compile
26// this file and link it with other files to produce an executable, this
27// file does not by itself cause the resulting executable to be covered by
28// the GNU General Public License. This exception does not however
29// invalidate any other reasons why the executable file might be covered by
30// the GNU General Public License.
31
ffe94f83 32/** @file valarray
0aa06b18 33 * This is a Standard C++ Library header.
2f9d51b8
PE
34 */
35
143c27b0
BK
36// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
37
1143680e
SE
38#ifndef _GLIBCXX_VALARRAY
39#define _GLIBCXX_VALARRAY 1
54c1bf78
BK
40
41#pragma GCC system_header
42
43#include <bits/c++config.h>
44#include <cstddef>
45#include <cmath>
54c1bf78 46#include <algorithm>
285b36d6 47#include <debug/debug.h>
54c1bf78 48
3cbc7af0
BK
49_GLIBCXX_BEGIN_NAMESPACE(std)
50
74d6b8ca
GDR
51 template<class _Clos, typename _Tp>
52 class _Expr;
54c1bf78 53
74d6b8ca
GDR
54 template<typename _Tp1, typename _Tp2>
55 class _ValArray;
54c1bf78 56
74d6b8ca
GDR
57 template<class _Oper, template<class, class> class _Meta, class _Dom>
58 struct _UnClos;
54c1bf78 59
971cfc6f 60 template<class _Oper,
54c1bf78
BK
61 template<class, class> class _Meta1,
62 template<class, class> class _Meta2,
74d6b8ca
GDR
63 class _Dom1, class _Dom2>
64 class _BinClos;
54c1bf78 65
74d6b8ca
GDR
66 template<template<class, class> class _Meta, class _Dom>
67 class _SClos;
54c1bf78 68
74d6b8ca
GDR
69 template<template<class, class> class _Meta, class _Dom>
70 class _GClos;
54c1bf78 71
74d6b8ca
GDR
72 template<template<class, class> class _Meta, class _Dom>
73 class _IClos;
54c1bf78 74
74d6b8ca
GDR
75 template<template<class, class> class _Meta, class _Dom>
76 class _ValFunClos;
54c1bf78 77
74d6b8ca
GDR
78 template<template<class, class> class _Meta, class _Dom>
79 class _RefFunClos;
80
74d6b8ca
GDR
81 template<class _Tp> class valarray; // An array of type _Tp
82 class slice; // BLAS-like slice out of an array
83 template<class _Tp> class slice_array;
84 class gslice; // generalized slice out of an array
85 template<class _Tp> class gslice_array;
86 template<class _Tp> class mask_array; // masked array
87 template<class _Tp> class indirect_array; // indirected array
54c1bf78 88
3cbc7af0 89_GLIBCXX_END_NAMESPACE
54c1bf78
BK
90
91#include <bits/valarray_array.h>
c13bea50 92#include <bits/valarray_before.h>
54c1bf78 93
3cbc7af0
BK
94_GLIBCXX_BEGIN_NAMESPACE(std)
95
7fb397a4
JQ
96 /**
97 * @brief Smart array designed to support numeric processing.
98 *
99 * A valarray is an array that provides constraints intended to allow for
100 * effective optimization of numeric array processing by reducing the
101 * aliasing that can result from pointer representations. It represents a
102 * one-dimensional array from which different multidimensional subsets can
103 * be accessed and modified.
104 *
105 * @param Tp Type of object in the array.
106 */
74d6b8ca
GDR
107 template<class _Tp>
108 class valarray
109 {
110 template<class _Op>
111 struct _UnaryOp
112 {
113 typedef typename __fun<_Op, _Tp>::result_type __rt;
114 typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt;
115 };
116 public:
54c1bf78 117 typedef _Tp value_type;
74d6b8ca
GDR
118
119 // _lib.valarray.cons_ construct/destroy:
7fb397a4 120 /// Construct an empty array.
54c1bf78 121 valarray();
7fb397a4
JQ
122
123 /// Construct an array with @a n elements.
54c1bf78 124 explicit valarray(size_t);
7fb397a4
JQ
125
126 /// Construct an array with @a n elements initialized to @a t.
54c1bf78 127 valarray(const _Tp&, size_t);
7fb397a4
JQ
128
129 /// Construct an array initialized to the first @a n elements of @a t.
54c1bf78 130 valarray(const _Tp* __restrict__, size_t);
7fb397a4
JQ
131
132 /// Copy constructor.
54c1bf78 133 valarray(const valarray&);
7fb397a4
JQ
134
135 /// Construct an array with the same size and values in @a sa.
54c1bf78 136 valarray(const slice_array<_Tp>&);
7fb397a4
JQ
137
138 /// Construct an array with the same size and values in @a ga.
54c1bf78 139 valarray(const gslice_array<_Tp>&);
7fb397a4
JQ
140
141 /// Construct an array with the same size and values in @a ma.
54c1bf78 142 valarray(const mask_array<_Tp>&);
7fb397a4
JQ
143
144 /// Construct an array with the same size and values in @a ia.
54c1bf78 145 valarray(const indirect_array<_Tp>&);
7fb397a4 146
54c1bf78 147 template<class _Dom>
b714a419
PC
148 valarray(const _Expr<_Dom, _Tp>& __e);
149
74d6b8ca 150 ~valarray();
54c1bf78
BK
151
152 // _lib.valarray.assign_ assignment:
7fb397a4
JQ
153 /**
154 * @brief Assign elements to an array.
155 *
156 * Assign elements of array to values in @a v. Results are undefined
dc5fef6a 157 * if @a v does not have the same size as this array.
7fb397a4
JQ
158 *
159 * @param v Valarray to get values from.
160 */
54c1bf78 161 valarray<_Tp>& operator=(const valarray<_Tp>&);
7fb397a4
JQ
162
163 /**
164 * @brief Assign elements to a value.
165 *
166 * Assign all elements of array to @a t.
167 *
168 * @param t Value for elements.
169 */
54c1bf78 170 valarray<_Tp>& operator=(const _Tp&);
7fb397a4
JQ
171
172 /**
173 * @brief Assign elements to an array subset.
174 *
175 * Assign elements of array to values in @a sa. Results are undefined
dc5fef6a 176 * if @a sa does not have the same size as this array.
7fb397a4
JQ
177 *
178 * @param sa Array slice to get values from.
179 */
54c1bf78 180 valarray<_Tp>& operator=(const slice_array<_Tp>&);
7fb397a4
JQ
181
182 /**
183 * @brief Assign elements to an array subset.
184 *
185 * Assign elements of array to values in @a ga. Results are undefined
dc5fef6a 186 * if @a ga does not have the same size as this array.
7fb397a4
JQ
187 *
188 * @param ga Array slice to get values from.
189 */
54c1bf78 190 valarray<_Tp>& operator=(const gslice_array<_Tp>&);
7fb397a4
JQ
191
192 /**
193 * @brief Assign elements to an array subset.
194 *
195 * Assign elements of array to values in @a ma. Results are undefined
dc5fef6a 196 * if @a ma does not have the same size as this array.
7fb397a4
JQ
197 *
198 * @param ma Array slice to get values from.
199 */
54c1bf78 200 valarray<_Tp>& operator=(const mask_array<_Tp>&);
7fb397a4
JQ
201
202 /**
203 * @brief Assign elements to an array subset.
204 *
205 * Assign elements of array to values in @a ia. Results are undefined
dc5fef6a 206 * if @a ia does not have the same size as this array.
7fb397a4
JQ
207 *
208 * @param ia Array slice to get values from.
209 */
54c1bf78
BK
210 valarray<_Tp>& operator=(const indirect_array<_Tp>&);
211
212 template<class _Dom> valarray<_Tp>&
b714a419 213 operator= (const _Expr<_Dom, _Tp>&);
54c1bf78
BK
214
215 // _lib.valarray.access_ element access:
7fb397a4
JQ
216 /**
217 * Return a reference to the i'th array element.
218 *
7fb397a4
JQ
219 * @param i Index of element to return.
220 * @return Reference to the i'th element.
221 */
2787b59a 222 _Tp& operator[](size_t);
7fb397a4 223
2787b59a
PC
224 // _GLIBCXX_RESOLVE_LIB_DEFECTS
225 // 389. Const overload of valarray::operator[] returns by value.
226 const _Tp& operator[](size_t) const;
7fb397a4 227
54c1bf78 228 // _lib.valarray.sub_ subset operations:
7fb397a4
JQ
229 /**
230 * @brief Return an array subset.
231 *
232 * Returns a new valarray containing the elements of the array
dc5fef6a
VR
233 * indicated by the slice argument. The new valarray has the same size
234 * as the input slice. @see slice.
7fb397a4
JQ
235 *
236 * @param s The source slice.
237 * @return New valarray containing elements in @a s.
238 */
b714a419 239 _Expr<_SClos<_ValArray, _Tp>, _Tp> operator[](slice) const;
7fb397a4
JQ
240
241 /**
242 * @brief Return a reference to an array subset.
243 *
244 * Returns a new valarray containing the elements of the array
dc5fef6a
VR
245 * indicated by the slice argument. The new valarray has the same size
246 * as the input slice. @see slice.
7fb397a4
JQ
247 *
248 * @param s The source slice.
249 * @return New valarray containing elements in @a s.
250 */
54c1bf78 251 slice_array<_Tp> operator[](slice);
7fb397a4
JQ
252
253 /**
254 * @brief Return an array subset.
255 *
256 * Returns a slice_array referencing the elements of the array
257 * indicated by the slice argument. @see gslice.
258 *
259 * @param s The source slice.
260 * @return Slice_array referencing elements indicated by @a s.
261 */
b714a419 262 _Expr<_GClos<_ValArray, _Tp>, _Tp> operator[](const gslice&) const;
7fb397a4
JQ
263
264 /**
265 * @brief Return a reference to an array subset.
266 *
267 * Returns a new valarray containing the elements of the array
dc5fef6a
VR
268 * indicated by the gslice argument. The new valarray has
269 * the same size as the input gslice. @see gslice.
7fb397a4
JQ
270 *
271 * @param s The source gslice.
272 * @return New valarray containing elements in @a s.
273 */
54c1bf78 274 gslice_array<_Tp> operator[](const gslice&);
7fb397a4
JQ
275
276 /**
277 * @brief Return an array subset.
278 *
279 * Returns a new valarray containing the elements of the array
280 * indicated by the argument. The input is a valarray of bool which
281 * represents a bitmask indicating which elements should be copied into
282 * the new valarray. Each element of the array is added to the return
283 * valarray if the corresponding element of the argument is true.
284 *
285 * @param m The valarray bitmask.
286 * @return New valarray containing elements indicated by @a m.
287 */
b714a419 288 valarray<_Tp> operator[](const valarray<bool>&) const;
7fb397a4
JQ
289
290 /**
291 * @brief Return a reference to an array subset.
292 *
293 * Returns a new mask_array referencing the elements of the array
294 * indicated by the argument. The input is a valarray of bool which
295 * represents a bitmask indicating which elements are part of the
296 * subset. Elements of the array are part of the subset if the
297 * corresponding element of the argument is true.
298 *
299 * @param m The valarray bitmask.
300 * @return New valarray containing elements indicated by @a m.
301 */
54c1bf78 302 mask_array<_Tp> operator[](const valarray<bool>&);
7fb397a4
JQ
303
304 /**
305 * @brief Return an array subset.
306 *
307 * Returns a new valarray containing the elements of the array
308 * indicated by the argument. The elements in the argument are
309 * interpreted as the indices of elements of this valarray to copy to
310 * the return valarray.
311 *
312 * @param i The valarray element index list.
313 * @return New valarray containing elements in @a s.
314 */
54c1bf78 315 _Expr<_IClos<_ValArray, _Tp>, _Tp>
74d6b8ca 316 operator[](const valarray<size_t>&) const;
7fb397a4
JQ
317
318 /**
319 * @brief Return a reference to an array subset.
320 *
321 * Returns an indirect_array referencing the elements of the array
322 * indicated by the argument. The elements in the argument are
323 * interpreted as the indices of elements of this valarray to include
324 * in the subset. The returned indirect_array refers to these
325 * elements.
326 *
327 * @param i The valarray element index list.
328 * @return Indirect_array referencing elements in @a i.
329 */
54c1bf78
BK
330 indirect_array<_Tp> operator[](const valarray<size_t>&);
331
332 // _lib.valarray.unary_ unary operators:
7fb397a4 333 /// Return a new valarray by applying unary + to each element.
74d6b8ca 334 typename _UnaryOp<__unary_plus>::_Rt operator+() const;
7fb397a4
JQ
335
336 /// Return a new valarray by applying unary - to each element.
74d6b8ca 337 typename _UnaryOp<__negate>::_Rt operator-() const;
7fb397a4
JQ
338
339 /// Return a new valarray by applying unary ~ to each element.
74d6b8ca 340 typename _UnaryOp<__bitwise_not>::_Rt operator~() const;
7fb397a4
JQ
341
342 /// Return a new valarray by applying unary ! to each element.
74d6b8ca
GDR
343 typename _UnaryOp<__logical_not>::_Rt operator!() const;
344
54c1bf78 345 // _lib.valarray.cassign_ computed assignment:
7fb397a4 346 /// Multiply each element of array by @a t.
74d6b8ca 347 valarray<_Tp>& operator*=(const _Tp&);
7fb397a4
JQ
348
349 /// Divide each element of array by @a t.
74d6b8ca 350 valarray<_Tp>& operator/=(const _Tp&);
7fb397a4
JQ
351
352 /// Set each element e of array to e % @a t.
74d6b8ca 353 valarray<_Tp>& operator%=(const _Tp&);
7fb397a4
JQ
354
355 /// Add @a t to each element of array.
74d6b8ca 356 valarray<_Tp>& operator+=(const _Tp&);
7fb397a4
JQ
357
358 /// Subtract @a t to each element of array.
74d6b8ca 359 valarray<_Tp>& operator-=(const _Tp&);
7fb397a4
JQ
360
361 /// Set each element e of array to e ^ @a t.
74d6b8ca 362 valarray<_Tp>& operator^=(const _Tp&);
7fb397a4
JQ
363
364 /// Set each element e of array to e & @a t.
74d6b8ca 365 valarray<_Tp>& operator&=(const _Tp&);
7fb397a4
JQ
366
367 /// Set each element e of array to e | @a t.
74d6b8ca 368 valarray<_Tp>& operator|=(const _Tp&);
7fb397a4
JQ
369
370 /// Left shift each element e of array by @a t bits.
54c1bf78 371 valarray<_Tp>& operator<<=(const _Tp&);
7fb397a4
JQ
372
373 /// Right shift each element e of array by @a t bits.
54c1bf78 374 valarray<_Tp>& operator>>=(const _Tp&);
7fb397a4
JQ
375
376 /// Multiply elements of array by corresponding elements of @a v.
74d6b8ca 377 valarray<_Tp>& operator*=(const valarray<_Tp>&);
7fb397a4
JQ
378
379 /// Divide elements of array by corresponding elements of @a v.
74d6b8ca 380 valarray<_Tp>& operator/=(const valarray<_Tp>&);
7fb397a4
JQ
381
382 /// Modulo elements of array by corresponding elements of @a v.
74d6b8ca 383 valarray<_Tp>& operator%=(const valarray<_Tp>&);
7fb397a4
JQ
384
385 /// Add corresponding elements of @a v to elements of array.
74d6b8ca 386 valarray<_Tp>& operator+=(const valarray<_Tp>&);
7fb397a4
JQ
387
388 /// Subtract corresponding elements of @a v from elements of array.
74d6b8ca 389 valarray<_Tp>& operator-=(const valarray<_Tp>&);
7fb397a4
JQ
390
391 /// Logical xor corresponding elements of @a v with elements of array.
74d6b8ca 392 valarray<_Tp>& operator^=(const valarray<_Tp>&);
7fb397a4
JQ
393
394 /// Logical or corresponding elements of @a v with elements of array.
74d6b8ca 395 valarray<_Tp>& operator|=(const valarray<_Tp>&);
7fb397a4
JQ
396
397 /// Logical and corresponding elements of @a v with elements of array.
74d6b8ca 398 valarray<_Tp>& operator&=(const valarray<_Tp>&);
7fb397a4
JQ
399
400 /// Left shift elements of array by corresponding elements of @a v.
54c1bf78 401 valarray<_Tp>& operator<<=(const valarray<_Tp>&);
7fb397a4
JQ
402
403 /// Right shift elements of array by corresponding elements of @a v.
54c1bf78
BK
404 valarray<_Tp>& operator>>=(const valarray<_Tp>&);
405
406 template<class _Dom>
b714a419 407 valarray<_Tp>& operator*=(const _Expr<_Dom, _Tp>&);
54c1bf78 408 template<class _Dom>
b714a419 409 valarray<_Tp>& operator/=(const _Expr<_Dom, _Tp>&);
54c1bf78 410 template<class _Dom>
b714a419 411 valarray<_Tp>& operator%=(const _Expr<_Dom, _Tp>&);
54c1bf78 412 template<class _Dom>
b714a419 413 valarray<_Tp>& operator+=(const _Expr<_Dom, _Tp>&);
54c1bf78 414 template<class _Dom>
b714a419 415 valarray<_Tp>& operator-=(const _Expr<_Dom, _Tp>&);
54c1bf78 416 template<class _Dom>
b714a419 417 valarray<_Tp>& operator^=(const _Expr<_Dom, _Tp>&);
54c1bf78 418 template<class _Dom>
b714a419 419 valarray<_Tp>& operator|=(const _Expr<_Dom, _Tp>&);
54c1bf78 420 template<class _Dom>
b714a419 421 valarray<_Tp>& operator&=(const _Expr<_Dom, _Tp>&);
54c1bf78 422 template<class _Dom>
b714a419 423 valarray<_Tp>& operator<<=(const _Expr<_Dom, _Tp>&);
54c1bf78 424 template<class _Dom>
b714a419 425 valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&);
54c1bf78 426
54c1bf78 427 // _lib.valarray.members_ member functions:
7fb397a4 428 /// Return the number of elements in array.
54c1bf78 429 size_t size() const;
7fb397a4
JQ
430
431 /**
432 * @brief Return the sum of all elements in the array.
433 *
434 * Accumulates the sum of all elements into a Tp using +=. The order
435 * of adding the elements is unspecified.
436 */
437 _Tp sum() const;
438
439 /// Return the minimum element using operator<().
54c1bf78 440 _Tp min() const;
7fb397a4
JQ
441
442 /// Return the maximum element using operator<().
54c1bf78
BK
443 _Tp max() const;
444
7fb397a4
JQ
445 /**
446 * @brief Return a shifted array.
447 *
448 * A new valarray is constructed as a copy of this array with elements
449 * in shifted positions. For an element with index i, the new position
dc5fef6a
VR
450 * is i - n. The new valarray has the same size as the current one.
451 * New elements without a value are set to 0. Elements whose new
7fb397a4
JQ
452 * position is outside the bounds of the array are discarded.
453 *
454 * Positive arguments shift toward index 0, discarding elements [0, n).
455 * Negative arguments discard elements from the top of the array.
456 *
457 * @param n Number of element positions to shift.
458 * @return New valarray with elements in shifted positions.
459 */
54c1bf78 460 valarray<_Tp> shift (int) const;
7fb397a4
JQ
461
462 /**
463 * @brief Return a rotated array.
464 *
465 * A new valarray is constructed as a copy of this array with elements
466 * in shifted positions. For an element with index i, the new position
dc5fef6a 467 * is (i - n) % size(). The new valarray has the same size as the
7fb397a4
JQ
468 * current one. Elements that are shifted beyond the array bounds are
469 * shifted into the other end of the array. No elements are lost.
470 *
471 * Positive arguments shift toward index 0, wrapping around the top.
472 * Negative arguments shift towards the top, wrapping around to 0.
473 *
474 * @param n Number of element positions to rotate.
475 * @return New valarray with elements in shifted positions.
476 */
54c1bf78 477 valarray<_Tp> cshift(int) const;
7fb397a4
JQ
478
479 /**
480 * @brief Apply a function to the array.
481 *
482 * Returns a new valarray with elements assigned to the result of
483 * applying func to the corresponding element of this array. The new
dc5fef6a 484 * array has the same size as this one.
7fb397a4
JQ
485 *
486 * @param func Function of Tp returning Tp to apply.
487 * @return New valarray with transformed elements.
488 */
b714a419 489 _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(_Tp)) const;
7fb397a4
JQ
490
491 /**
492 * @brief Apply a function to the array.
493 *
494 * Returns a new valarray with elements assigned to the result of
495 * applying func to the corresponding element of this array. The new
dc5fef6a 496 * array has the same size as this one.
7fb397a4
JQ
497 *
498 * @param func Function of const Tp& returning Tp to apply.
499 * @return New valarray with transformed elements.
500 */
b714a419 501 _Expr<_RefFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(const _Tp&)) const;
7fb397a4
JQ
502
503 /**
504 * @brief Resize array.
505 *
dc5fef6a 506 * Resize this array to @a size and set all elements to @a c. All
7fb397a4
JQ
507 * references and iterators are invalidated.
508 *
509 * @param size New array size.
510 * @param c New value for all elements.
511 */
54c1bf78
BK
512 void resize(size_t __size, _Tp __c = _Tp());
513
74d6b8ca 514 private:
54c1bf78
BK
515 size_t _M_size;
516 _Tp* __restrict__ _M_data;
74d6b8ca 517
54c1bf78 518 friend class _Array<_Tp>;
74d6b8ca 519 };
54c1bf78
BK
520
521 template<typename _Tp>
74d6b8ca
GDR
522 inline const _Tp&
523 valarray<_Tp>::operator[](size_t __i) const
285b36d6
BK
524 {
525 __glibcxx_requires_subscript(__i);
b714a419 526 return _M_data[__i];
285b36d6 527 }
54c1bf78
BK
528
529 template<typename _Tp>
74d6b8ca
GDR
530 inline _Tp&
531 valarray<_Tp>::operator[](size_t __i)
285b36d6
BK
532 {
533 __glibcxx_requires_subscript(__i);
b714a419 534 return _M_data[__i];
285b36d6 535 }
54c1bf78 536
3cbc7af0 537_GLIBCXX_END_NAMESPACE
c13bea50
NS
538
539#include <bits/valarray_after.h>
54c1bf78
BK
540#include <bits/slice_array.h>
541#include <bits/gslice.h>
542#include <bits/gslice_array.h>
543#include <bits/mask_array.h>
544#include <bits/indirect_array.h>
545
3cbc7af0
BK
546_GLIBCXX_BEGIN_NAMESPACE(std)
547
54c1bf78 548 template<typename _Tp>
74d6b8ca
GDR
549 inline
550 valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {}
54c1bf78
BK
551
552 template<typename _Tp>
74d6b8ca
GDR
553 inline
554 valarray<_Tp>::valarray(size_t __n)
b714a419 555 : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
eb9a4231 556 { std::__valarray_default_construct(_M_data, _M_data + __n); }
54c1bf78
BK
557
558 template<typename _Tp>
74d6b8ca
GDR
559 inline
560 valarray<_Tp>::valarray(const _Tp& __t, size_t __n)
b714a419 561 : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
eb9a4231 562 { std::__valarray_fill_construct(_M_data, _M_data + __n, __t); }
54c1bf78
BK
563
564 template<typename _Tp>
74d6b8ca
GDR
565 inline
566 valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
b714a419 567 : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
285b36d6
BK
568 {
569 _GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0);
570 std::__valarray_copy_construct(__p, __p + __n, _M_data);
571 }
54c1bf78
BK
572
573 template<typename _Tp>
74d6b8ca
GDR
574 inline
575 valarray<_Tp>::valarray(const valarray<_Tp>& __v)
b714a419
PC
576 : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
577 { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
578 _M_data); }
54c1bf78
BK
579
580 template<typename _Tp>
74d6b8ca
GDR
581 inline
582 valarray<_Tp>::valarray(const slice_array<_Tp>& __sa)
b714a419 583 : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
74d6b8ca 584 {
6085dc49 585 std::__valarray_copy_construct
74d6b8ca
GDR
586 (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
587 }
54c1bf78
BK
588
589 template<typename _Tp>
74d6b8ca
GDR
590 inline
591 valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga)
b714a419
PC
592 : _M_size(__ga._M_index.size()),
593 _M_data(__valarray_get_storage<_Tp>(_M_size))
74d6b8ca 594 {
6085dc49 595 std::__valarray_copy_construct
74d6b8ca
GDR
596 (__ga._M_array, _Array<size_t>(__ga._M_index),
597 _Array<_Tp>(_M_data), _M_size);
598 }
54c1bf78
BK
599
600 template<typename _Tp>
74d6b8ca
GDR
601 inline
602 valarray<_Tp>::valarray(const mask_array<_Tp>& __ma)
b714a419 603 : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
74d6b8ca 604 {
6085dc49 605 std::__valarray_copy_construct
74d6b8ca
GDR
606 (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
607 }
54c1bf78
BK
608
609 template<typename _Tp>
74d6b8ca
GDR
610 inline
611 valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia)
b714a419 612 : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
74d6b8ca 613 {
6085dc49 614 std::__valarray_copy_construct
74d6b8ca
GDR
615 (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
616 }
54c1bf78
BK
617
618 template<typename _Tp> template<class _Dom>
74d6b8ca
GDR
619 inline
620 valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e)
b714a419 621 : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
6085dc49 622 { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); }
54c1bf78
BK
623
624 template<typename _Tp>
74d6b8ca
GDR
625 inline
626 valarray<_Tp>::~valarray()
627 {
eb9a4231
PC
628 std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
629 std::__valarray_release_memory(_M_data);
74d6b8ca 630 }
54c1bf78
BK
631
632 template<typename _Tp>
74d6b8ca
GDR
633 inline valarray<_Tp>&
634 valarray<_Tp>::operator=(const valarray<_Tp>& __v)
635 {
285b36d6 636 _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size);
eb9a4231 637 std::__valarray_copy(__v._M_data, _M_size, _M_data);
54c1bf78 638 return *this;
74d6b8ca 639 }
54c1bf78
BK
640
641 template<typename _Tp>
74d6b8ca
GDR
642 inline valarray<_Tp>&
643 valarray<_Tp>::operator=(const _Tp& __t)
644 {
eb9a4231 645 std::__valarray_fill(_M_data, _M_size, __t);
54c1bf78 646 return *this;
74d6b8ca 647 }
54c1bf78
BK
648
649 template<typename _Tp>
74d6b8ca
GDR
650 inline valarray<_Tp>&
651 valarray<_Tp>::operator=(const slice_array<_Tp>& __sa)
652 {
285b36d6 653 _GLIBCXX_DEBUG_ASSERT(_M_size == __sa._M_sz);
eb9a4231
PC
654 std::__valarray_copy(__sa._M_array, __sa._M_sz,
655 __sa._M_stride, _Array<_Tp>(_M_data));
54c1bf78 656 return *this;
74d6b8ca 657 }
54c1bf78
BK
658
659 template<typename _Tp>
74d6b8ca
GDR
660 inline valarray<_Tp>&
661 valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga)
662 {
285b36d6 663 _GLIBCXX_DEBUG_ASSERT(_M_size == __ga._M_index.size());
eb9a4231
PC
664 std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index),
665 _Array<_Tp>(_M_data), _M_size);
54c1bf78 666 return *this;
74d6b8ca 667 }
54c1bf78
BK
668
669 template<typename _Tp>
74d6b8ca
GDR
670 inline valarray<_Tp>&
671 valarray<_Tp>::operator=(const mask_array<_Tp>& __ma)
672 {
285b36d6 673 _GLIBCXX_DEBUG_ASSERT(_M_size == __ma._M_sz);
eb9a4231
PC
674 std::__valarray_copy(__ma._M_array, __ma._M_mask,
675 _Array<_Tp>(_M_data), _M_size);
54c1bf78 676 return *this;
74d6b8ca 677 }
54c1bf78
BK
678
679 template<typename _Tp>
74d6b8ca
GDR
680 inline valarray<_Tp>&
681 valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia)
682 {
285b36d6 683 _GLIBCXX_DEBUG_ASSERT(_M_size == __ia._M_sz);
eb9a4231
PC
684 std::__valarray_copy(__ia._M_array, __ia._M_index,
685 _Array<_Tp>(_M_data), _M_size);
54c1bf78 686 return *this;
74d6b8ca 687 }
54c1bf78
BK
688
689 template<typename _Tp> template<class _Dom>
74d6b8ca
GDR
690 inline valarray<_Tp>&
691 valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
692 {
285b36d6 693 _GLIBCXX_DEBUG_ASSERT(_M_size == __e.size());
eb9a4231
PC
694 std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
695 return *this;
74d6b8ca 696 }
54c1bf78
BK
697
698 template<typename _Tp>
74d6b8ca
GDR
699 inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
700 valarray<_Tp>::operator[](slice __s) const
701 {
54c1bf78 702 typedef _SClos<_ValArray,_Tp> _Closure;
74d6b8ca
GDR
703 return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s));
704 }
54c1bf78
BK
705
706 template<typename _Tp>
74d6b8ca
GDR
707 inline slice_array<_Tp>
708 valarray<_Tp>::operator[](slice __s)
b714a419 709 { return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); }
54c1bf78
BK
710
711 template<typename _Tp>
74d6b8ca
GDR
712 inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
713 valarray<_Tp>::operator[](const gslice& __gs) const
714 {
54c1bf78
BK
715 typedef _GClos<_ValArray,_Tp> _Closure;
716 return _Expr<_Closure, _Tp>
74d6b8ca
GDR
717 (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index));
718 }
54c1bf78
BK
719
720 template<typename _Tp>
74d6b8ca
GDR
721 inline gslice_array<_Tp>
722 valarray<_Tp>::operator[](const gslice& __gs)
723 {
54c1bf78 724 return gslice_array<_Tp>
74d6b8ca
GDR
725 (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
726 }
54c1bf78
BK
727
728 template<typename _Tp>
74d6b8ca
GDR
729 inline valarray<_Tp>
730 valarray<_Tp>::operator[](const valarray<bool>& __m) const
731 {
732 size_t __s = 0;
733 size_t __e = __m.size();
54c1bf78 734 for (size_t __i=0; __i<__e; ++__i)
74d6b8ca
GDR
735 if (__m[__i]) ++__s;
736 return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s,
737 _Array<bool> (__m)));
738 }
54c1bf78
BK
739
740 template<typename _Tp>
74d6b8ca
GDR
741 inline mask_array<_Tp>
742 valarray<_Tp>::operator[](const valarray<bool>& __m)
743 {
744 size_t __s = 0;
745 size_t __e = __m.size();
54c1bf78 746 for (size_t __i=0; __i<__e; ++__i)
74d6b8ca
GDR
747 if (__m[__i]) ++__s;
748 return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array<bool>(__m));
749 }
54c1bf78
BK
750
751 template<typename _Tp>
74d6b8ca
GDR
752 inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
753 valarray<_Tp>::operator[](const valarray<size_t>& __i) const
754 {
54c1bf78 755 typedef _IClos<_ValArray,_Tp> _Closure;
74d6b8ca
GDR
756 return _Expr<_Closure, _Tp>(_Closure(*this, __i));
757 }
54c1bf78
BK
758
759 template<typename _Tp>
74d6b8ca
GDR
760 inline indirect_array<_Tp>
761 valarray<_Tp>::operator[](const valarray<size_t>& __i)
762 {
763 return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(),
764 _Array<size_t>(__i));
765 }
54c1bf78
BK
766
767 template<class _Tp>
74d6b8ca
GDR
768 inline size_t
769 valarray<_Tp>::size() const
770 { return _M_size; }
54c1bf78
BK
771
772 template<class _Tp>
74d6b8ca
GDR
773 inline _Tp
774 valarray<_Tp>::sum() const
775 {
285b36d6 776 _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
eb9a4231 777 return std::__valarray_sum(_M_data, _M_data + _M_size);
74d6b8ca 778 }
54c1bf78 779
22d67c60 780 template<class _Tp>
54c1bf78
BK
781 inline valarray<_Tp>
782 valarray<_Tp>::shift(int __n) const
783 {
22d67c60 784 valarray<_Tp> __ret;
102693c7
PC
785
786 if (_M_size == 0)
787 return __ret;
788
22d67c60
PC
789 _Tp* __restrict__ __tmp_M_data =
790 std::__valarray_get_storage<_Tp>(_M_size);
791
102693c7
PC
792 if (__n == 0)
793 std::__valarray_copy_construct(_M_data,
794 _M_data + _M_size, __tmp_M_data);
795 else if (__n > 0) // shift left
8e768214
PC
796 {
797 if (size_t(__n) > _M_size)
226a2e08 798 __n = int(_M_size);
8e768214
PC
799
800 std::__valarray_copy_construct(_M_data + __n,
801 _M_data + _M_size, __tmp_M_data);
802 std::__valarray_default_construct(__tmp_M_data + _M_size - __n,
803 __tmp_M_data + _M_size);
804 }
102693c7 805 else // shift right
8e768214 806 {
226a2e08
PC
807 if (-size_t(__n) > _M_size)
808 __n = -int(_M_size);
8e768214
PC
809
810 std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
22d67c60 811 __tmp_M_data - __n);
8e768214 812 std::__valarray_default_construct(__tmp_M_data,
22d67c60 813 __tmp_M_data - __n);
8e768214 814 }
22d67c60
PC
815
816 __ret._M_size = _M_size;
817 __ret._M_data = __tmp_M_data;
818 return __ret;
54c1bf78
BK
819 }
820
22d67c60 821 template<class _Tp>
54c1bf78 822 inline valarray<_Tp>
22d67c60 823 valarray<_Tp>::cshift(int __n) const
54c1bf78 824 {
22d67c60 825 valarray<_Tp> __ret;
102693c7
PC
826
827 if (_M_size == 0)
828 return __ret;
829
22d67c60
PC
830 _Tp* __restrict__ __tmp_M_data =
831 std::__valarray_get_storage<_Tp>(_M_size);
102693c7
PC
832
833 if (__n == 0)
834 std::__valarray_copy_construct(_M_data,
835 _M_data + _M_size, __tmp_M_data);
836 else if (__n > 0) // cshift left
8e768214
PC
837 {
838 if (size_t(__n) > _M_size)
226a2e08 839 __n = int(__n % _M_size);
22d67c60 840
8e768214 841 std::__valarray_copy_construct(_M_data, _M_data + __n,
22d67c60 842 __tmp_M_data + _M_size - __n);
8e768214 843 std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size,
22d67c60 844 __tmp_M_data);
8e768214 845 }
102693c7 846 else // cshift right
8e768214 847 {
226a2e08
PC
848 if (-size_t(__n) > _M_size)
849 __n = -int(-size_t(__n) % _M_size);
8e768214
PC
850
851 std::__valarray_copy_construct(_M_data + _M_size + __n,
852 _M_data + _M_size, __tmp_M_data);
853 std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
854 __tmp_M_data - __n);
855 }
22d67c60
PC
856
857 __ret._M_size = _M_size;
858 __ret._M_data = __tmp_M_data;
859 return __ret;
54c1bf78
BK
860 }
861
22d67c60 862 template<class _Tp>
74d6b8ca 863 inline void
22d67c60 864 valarray<_Tp>::resize(size_t __n, _Tp __c)
74d6b8ca
GDR
865 {
866 // This complication is so to make valarray<valarray<T> > work
867 // even though it is not required by the standard. Nobody should
868 // be saying valarray<valarray<T> > anyway. See the specs.
eb9a4231 869 std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
74d6b8ca
GDR
870 if (_M_size != __n)
871 {
eb9a4231 872 std::__valarray_release_memory(_M_data);
74d6b8ca
GDR
873 _M_size = __n;
874 _M_data = __valarray_get_storage<_Tp>(__n);
875 }
eb9a4231 876 std::__valarray_fill_construct(_M_data, _M_data + __n, __c);
74d6b8ca 877 }
54c1bf78
BK
878
879 template<typename _Tp>
74d6b8ca
GDR
880 inline _Tp
881 valarray<_Tp>::min() const
882 {
285b36d6 883 _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
65be6ddd 884 return *std::min_element(_M_data, _M_data + _M_size);
74d6b8ca 885 }
54c1bf78
BK
886
887 template<typename _Tp>
74d6b8ca
GDR
888 inline _Tp
889 valarray<_Tp>::max() const
890 {
285b36d6 891 _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
65be6ddd 892 return *std::max_element(_M_data, _M_data + _M_size);
74d6b8ca 893 }
54c1bf78
BK
894
895 template<class _Tp>
b714a419 896 inline _Expr<_ValFunClos<_ValArray, _Tp>, _Tp>
74d6b8ca
GDR
897 valarray<_Tp>::apply(_Tp func(_Tp)) const
898 {
b714a419
PC
899 typedef _ValFunClos<_ValArray, _Tp> _Closure;
900 return _Expr<_Closure, _Tp>(_Closure(*this, func));
74d6b8ca 901 }
54c1bf78
BK
902
903 template<class _Tp>
b714a419 904 inline _Expr<_RefFunClos<_ValArray, _Tp>, _Tp>
74d6b8ca
GDR
905 valarray<_Tp>::apply(_Tp func(const _Tp &)) const
906 {
b714a419
PC
907 typedef _RefFunClos<_ValArray, _Tp> _Closure;
908 return _Expr<_Closure, _Tp>(_Closure(*this, func));
74d6b8ca 909 }
54c1bf78
BK
910
911#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
912 template<typename _Tp> \
b714a419
PC
913 inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
914 valarray<_Tp>::operator _Op() const \
915 { \
916 typedef _UnClos<_Name, _ValArray, _Tp> _Closure; \
917 typedef typename __fun<_Name, _Tp>::result_type _Rt; \
918 return _Expr<_Closure, _Rt>(_Closure(*this)); \
919 }
54c1bf78 920
74d6b8ca
GDR
921 _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus)
922 _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate)
923 _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not)
924 _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not)
54c1bf78
BK
925
926#undef _DEFINE_VALARRAY_UNARY_OPERATOR
54c1bf78
BK
927
928#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
929 template<class _Tp> \
971cfc6f
GDR
930 inline valarray<_Tp>& \
931 valarray<_Tp>::operator _Op##=(const _Tp &__t) \
932 { \
933 _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, __t); \
54c1bf78 934 return *this; \
971cfc6f 935 } \
54c1bf78
BK
936 \
937 template<class _Tp> \
971cfc6f
GDR
938 inline valarray<_Tp>& \
939 valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \
940 { \
285b36d6 941 _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); \
971cfc6f
GDR
942 _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \
943 _Array<_Tp>(__v._M_data)); \
54c1bf78 944 return *this; \
971cfc6f 945 }
54c1bf78 946
971cfc6f
GDR
947_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, __plus)
948_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, __minus)
949_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, __multiplies)
950_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, __divides)
951_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, __modulus)
952_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
953_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
954_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
955_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, __shift_left)
956_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right)
54c1bf78
BK
957
958#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT
959
54c1bf78
BK
960#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
961 template<class _Tp> template<class _Dom> \
971cfc6f 962 inline valarray<_Tp>& \
b714a419 963 valarray<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) \
971cfc6f
GDR
964 { \
965 _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \
54c1bf78 966 return *this; \
971cfc6f 967 }
54c1bf78 968
971cfc6f
GDR
969_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, __plus)
970_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, __minus)
971_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, __multiplies)
972_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, __divides)
973_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, __modulus)
974_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
975_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
976_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
977_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left)
978_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
54c1bf78
BK
979
980#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT
981
982
983#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
984 template<typename _Tp> \
b714a419 985 inline _Expr<_BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp>, \
971cfc6f
GDR
986 typename __fun<_Name, _Tp>::result_type> \
987 operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
988 { \
285b36d6 989 _GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \
b714a419 990 typedef _BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
971cfc6f
GDR
991 typedef typename __fun<_Name, _Tp>::result_type _Rt; \
992 return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \
993 } \
54c1bf78
BK
994 \
995 template<typename _Tp> \
b714a419
PC
996 inline _Expr<_BinClos<_Name, _ValArray,_Constant, _Tp, _Tp>, \
997 typename __fun<_Name, _Tp>::result_type> \
998 operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \
999 { \
1000 typedef _BinClos<_Name, _ValArray, _Constant, _Tp, _Tp> _Closure; \
1001 typedef typename __fun<_Name, _Tp>::result_type _Rt; \
1002 return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \
1003 } \
54c1bf78
BK
1004 \
1005 template<typename _Tp> \
b714a419
PC
1006 inline _Expr<_BinClos<_Name, _Constant, _ValArray, _Tp, _Tp>, \
1007 typename __fun<_Name, _Tp>::result_type> \
1008 operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \
1009 { \
1010 typedef _BinClos<_Name, _Constant, _ValArray, _Tp, _Tp> _Closure; \
1011 typedef typename __fun<_Name, _Tp>::result_type _Rt; \
5837d3c8 1012 return _Expr<_Closure, _Rt>(_Closure(__t, __v)); \
b714a419 1013 }
54c1bf78 1014
971cfc6f
GDR
1015_DEFINE_BINARY_OPERATOR(+, __plus)
1016_DEFINE_BINARY_OPERATOR(-, __minus)
1017_DEFINE_BINARY_OPERATOR(*, __multiplies)
1018_DEFINE_BINARY_OPERATOR(/, __divides)
1019_DEFINE_BINARY_OPERATOR(%, __modulus)
1020_DEFINE_BINARY_OPERATOR(^, __bitwise_xor)
1021_DEFINE_BINARY_OPERATOR(&, __bitwise_and)
1022_DEFINE_BINARY_OPERATOR(|, __bitwise_or)
1023_DEFINE_BINARY_OPERATOR(<<, __shift_left)
1024_DEFINE_BINARY_OPERATOR(>>, __shift_right)
1025_DEFINE_BINARY_OPERATOR(&&, __logical_and)
1026_DEFINE_BINARY_OPERATOR(||, __logical_or)
1027_DEFINE_BINARY_OPERATOR(==, __equal_to)
1028_DEFINE_BINARY_OPERATOR(!=, __not_equal_to)
1029_DEFINE_BINARY_OPERATOR(<, __less)
1030_DEFINE_BINARY_OPERATOR(>, __greater)
1031_DEFINE_BINARY_OPERATOR(<=, __less_equal)
1032_DEFINE_BINARY_OPERATOR(>=, __greater_equal)
54c1bf78 1033
bcc4a44f
PC
1034#undef _DEFINE_BINARY_OPERATOR
1035
3cbc7af0 1036_GLIBCXX_END_NAMESPACE
54c1bf78 1037
1143680e 1038#endif /* _GLIBCXX_VALARRAY */