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