summaryrefslogtreecommitdiffstats
path: root/contrib/libstdc++/include/std/std_valarray.h
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2007-05-19 01:25:07 +0000
committerkan <kan@FreeBSD.org>2007-05-19 01:25:07 +0000
commit7865836f4b0f698454c31b4593effcb032c22c1e (patch)
treeea6c2718dc1e45ed535d194df808ef31f0ebac92 /contrib/libstdc++/include/std/std_valarray.h
parent1f9ea4d0a40cca64d60cf4dab152349da7b9dddf (diff)
downloadFreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.zip
FreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.tar.gz
GCC 4.2.0 release C++ standard library and runtime support code.
Diffstat (limited to 'contrib/libstdc++/include/std/std_valarray.h')
-rw-r--r--contrib/libstdc++/include/std/std_valarray.h338
1 files changed, 180 insertions, 158 deletions
diff --git a/contrib/libstdc++/include/std/std_valarray.h b/contrib/libstdc++/include/std/std_valarray.h
index b893b33..87f30ec 100644
--- a/contrib/libstdc++/include/std/std_valarray.h
+++ b/contrib/libstdc++/include/std/std_valarray.h
@@ -1,6 +1,6 @@
// The template and inlines for the -*- C++ -*- valarray class.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
// As a special exception, you may use this file as part of a free software
@@ -28,13 +28,12 @@
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
-// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
-
/** @file valarray
- * This is a Standard C++ Library header. You should @c #include this header
- * in your programs, rather than any of the "st[dl]_*.h" implementation files.
+ * This is a Standard C++ Library header.
*/
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
#ifndef _GLIBCXX_VALARRAY
#define _GLIBCXX_VALARRAY 1
@@ -48,8 +47,8 @@
#include <algorithm>
#include <debug/debug.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
template<class _Clos, typename _Tp>
class _Expr;
@@ -88,13 +87,13 @@ namespace std
template<class _Tp> class mask_array; // masked array
template<class _Tp> class indirect_array; // indirected array
-} // namespace std
+_GLIBCXX_END_NAMESPACE
#include <bits/valarray_array.h>
#include <bits/valarray_before.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
/**
* @brief Smart array designed to support numeric processing.
*
@@ -147,7 +146,8 @@ namespace std
valarray(const indirect_array<_Tp>&);
template<class _Dom>
- valarray(const _Expr<_Dom,_Tp>& __e);
+ valarray(const _Expr<_Dom, _Tp>& __e);
+
~valarray();
// _lib.valarray.assign_ assignment:
@@ -155,7 +155,7 @@ namespace std
* @brief Assign elements to an array.
*
* Assign elements of array to values in @a v. Results are undefined
- * if @a v is not the same size as this array.
+ * if @a v does not have the same size as this array.
*
* @param v Valarray to get values from.
*/
@@ -174,7 +174,7 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a sa. Results are undefined
- * if @a sa is not the same size as this array.
+ * if @a sa does not have the same size as this array.
*
* @param sa Array slice to get values from.
*/
@@ -184,7 +184,7 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a ga. Results are undefined
- * if @a ga is not the same size as this array.
+ * if @a ga does not have the same size as this array.
*
* @param ga Array slice to get values from.
*/
@@ -194,7 +194,7 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a ma. Results are undefined
- * if @a ma is not the same size as this array.
+ * if @a ma does not have the same size as this array.
*
* @param ma Array slice to get values from.
*/
@@ -204,14 +204,14 @@ namespace std
* @brief Assign elements to an array subset.
*
* Assign elements of array to values in @a ia. Results are undefined
- * if @a ia is not the same size as this array.
+ * if @a ia does not have the same size as this array.
*
* @param ia Array slice to get values from.
*/
valarray<_Tp>& operator=(const indirect_array<_Tp>&);
template<class _Dom> valarray<_Tp>&
- operator= (const _Expr<_Dom,_Tp>&);
+ operator= (const _Expr<_Dom, _Tp>&);
// _lib.valarray.access_ element access:
/**
@@ -231,20 +231,20 @@ namespace std
* @brief Return an array subset.
*
* Returns a new valarray containing the elements of the array
- * indicated by the slice argument. The new valarray is the size of
- * the input slice. @see slice.
+ * indicated by the slice argument. The new valarray has the same size
+ * as the input slice. @see slice.
*
* @param s The source slice.
* @return New valarray containing elements in @a s.
*/
- _Expr<_SClos<_ValArray,_Tp>, _Tp> operator[](slice) const;
+ _Expr<_SClos<_ValArray, _Tp>, _Tp> operator[](slice) const;
/**
* @brief Return a reference to an array subset.
*
* Returns a new valarray containing the elements of the array
- * indicated by the slice argument. The new valarray is the size of
- * the input slice. @see slice.
+ * indicated by the slice argument. The new valarray has the same size
+ * as the input slice. @see slice.
*
* @param s The source slice.
* @return New valarray containing elements in @a s.
@@ -260,14 +260,14 @@ namespace std
* @param s The source slice.
* @return Slice_array referencing elements indicated by @a s.
*/
- _Expr<_GClos<_ValArray,_Tp>, _Tp> operator[](const gslice&) const;
+ _Expr<_GClos<_ValArray, _Tp>, _Tp> operator[](const gslice&) const;
/**
* @brief Return a reference to an array subset.
*
* Returns a new valarray containing the elements of the array
- * indicated by the gslice argument. The new valarray is
- * the size of the input gslice. @see gslice.
+ * indicated by the gslice argument. The new valarray has
+ * the same size as the input gslice. @see gslice.
*
* @param s The source gslice.
* @return New valarray containing elements in @a s.
@@ -286,7 +286,7 @@ namespace std
* @param m The valarray bitmask.
* @return New valarray containing elements indicated by @a m.
*/
- valarray<_Tp> operator[](const valarray<bool>&) const;
+ valarray<_Tp> operator[](const valarray<bool>&) const;
/**
* @brief Return a reference to an array subset.
@@ -405,26 +405,25 @@ namespace std
valarray<_Tp>& operator>>=(const valarray<_Tp>&);
template<class _Dom>
- valarray<_Tp>& operator*=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator*=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator/=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator/=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator%=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator%=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator+=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator+=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator-=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator-=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator^=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator^=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator|=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator|=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator&=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator&=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
+ valarray<_Tp>& operator<<=(const _Expr<_Dom, _Tp>&);
template<class _Dom>
- valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
-
+ valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&);
// _lib.valarray.members_ member functions:
/// Return the number of elements in array.
@@ -444,16 +443,13 @@ namespace std
/// Return the maximum element using operator<().
_Tp max() const;
- // // FIXME: Extension
- // _Tp product () const;
-
/**
* @brief Return a shifted array.
*
* A new valarray is constructed as a copy of this array with elements
* in shifted positions. For an element with index i, the new position
- * is i - n. The new valarray is the same size as the current one.
- * New elements without a value are set to 0. Elements whos new
+ * is i - n. The new valarray has the same size as the current one.
+ * New elements without a value are set to 0. Elements whose new
* position is outside the bounds of the array are discarded.
*
* Positive arguments shift toward index 0, discarding elements [0, n).
@@ -469,7 +465,7 @@ namespace std
*
* A new valarray is constructed as a copy of this array with elements
* in shifted positions. For an element with index i, the new position
- * is (i - n) % size(). The new valarray is the same size as the
+ * is (i - n) % size(). The new valarray has the same size as the
* current one. Elements that are shifted beyond the array bounds are
* shifted into the other end of the array. No elements are lost.
*
@@ -486,29 +482,29 @@ namespace std
*
* Returns a new valarray with elements assigned to the result of
* applying func to the corresponding element of this array. The new
- * array is the same size as this one.
+ * array has the same size as this one.
*
* @param func Function of Tp returning Tp to apply.
* @return New valarray with transformed elements.
*/
- _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(_Tp)) const;
+ _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(_Tp)) const;
/**
* @brief Apply a function to the array.
*
* Returns a new valarray with elements assigned to the result of
* applying func to the corresponding element of this array. The new
- * array is the same size as this one.
+ * array has the same size as this one.
*
* @param func Function of const Tp& returning Tp to apply.
* @return New valarray with transformed elements.
*/
- _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
+ _Expr<_RefFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(const _Tp&)) const;
/**
* @brief Resize array.
*
- * Resize this array to be @a size and set all elements to @a c. All
+ * Resize this array to @a size and set all elements to @a c. All
* references and iterators are invalidated.
*
* @param size New array size.
@@ -528,7 +524,7 @@ namespace std
valarray<_Tp>::operator[](size_t __i) const
{
__glibcxx_requires_subscript(__i);
- return _M_data[__i];
+ return _M_data[__i];
}
template<typename _Tp>
@@ -536,21 +532,20 @@ namespace std
valarray<_Tp>::operator[](size_t __i)
{
__glibcxx_requires_subscript(__i);
- return _M_data[__i];
+ return _M_data[__i];
}
-} // std::
+_GLIBCXX_END_NAMESPACE
#include <bits/valarray_after.h>
-
#include <bits/slice_array.h>
#include <bits/gslice.h>
#include <bits/gslice_array.h>
#include <bits/mask_array.h>
#include <bits/indirect_array.h>
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
template<typename _Tp>
inline
valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {}
@@ -558,19 +553,19 @@ namespace std
template<typename _Tp>
inline
valarray<_Tp>::valarray(size_t __n)
- : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{ std::__valarray_default_construct(_M_data, _M_data + __n); }
template<typename _Tp>
inline
valarray<_Tp>::valarray(const _Tp& __t, size_t __n)
- : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{ std::__valarray_fill_construct(_M_data, _M_data + __n, __t); }
template<typename _Tp>
inline
valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
- : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
{
_GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0);
std::__valarray_copy_construct(__p, __p + __n, _M_data);
@@ -579,25 +574,26 @@ namespace std
template<typename _Tp>
inline
valarray<_Tp>::valarray(const valarray<_Tp>& __v)
- : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
- { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size, _M_data); }
+ : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
+ { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
+ _M_data); }
template<typename _Tp>
inline
valarray<_Tp>::valarray(const slice_array<_Tp>& __sa)
- : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
+ : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
}
template<typename _Tp>
inline
valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga)
- : _M_size(__ga._M_index.size()),
- _M_data(__valarray_get_storage<_Tp>(_M_size))
+ : _M_size(__ga._M_index.size()),
+ _M_data(__valarray_get_storage<_Tp>(_M_size))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__ga._M_array, _Array<size_t>(__ga._M_index),
_Array<_Tp>(_M_data), _M_size);
}
@@ -605,26 +601,26 @@ namespace std
template<typename _Tp>
inline
valarray<_Tp>::valarray(const mask_array<_Tp>& __ma)
- : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
+ : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
}
template<typename _Tp>
inline
valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia)
- : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
+ : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
{
- std::__valarray_copy
+ std::__valarray_copy_construct
(__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
}
template<typename _Tp> template<class _Dom>
inline
valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e)
- : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
- { std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); }
+ : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
+ { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); }
template<typename _Tp>
inline
@@ -711,9 +707,7 @@ namespace std
template<typename _Tp>
inline slice_array<_Tp>
valarray<_Tp>::operator[](slice __s)
- {
- return slice_array<_Tp>(_Array<_Tp>(_M_data), __s);
- }
+ { return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); }
template<typename _Tp>
inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
@@ -784,65 +778,91 @@ namespace std
return std::__valarray_sum(_M_data, _M_data + _M_size);
}
-// template<typename _Tp>
-// inline _Tp
-// valarray<_Tp>::product () const
-// {
-// return __valarray_product(_M_data, _M_data + _M_size);
-// }
-
- template <class _Tp>
+ template<class _Tp>
inline valarray<_Tp>
valarray<_Tp>::shift(int __n) const
{
- _Tp* const __a = static_cast<_Tp*>
- (__builtin_alloca(sizeof(_Tp) * _M_size));
- if (__n == 0) // no shift
- std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a);
- else if (__n > 0) // __n > 0: shift left
- {
- if (size_t(__n) > _M_size)
- std::__valarray_default_construct(__a, __a + __n);
- else
- {
- std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
- std::__valarray_default_construct(__a+_M_size-__n, __a + _M_size);
- }
- }
- else // __n < 0: shift right
- {
- std::__valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n);
- std::__valarray_default_construct(__a, __a - __n);
- }
- return valarray<_Tp> (__a, _M_size);
+ valarray<_Tp> __ret;
+
+ if (_M_size == 0)
+ return __ret;
+
+ _Tp* __restrict__ __tmp_M_data =
+ std::__valarray_get_storage<_Tp>(_M_size);
+
+ if (__n == 0)
+ std::__valarray_copy_construct(_M_data,
+ _M_data + _M_size, __tmp_M_data);
+ else if (__n > 0) // shift left
+ {
+ if (size_t(__n) > _M_size)
+ __n = _M_size;
+
+ std::__valarray_copy_construct(_M_data + __n,
+ _M_data + _M_size, __tmp_M_data);
+ std::__valarray_default_construct(__tmp_M_data + _M_size - __n,
+ __tmp_M_data + _M_size);
+ }
+ else // shift right
+ {
+ if (size_t(-__n) > _M_size)
+ __n = -_M_size;
+
+ std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
+ __tmp_M_data - __n);
+ std::__valarray_default_construct(__tmp_M_data,
+ __tmp_M_data - __n);
+ }
+
+ __ret._M_size = _M_size;
+ __ret._M_data = __tmp_M_data;
+ return __ret;
}
- template <class _Tp>
+ template<class _Tp>
inline valarray<_Tp>
- valarray<_Tp>::cshift (int __n) const
+ valarray<_Tp>::cshift(int __n) const
{
- _Tp* const __a = static_cast<_Tp*>
- (__builtin_alloca (sizeof(_Tp) * _M_size));
- if (__n == 0) // no cshift
- std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a);
- else if (__n > 0) // cshift left
- {
- std::__valarray_copy_construct(_M_data, _M_data+__n, __a+_M_size-__n);
- std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a);
- }
- else // cshift right
- {
- std::__valarray_copy_construct
- (_M_data + _M_size+__n, _M_data + _M_size, __a);
- std::__valarray_copy_construct
- (_M_data, _M_data + _M_size+__n, __a - __n);
- }
- return valarray<_Tp>(__a, _M_size);
+ valarray<_Tp> __ret;
+
+ if (_M_size == 0)
+ return __ret;
+
+ _Tp* __restrict__ __tmp_M_data =
+ std::__valarray_get_storage<_Tp>(_M_size);
+
+ if (__n == 0)
+ std::__valarray_copy_construct(_M_data,
+ _M_data + _M_size, __tmp_M_data);
+ else if (__n > 0) // cshift left
+ {
+ if (size_t(__n) > _M_size)
+ __n = __n % _M_size;
+
+ std::__valarray_copy_construct(_M_data, _M_data + __n,
+ __tmp_M_data + _M_size - __n);
+ std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size,
+ __tmp_M_data);
+ }
+ else // cshift right
+ {
+ if (size_t(-__n) > _M_size)
+ __n = -(size_t(-__n) % _M_size);
+
+ std::__valarray_copy_construct(_M_data + _M_size + __n,
+ _M_data + _M_size, __tmp_M_data);
+ std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
+ __tmp_M_data - __n);
+ }
+
+ __ret._M_size = _M_size;
+ __ret._M_data = __tmp_M_data;
+ return __ret;
}
- template <class _Tp>
+ template<class _Tp>
inline void
- valarray<_Tp>::resize (size_t __n, _Tp __c)
+ valarray<_Tp>::resize(size_t __n, _Tp __c)
{
// This complication is so to make valarray<valarray<T> > work
// even though it is not required by the standard. Nobody should
@@ -862,7 +882,7 @@ namespace std
valarray<_Tp>::min() const
{
_GLIBCXX_DEBUG_ASSERT(_M_size > 0);
- return *std::min_element (_M_data, _M_data+_M_size);
+ return *std::min_element(_M_data, _M_data+_M_size);
}
template<typename _Tp>
@@ -870,34 +890,34 @@ namespace std
valarray<_Tp>::max() const
{
_GLIBCXX_DEBUG_ASSERT(_M_size > 0);
- return *std::max_element (_M_data, _M_data+_M_size);
+ return *std::max_element(_M_data, _M_data+_M_size);
}
template<class _Tp>
- inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp>
+ inline _Expr<_ValFunClos<_ValArray, _Tp>, _Tp>
valarray<_Tp>::apply(_Tp func(_Tp)) const
{
- typedef _ValFunClos<_ValArray,_Tp> _Closure;
- return _Expr<_Closure,_Tp>(_Closure(*this, func));
+ typedef _ValFunClos<_ValArray, _Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure(*this, func));
}
template<class _Tp>
- inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp>
+ inline _Expr<_RefFunClos<_ValArray, _Tp>, _Tp>
valarray<_Tp>::apply(_Tp func(const _Tp &)) const
{
- typedef _RefFunClos<_ValArray,_Tp> _Closure;
- return _Expr<_Closure,_Tp>(_Closure(*this, func));
+ typedef _RefFunClos<_ValArray, _Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure(*this, func));
}
#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
- inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
- valarray<_Tp>::operator _Op() const \
- { \
- typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
- typedef typename __fun<_Name, _Tp>::result_type _Rt; \
- return _Expr<_Closure, _Rt>(_Closure(*this)); \
- }
+ inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
+ valarray<_Tp>::operator _Op() const \
+ { \
+ typedef _UnClos<_Name, _ValArray, _Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(*this)); \
+ }
_DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus)
_DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate)
@@ -941,7 +961,7 @@ _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
template<class _Tp> template<class _Dom> \
inline valarray<_Tp>& \
- valarray<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) \
+ valarray<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) \
{ \
_Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \
return *this; \
@@ -963,35 +983,35 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp>, \
+ inline _Expr<_BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp>, \
typename __fun<_Name, _Tp>::result_type> \
operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
{ \
_GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \
- typedef _BinClos<_Name,_ValArray,_ValArray,_Tp,_Tp> _Closure; \
+ typedef _BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
typedef typename __fun<_Name, _Tp>::result_type _Rt; \
return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \
} \
\
template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>, \
- typename __fun<_Name, _Tp>::result_type> \
- operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \
- { \
- typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \
- typedef typename __fun<_Name, _Tp>::result_type _Rt; \
- return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \
- } \
+ inline _Expr<_BinClos<_Name, _ValArray,_Constant, _Tp, _Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \
+ { \
+ typedef _BinClos<_Name, _ValArray, _Constant, _Tp, _Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \
+ } \
\
template<typename _Tp> \
- inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>, \
- typename __fun<_Name, _Tp>::result_type> \
- operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \
- { \
- typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \
- typedef typename __fun<_Name, _Tp>::result_type _Rt; \
- return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
- }
+ inline _Expr<_BinClos<_Name, _Constant, _ValArray, _Tp, _Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \
+ { \
+ typedef _BinClos<_Name, _Constant, _ValArray, _Tp, _Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
+ }
_DEFINE_BINARY_OPERATOR(+, __plus)
_DEFINE_BINARY_OPERATOR(-, __minus)
@@ -1012,6 +1032,8 @@ _DEFINE_BINARY_OPERATOR(>, __greater)
_DEFINE_BINARY_OPERATOR(<=, __less_equal)
_DEFINE_BINARY_OPERATOR(>=, __greater_equal)
-} // namespace std
+#undef _DEFINE_BINARY_OPERATOR
+
+_GLIBCXX_END_NAMESPACE
#endif /* _GLIBCXX_VALARRAY */
OpenPOWER on IntegriCloud