Commit b714a419 by Paolo Carlini Committed by Paolo Carlini

gslice.h: Trivial formatting fixes.

2004-07-08  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/gslice.h: Trivial formatting fixes.
	* include/bits/gslice_array.h: Likewise.
	* include/bits/indirect_array.h: Likewise.
	* include/bits/mask_array.h: Likewise.
	* include/bits/slice_array.h: Likewise.
	* include/bits/valarray_after.h: Likewise.
	* include/bits/valarray_array.h: Likewise.
	* include/bits/valarray_before.h: Likewise.
	* include/std/std_valarray.h: Likewise.

From-SVN: r84312
parent d222b827
2004-07-08 Paolo Carlini <pcarlini@suse.de>
* include/bits/gslice.h: Trivial formatting fixes.
* include/bits/gslice_array.h: Likewise.
* include/bits/indirect_array.h: Likewise.
* include/bits/mask_array.h: Likewise.
* include/bits/slice_array.h: Likewise.
* include/bits/valarray_after.h: Likewise.
* include/bits/valarray_array.h: Likewise.
* include/bits/valarray_before.h: Likewise.
* include/std/std_valarray.h: Likewise.
2004-07-08 Benjamin Kosnik <bkoz@redhat.com> 2004-07-08 Benjamin Kosnik <bkoz@redhat.com>
PR c++/16169 PR c++/16169
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#pragma GCC system_header #pragma GCC system_header
namespace std { namespace std
{
/** /**
* @brief Class defining multi-dimensional subset of an array. * @brief Class defining multi-dimensional subset of an array.
* *
...@@ -101,7 +101,8 @@ namespace std { ...@@ -101,7 +101,8 @@ namespace std {
valarray<size_t> stride() const; valarray<size_t> stride() const;
private: private:
struct _Indexer { struct _Indexer
{
size_t _M_count; size_t _M_count;
size_t _M_start; size_t _M_start;
valarray<size_t> _M_size; valarray<size_t> _M_size;
...@@ -109,8 +110,13 @@ namespace std { ...@@ -109,8 +110,13 @@ namespace std {
valarray<size_t> _M_index; // Linear array of referenced indices valarray<size_t> _M_index; // Linear array of referenced indices
_Indexer(size_t, const valarray<size_t>&, _Indexer(size_t, const valarray<size_t>&,
const valarray<size_t>&); const valarray<size_t>&);
void _M_increment_use() { ++_M_count; } void
size_t _M_decrement_use() { return --_M_count; } _M_increment_use()
{ ++_M_count; }
size_t
_M_decrement_use()
{ return --_M_count; }
}; };
_Indexer* _M_index; _Indexer* _M_index;
...@@ -143,21 +149,24 @@ namespace std { ...@@ -143,21 +149,24 @@ namespace std {
inline inline
gslice::~gslice() gslice::~gslice()
{ if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; } {
if (_M_index && _M_index->_M_decrement_use() == 0)
delete _M_index;
}
inline gslice& inline gslice&
gslice::operator= (const gslice& __g) gslice::operator= (const gslice& __g)
{ {
if (__g._M_index) __g._M_index->_M_increment_use(); if (__g._M_index)
if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; __g._M_index->_M_increment_use();
if (_M_index && _M_index->_M_decrement_use() == 0)
delete _M_index;
_M_index = __g._M_index; _M_index = __g._M_index;
return *this; return *this;
} }
} // std:: } // std::
#endif /* _GSLICE_H */ #endif /* _GSLICE_H */
// Local Variables: // Local Variables:
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#pragma GCC system_header #pragma GCC system_header
namespace std { namespace std
{
/** /**
* @brief Reference to multi-dimensional subset of an array. * @brief Reference to multi-dimensional subset of an array.
* *
...@@ -97,27 +97,27 @@ namespace std { ...@@ -97,27 +97,27 @@ namespace std {
void operator=(const _Tp&) const; void operator=(const _Tp&) const;
template<class _Dom> template<class _Dom>
void operator=(const _Expr<_Dom,_Tp>&) const; void operator=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator*=(const _Expr<_Dom,_Tp>&) const; void operator*=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator/=(const _Expr<_Dom,_Tp>&) const; void operator/=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator%=(const _Expr<_Dom,_Tp>&) const; void operator%=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator+=(const _Expr<_Dom,_Tp>&) const; void operator+=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator-=(const _Expr<_Dom,_Tp>&) const; void operator-=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator^=(const _Expr<_Dom,_Tp>&) const; void operator^=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator&=(const _Expr<_Dom,_Tp>&) const; void operator&=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator|=(const _Expr<_Dom,_Tp>&) const; void operator|=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator<<=(const _Expr<_Dom,_Tp>&) const; void operator<<=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator>>=(const _Expr<_Dom,_Tp>&) const; void operator>>=(const _Expr<_Dom, _Tp>&) const;
private: private:
_Array<_Tp> _M_array; _Array<_Tp> _M_array;
...@@ -137,13 +137,11 @@ namespace std { ...@@ -137,13 +137,11 @@ namespace std {
const valarray<size_t>& __i) const valarray<size_t>& __i)
: _M_array(__a), _M_index(__i) {} : _M_array(__a), _M_index(__i) {}
template<typename _Tp> template<typename _Tp>
inline inline
gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a) gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a)
: _M_array(__a._M_array), _M_index(__a._M_index) {} : _M_array(__a._M_array), _M_index(__a._M_index) {}
template<typename _Tp> template<typename _Tp>
inline gslice_array<_Tp>& inline gslice_array<_Tp>&
gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a) gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a)
......
...@@ -156,7 +156,6 @@ namespace std ...@@ -156,7 +156,6 @@ namespace std
return *this; return *this;
} }
template<typename _Tp> template<typename _Tp>
inline void inline void
indirect_array<_Tp>::operator=(const _Tp& __t) const indirect_array<_Tp>::operator=(const _Tp& __t) const
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#pragma GCC system_header #pragma GCC system_header
namespace std { namespace std
{
/** /**
* @brief Reference to selected subset of an array. * @brief Reference to selected subset of an array.
* *
...@@ -134,7 +134,6 @@ namespace std { ...@@ -134,7 +134,6 @@ namespace std {
mask_array(); mask_array();
}; };
template<typename _Tp> template<typename _Tp>
inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& a) inline mask_array<_Tp>::mask_array(const mask_array<_Tp>& a)
: _M_sz(a._M_sz), _M_mask(a._M_mask), _M_array(a._M_array) {} : _M_sz(a._M_sz), _M_mask(a._M_mask), _M_array(a._M_array) {}
......
...@@ -160,27 +160,27 @@ namespace std ...@@ -160,27 +160,27 @@ namespace std
// ~slice_array (); // ~slice_array ();
template<class _Dom> template<class _Dom>
void operator=(const _Expr<_Dom,_Tp>&) const; void operator=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator*=(const _Expr<_Dom,_Tp>&) const; void operator*=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator/=(const _Expr<_Dom,_Tp>&) const; void operator/=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator%=(const _Expr<_Dom,_Tp>&) const; void operator%=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator+=(const _Expr<_Dom,_Tp>&) const; void operator+=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator-=(const _Expr<_Dom,_Tp>&) const; void operator-=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator^=(const _Expr<_Dom,_Tp>&) const; void operator^=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator&=(const _Expr<_Dom,_Tp>&) const; void operator&=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator|=(const _Expr<_Dom,_Tp>&) const; void operator|=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator<<=(const _Expr<_Dom,_Tp>&) const; void operator<<=(const _Expr<_Dom, _Tp>&) const;
template<class _Dom> template<class _Dom>
void operator>>=(const _Expr<_Dom,_Tp>&) const; void operator>>=(const _Expr<_Dom, _Tp>&) const;
private: private:
friend class valarray<_Tp>; friend class valarray<_Tp>;
......
// The template and inlines for the -*- C++ -*- internal _Meta class. // The template and inlines for the -*- C++ -*- internal _Meta class.
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -41,41 +42,57 @@ ...@@ -41,41 +42,57 @@
namespace std namespace std
{ {
// //
// gslice_array closure. // gslice_array closure.
// //
template<class _Dom> class _GBase { template<class _Dom>
class _GBase
{
public: public:
typedef typename _Dom::value_type value_type; typedef typename _Dom::value_type value_type;
_GBase (const _Dom& __e, const valarray<size_t>& __i) _GBase (const _Dom& __e, const valarray<size_t>& __i)
: _M_expr (__e), _M_index(__i) {} : _M_expr (__e), _M_index(__i) {}
value_type operator[] (size_t __i) const
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_index[__i]]; } { return _M_expr[_M_index[__i]]; }
size_t size () const { return _M_index.size(); }
size_t
size () const
{ return _M_index.size(); }
private: private:
const _Dom& _M_expr; const _Dom& _M_expr;
const valarray<size_t>& _M_index; const valarray<size_t>& _M_index;
}; };
template<typename _Tp> class _GBase<_Array<_Tp> > { template<typename _Tp>
class _GBase<_Array<_Tp> >
{
public: public:
typedef _Tp value_type; typedef _Tp value_type;
_GBase (_Array<_Tp> __a, const valarray<size_t>& __i) _GBase (_Array<_Tp> __a, const valarray<size_t>& __i)
: _M_array (__a), _M_index(__i) {} : _M_array (__a), _M_index(__i) {}
value_type operator[] (size_t __i) const
value_type
operator[] (size_t __i) const
{ return _M_array._M_data[_M_index[__i]]; } { return _M_array._M_data[_M_index[__i]]; }
size_t size () const { return _M_index.size(); }
size_t
size () const
{ return _M_index.size(); }
private: private:
const _Array<_Tp> _M_array; const _Array<_Tp> _M_array;
const valarray<size_t>& _M_index; const valarray<size_t>& _M_index;
}; };
template<class _Dom> struct _GClos<_Expr,_Dom> : _GBase<_Dom> { template<class _Dom>
struct _GClos<_Expr, _Dom>
: _GBase<_Dom>
{
typedef _GBase<_Dom> _Base; typedef _GBase<_Dom> _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
...@@ -84,7 +101,9 @@ namespace std ...@@ -84,7 +101,9 @@ namespace std
}; };
template<typename _Tp> template<typename _Tp>
struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > { struct _GClos<_ValArray, _Tp>
: _GBase<_Array<_Tp> >
{
typedef _GBase<_Array<_Tp> > _Base; typedef _GBase<_Array<_Tp> > _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
...@@ -95,14 +114,19 @@ namespace std ...@@ -95,14 +114,19 @@ namespace std
// //
// indirect_array closure // indirect_array closure
// //
template<class _Dom> class _IBase { template<class _Dom>
class _IBase
{
public: public:
typedef typename _Dom::value_type value_type; typedef typename _Dom::value_type value_type;
_IBase (const _Dom& __e, const valarray<size_t>& __i) _IBase (const _Dom& __e, const valarray<size_t>& __i)
: _M_expr (__e), _M_index (__i) {} : _M_expr (__e), _M_index (__i) {}
value_type operator[] (size_t __i) const
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_index[__i]]; } { return _M_expr[_M_index[__i]]; }
size_t size() const { return _M_index.size(); } size_t size() const { return _M_index.size(); }
private: private:
...@@ -110,7 +134,10 @@ namespace std ...@@ -110,7 +134,10 @@ namespace std
const valarray<size_t>& _M_index; const valarray<size_t>& _M_index;
}; };
template<class _Dom> struct _IClos<_Expr,_Dom> : _IBase<_Dom> { template<class _Dom>
struct _IClos<_Expr, _Dom>
: _IBase<_Dom>
{
typedef _IBase<_Dom> _Base; typedef _IBase<_Dom> _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
...@@ -119,7 +146,9 @@ namespace std ...@@ -119,7 +146,9 @@ namespace std
}; };
template<typename _Tp> template<typename _Tp>
struct _IClos<_ValArray,_Tp> : _IBase<valarray<_Tp> > { struct _IClos<_ValArray, _Tp>
: _IBase<valarray<_Tp> >
{
typedef _IBase<valarray<_Tp> > _Base; typedef _IBase<valarray<_Tp> > _Base;
typedef _Tp value_type; typedef _Tp value_type;
...@@ -146,16 +175,16 @@ namespace std ...@@ -146,16 +175,16 @@ namespace std
valarray<value_type> operator[](const valarray<bool>&) const; valarray<value_type> operator[](const valarray<bool>&) const;
valarray<value_type> operator[](const valarray<size_t>&) const; valarray<value_type> operator[](const valarray<size_t>&) const;
_Expr<_UnClos<__unary_plus,std::_Expr,_Clos>, value_type> _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type>
operator+() const; operator+() const;
_Expr<_UnClos<__negate,std::_Expr,_Clos>, value_type> _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type>
operator-() const; operator-() const;
_Expr<_UnClos<__bitwise_not,std::_Expr,_Clos>, value_type> _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type>
operator~() const; operator~() const;
_Expr<_UnClos<__logical_not,std::_Expr,_Clos>, bool> _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool>
operator!() const; operator!() const;
size_t size() const; size_t size() const;
...@@ -176,41 +205,42 @@ namespace std ...@@ -176,41 +205,42 @@ namespace std
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline inline
_Expr<_Clos,_Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {} _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {}
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline const _Clos& inline const _Clos&
_Expr<_Clos,_Tp>::operator()() const _Expr<_Clos, _Tp>::operator()() const
{ return _M_closure; } { return _M_closure; }
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline _Tp inline _Tp
_Expr<_Clos,_Tp>::operator[](size_t __i) const _Expr<_Clos, _Tp>::operator[](size_t __i) const
{ return _M_closure[__i]; } { return _M_closure[__i]; }
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline valarray<_Tp> inline valarray<_Tp>
_Expr<_Clos,_Tp>::operator[](slice __s) const _Expr<_Clos, _Tp>::operator[](slice __s) const
{ return _M_closure[__s]; } { return _M_closure[__s]; }
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline valarray<_Tp> inline valarray<_Tp>
_Expr<_Clos,_Tp>::operator[](const gslice& __gs) const _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const
{ return _M_closure[__gs]; } { return _M_closure[__gs]; }
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline valarray<_Tp> inline valarray<_Tp>
_Expr<_Clos,_Tp>::operator[](const valarray<bool>& __m) const _Expr<_Clos, _Tp>::operator[](const valarray<bool>& __m) const
{ return _M_closure[__m]; } { return _M_closure[__m]; }
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline valarray<_Tp> inline valarray<_Tp>
_Expr<_Clos,_Tp>::operator[](const valarray<size_t>& __i) const _Expr<_Clos, _Tp>::operator[](const valarray<size_t>& __i) const
{ return _M_closure[__i]; } { return _M_closure[__i]; }
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline size_t inline size_t
_Expr<_Clos,_Tp>::size() const { return _M_closure.size (); } _Expr<_Clos, _Tp>::size() const
{ return _M_closure.size (); }
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline valarray<_Tp> inline valarray<_Tp>
...@@ -235,7 +265,7 @@ namespace std ...@@ -235,7 +265,7 @@ namespace std
// XXX: replace this with a more robust summation algorithm. // XXX: replace this with a more robust summation algorithm.
template<class _Clos, typename _Tp> template<class _Clos, typename _Tp>
inline _Tp inline _Tp
_Expr<_Clos,_Tp>::sum() const _Expr<_Clos, _Tp>::sum() const
{ {
size_t __n = _M_closure.size(); size_t __n = _M_closure.size();
if (__n == 0) if (__n == 0)
...@@ -260,20 +290,20 @@ namespace std ...@@ -260,20 +290,20 @@ namespace std
{ return __valarray_max(_M_closure); } { return __valarray_max(_M_closure); }
template<class _Dom, typename _Tp> template<class _Dom, typename _Tp>
inline _Expr<_UnClos<__logical_not,_Expr,_Dom>, bool> inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool>
_Expr<_Dom,_Tp>::operator!() const _Expr<_Dom, _Tp>::operator!() const
{ {
typedef _UnClos<__logical_not,std::_Expr,_Dom> _Closure; typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure;
return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); return _Expr<_Closure, _Tp>(_Closure(this->_M_closure));
} }
#define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \ #define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \
template<class _Dom, typename _Tp> \ template<class _Dom, typename _Tp> \
inline _Expr<_UnClos<_Name,std::_Expr,_Dom>,_Tp> \ inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \
_Expr<_Dom,_Tp>::operator _Op() const \ _Expr<_Dom, _Tp>::operator _Op() const \
{ \ { \
typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \ typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); \ return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \
} }
_DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus) _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus)
...@@ -282,67 +312,70 @@ namespace std ...@@ -282,67 +312,70 @@ namespace std
#undef _DEFINE_EXPR_UNARY_OPERATOR #undef _DEFINE_EXPR_UNARY_OPERATOR
#define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \ #define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \
template<class _Dom1, class _Dom2> \ template<class _Dom1, class _Dom2> \
inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \ inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \
typename __fun<_Name, typename _Dom1::value_type>::result_type>\ typename __fun<_Name, typename _Dom1::value_type>::result_type> \
operator _Op(const _Expr<_Dom1,typename _Dom1::value_type>& __v, \ operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \
const _Expr<_Dom2,typename _Dom2::value_type>& __w) \ const _Expr<_Dom2, typename _Dom2::value_type>& __w) \
{ \ { \
typedef typename _Dom1::value_type _Arg; \ typedef typename _Dom1::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \ typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \ typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \
return _Expr<_Closure,_Value>(_Closure(__v(), __w())); \ return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>,\ inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \
typename __fun<_Name, typename _Dom::value_type>::result_type>\ typename _Dom::value_type>, \
operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __v, \ typename __fun<_Name, typename _Dom::value_type>::result_type> \
operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v, \
const typename _Dom::value_type& __t) \ const typename _Dom::value_type& __t) \
{ \ { \
typedef typename _Dom::value_type _Arg; \ typedef typename _Dom::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \ typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \ typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \
return _Expr<_Closure,_Value>(_Closure(__v(), __t)); \ return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>,\ inline _Expr<_BinClos<_Name, _Constant, _Expr, \
typename __fun<_Name, typename _Dom::value_type>::result_type>\ typename _Dom::value_type, _Dom>, \
operator _Op(const typename _Dom::value_type& __t, \ typename __fun<_Name, typename _Dom::value_type>::result_type> \
const _Expr<_Dom,typename _Dom::value_type>& __v) \ operator _Op(const typename _Dom::value_type& __t, \
{ \ const _Expr<_Dom, typename _Dom::value_type>& __v) \
{ \
typedef typename _Dom::value_type _Arg; \ typedef typename _Dom::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \ typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \ typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \
return _Expr<_Closure,_Value>(_Closure(__t, __v())); \ return _Expr<_Closure, _Value>(_Closure(__t, __v())); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>,\ inline _Expr<_BinClos<_Name, _Expr, _ValArray, \
typename __fun<_Name, typename _Dom::value_type>::result_type>\ _Dom, typename _Dom::value_type>, \
operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \ typename __fun<_Name, typename _Dom::value_type>::result_type> \
operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \
const valarray<typename _Dom::value_type>& __v) \ const valarray<typename _Dom::value_type>& __v) \
{ \ { \
typedef typename _Dom::value_type _Arg; \ typedef typename _Dom::value_type _Arg; \
typedef typename __fun<_Name, _Arg>::result_type _Value; \ typedef typename __fun<_Name, _Arg>::result_type _Value; \
typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \ typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \
return _Expr<_Closure,_Value>(_Closure(__e(), __v)); \ return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>,\ inline _Expr<_BinClos<_Name, _ValArray, _Expr, \
typename __fun<_Name, typename _Dom::value_type>::result_type>\ typename _Dom::value_type, _Dom>, \
operator _Op(const valarray<typename _Dom::value_type>& __v, \ typename __fun<_Name, typename _Dom::value_type>::result_type> \
const _Expr<_Dom,typename _Dom::value_type>& __e) \ operator _Op(const valarray<typename _Dom::value_type>& __v, \
{ \ const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \
typedef typename _Dom::value_type _Tp; \ typedef typename _Dom::value_type _Tp; \
typedef typename __fun<_Name, _Tp>::result_type _Value; \ typedef typename __fun<_Name, _Tp>::result_type _Value; \
typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \ typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \
return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \ return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \
} }
_DEFINE_EXPR_BINARY_OPERATOR(+, __plus) _DEFINE_EXPR_BINARY_OPERATOR(+, __plus)
_DEFINE_EXPR_BINARY_OPERATOR(-, __minus) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
...@@ -367,20 +400,21 @@ operator _Op(const valarray<typename _Dom::value_type>& __v, \ ...@@ -367,20 +400,21 @@ operator _Op(const valarray<typename _Dom::value_type>& __v, \
#define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \ #define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_UnClos<__##_Name,_Expr,_Dom>,typename _Dom::value_type>\ inline _Expr<_UnClos<__##_Name, _Expr, _Dom>, \
_Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \ typename _Dom::value_type> \
_Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \ { \
typedef typename _Dom::value_type _Tp; \ typedef typename _Dom::value_type _Tp; \
typedef _UnClos<__##_Name,_Expr,_Dom> _Closure; \ typedef _UnClos<__##_Name, _Expr, _Dom> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__e())); \ return _Expr<_Closure, _Tp>(_Closure(__e())); \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline _Expr<_UnClos<__##_Name,_ValArray,_Tp>,_Tp> \ inline _Expr<_UnClos<__##_Name, _ValArray, _Tp>, _Tp> \
_Name(const valarray<_Tp>& __v) \ _Name(const valarray<_Tp>& __v) \
{ \ { \
typedef _UnClos<__##_Name,_ValArray,_Tp> _Closure; \ typedef _UnClos<__##_Name, _ValArray, _Tp> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__v)); \ return _Expr<_Closure, _Tp>(_Closure(__v)); \
} }
_DEFINE_EXPR_UNARY_FUNCTION(abs) _DEFINE_EXPR_UNARY_FUNCTION(abs)
...@@ -402,86 +436,86 @@ operator _Op(const valarray<typename _Dom::value_type>& __v, \ ...@@ -402,86 +436,86 @@ operator _Op(const valarray<typename _Dom::value_type>& __v, \
#define _DEFINE_EXPR_BINARY_FUNCTION(_Fun) \ #define _DEFINE_EXPR_BINARY_FUNCTION(_Fun) \
template<class _Dom1, class _Dom2> \ template<class _Dom1, class _Dom2> \
inline _Expr<_BinClos<__##_Fun,_Expr,_Expr,_Dom1,_Dom2>, \ inline _Expr<_BinClos<__##_Fun, _Expr, _Expr, _Dom1, _Dom2>, \
typename _Dom1::value_type> \ typename _Dom1::value_type> \
_Fun(const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \ _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \
const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \ const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \
{ \ { \
typedef typename _Dom1::value_type _Tp; \ typedef typename _Dom1::value_type _Tp; \
typedef _BinClos<__##_Fun,_Expr,_Expr,_Dom1,_Dom2> _Closure; \ typedef _BinClos<__##_Fun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__e1(), __e2())); \ return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<__##_Fun, _Expr, _ValArray, _Dom, \ inline _Expr<_BinClos<__##_Fun, _Expr, _ValArray, _Dom, \
typename _Dom::value_type>, \ typename _Dom::value_type>, \
typename _Dom::value_type> \ typename _Dom::value_type> \
_Fun(const _Expr<_Dom,typename _Dom::value_type>& __e, \ _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \
const valarray<typename _Dom::value_type>& __v) \ const valarray<typename _Dom::value_type>& __v) \
{ \ { \
typedef typename _Dom::value_type _Tp; \ typedef typename _Dom::value_type _Tp; \
typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure;\ typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__e(), __v)); \ return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<__##_Fun, _ValArray, _Expr, \ inline _Expr<_BinClos<__##_Fun, _ValArray, _Expr, \
typename _Dom::value_type,_Dom>, \ typename _Dom::value_type, _Dom>, \
typename _Dom::value_type> \ typename _Dom::value_type> \
_Fun(const valarray<typename _Dom::valarray>& __v, \ _Fun(const valarray<typename _Dom::valarray>& __v, \
const _Expr<_Dom,typename _Dom::value_type>& __e) \ const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \ { \
typedef typename _Dom::value_type _Tp; \ typedef typename _Dom::value_type _Tp; \
typedef _BinClos<__##_Fun,_ValArray,_Expr,_Tp,_Dom> _Closure; \ typedef _BinClos<__##_Fun, _ValArray, _Expr, _Tp, _Dom> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__v, __e())); \ return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<__##_Fun,_Expr,_Constant,_Dom, \ inline _Expr<_BinClos<__##_Fun, _Expr, _Constant, _Dom, \
typename _Dom::value_type>, \ typename _Dom::value_type>, \
typename _Dom::value_type> \ typename _Dom::value_type> \
_Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \
const typename _Dom::value_type& __t) \ const typename _Dom::value_type& __t) \
{ \ { \
typedef typename _Dom::value_type _Tp; \ typedef typename _Dom::value_type _Tp; \
typedef _BinClos<__##_Fun,_Expr,_Constant,_Dom,_Tp> _Closure; \ typedef _BinClos<__##_Fun, _Expr, _Constant, _Dom, _Tp> _Closure;\
return _Expr<_Closure,_Tp>(_Closure(__e(), __t)); \ return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \
} \ } \
\ \
template<class _Dom> \ template<class _Dom> \
inline _Expr<_BinClos<__##_Fun,_Constant,_Expr, \ inline _Expr<_BinClos<__##_Fun, _Constant, _Expr, \
typename _Dom::value_type,_Dom>, \ typename _Dom::value_type, _Dom>, \
typename _Dom::value_type> \ typename _Dom::value_type> \
_Fun(const typename _Dom::value_type& __t, \ _Fun(const typename _Dom::value_type& __t, \
const _Expr<_Dom,typename _Dom::value_type>& __e) \ const _Expr<_Dom, typename _Dom::value_type>& __e) \
{ \ { \
typedef typename _Dom::value_type _Tp; \ typedef typename _Dom::value_type _Tp; \
typedef _BinClos<__##_Fun, _Constant,_Expr,_Tp,_Dom> _Closure; \ typedef _BinClos<__##_Fun, _Constant, _Expr, _Tp, _Dom> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__t, __e())); \ return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline _Expr<_BinClos<__##_Fun,_ValArray,_ValArray,_Tp,_Tp>, _Tp> \ inline _Expr<_BinClos<__##_Fun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \
_Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
{ \ { \
typedef _BinClos<__##_Fun,_ValArray,_ValArray,_Tp,_Tp> _Closure; \ typedef _BinClos<__##_Fun, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__v, __w)); \ return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline _Expr<_BinClos<__##_Fun,_ValArray,_Constant,_Tp,_Tp>,_Tp> \ inline _Expr<_BinClos<__##_Fun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \
_Fun(const valarray<_Tp>& __v, const _Tp& __t) \ _Fun(const valarray<_Tp>& __v, const _Tp& __t) \
{ \ { \
typedef _BinClos<__##_Fun,_ValArray,_Constant,_Tp,_Tp> _Closure; \ typedef _BinClos<__##_Fun, _ValArray, _Constant, _Tp, _Tp> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__v, __t)); \ return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline _Expr<_BinClos<__##_Fun,_Constant,_ValArray,_Tp,_Tp>,_Tp> \ inline _Expr<_BinClos<__##_Fun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \
_Fun(const _Tp& __t, const valarray<_Tp>& __v) \ _Fun(const _Tp& __t, const valarray<_Tp>& __v) \
{ \ { \
typedef _BinClos<__##_Fun,_Constant,_ValArray,_Tp,_Tp> _Closure; \ typedef _BinClos<__##_Fun, _Constant, _ValArray, _Tp, _Tp> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__t, __v)); \ return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
} }
_DEFINE_EXPR_BINARY_FUNCTION(atan2) _DEFINE_EXPR_BINARY_FUNCTION(atan2)
...@@ -491,7 +525,6 @@ _DEFINE_EXPR_BINARY_FUNCTION(pow) ...@@ -491,7 +525,6 @@ _DEFINE_EXPR_BINARY_FUNCTION(pow)
} // std:: } // std::
#endif /* _CPP_VALARRAY_AFTER_H */ #endif /* _CPP_VALARRAY_AFTER_H */
// Local Variables: // Local Variables:
......
...@@ -79,7 +79,10 @@ namespace std ...@@ -79,7 +79,10 @@ namespace std
// valarrays aren't required to be exception safe. // valarrays aren't required to be exception safe.
inline static void inline static void
_S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
{ while (__b != __e) new(__b++) _Tp(); } {
while (__b != __e)
new(__b++) _Tp();
}
}; };
template<typename _Tp> template<typename _Tp>
...@@ -88,7 +91,7 @@ namespace std ...@@ -88,7 +91,7 @@ namespace std
// For fundamental types, it suffices to say 'memset()' // For fundamental types, it suffices to say 'memset()'
inline static void inline static void
_S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
{ std::memset(__b, 0, (__e - __b)*sizeof(_Tp)); } { std::memset(__b, 0, (__e - __b) * sizeof(_Tp)); }
}; };
template<typename _Tp> template<typename _Tp>
...@@ -109,7 +112,10 @@ namespace std ...@@ -109,7 +112,10 @@ namespace std
// valarrays aren't required to be exception safe. // valarrays aren't required to be exception safe.
inline static void inline static void
_S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t)
{ while (__b != __e) new(__b++) _Tp(__t); } {
while (__b != __e)
new(__b++) _Tp(__t);
}
}; };
template<typename _Tp> template<typename _Tp>
...@@ -117,7 +123,10 @@ namespace std ...@@ -117,7 +123,10 @@ namespace std
{ {
inline static void inline static void
_S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t) _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e, const _Tp __t)
{ while (__b != __e) *__b++ = __t; } {
while (__b != __e)
*__b++ = __t;
}
}; };
template<typename _Tp> template<typename _Tp>
...@@ -141,7 +150,10 @@ namespace std ...@@ -141,7 +150,10 @@ namespace std
inline static void inline static void
_S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e,
_Tp* __restrict__ __o) _Tp* __restrict__ __o)
{ while (__b != __e) new(__o++) _Tp(*__b++); } {
while (__b != __e)
new(__o++) _Tp(*__b++);
}
}; };
template<typename _Tp> template<typename _Tp>
...@@ -170,9 +182,17 @@ namespace std ...@@ -170,9 +182,17 @@ namespace std
size_t __s, _Tp* __restrict__ __o) size_t __s, _Tp* __restrict__ __o)
{ {
if (__is_fundamental<_Tp>::_M_type) if (__is_fundamental<_Tp>::_M_type)
while (__n--) { *__o++ = *__a; __a += __s; } while (__n--)
{
*__o++ = *__a;
__a += __s;
}
else else
while (__n--) { new(__o++) _Tp(*__a); __a += __s; } while (__n--)
{
new(__o++) _Tp(*__a);
__a += __s;
}
} }
// copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]] // copy-construct raw array [__o, *) from indexed array __a[__i[<__n>]]
...@@ -183,9 +203,11 @@ namespace std ...@@ -183,9 +203,11 @@ namespace std
_Tp* __restrict__ __o, size_t __n) _Tp* __restrict__ __o, size_t __n)
{ {
if (__is_fundamental<_Tp>::_M_type) if (__is_fundamental<_Tp>::_M_type)
while (__n--) *__o++ = __a[*__i++]; while (__n--)
*__o++ = __a[*__i++];
else else
while (__n--) new (__o++) _Tp(__a[*__i++]); while (__n--)
new (__o++) _Tp(__a[*__i++]);
} }
// Do the necessary cleanup when we're done with arrays. // Do the necessary cleanup when we're done with arrays.
...@@ -194,28 +216,41 @@ namespace std ...@@ -194,28 +216,41 @@ namespace std
__valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e) __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e)
{ {
if (!__is_fundamental<_Tp>::_M_type) if (!__is_fundamental<_Tp>::_M_type)
while (__b != __e) { __b->~_Tp(); ++__b; } while (__b != __e)
{
__b->~_Tp();
++__b;
}
} }
// Fill a plain array __a[<__n>] with __t // Fill a plain array __a[<__n>] with __t
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_fill (_Tp* __restrict__ __a, size_t __n, const _Tp& __t) __valarray_fill(_Tp* __restrict__ __a, size_t __n, const _Tp& __t)
{ while (__n--) *__a++ = __t; } {
while (__n--)
*__a++ = __t;
}
// fill strided array __a[<__n-1 : __s>] with __t // fill strided array __a[<__n-1 : __s>] with __t
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_fill (_Tp* __restrict__ __a, size_t __n, __valarray_fill(_Tp* __restrict__ __a, size_t __n,
size_t __s, const _Tp& __t) size_t __s, const _Tp& __t)
{ for (size_t __i=0; __i<__n; ++__i, __a+=__s) *__a = __t; } {
for (size_t __i = 0; __i < __n; ++__i, __a += __s)
*__a = __t;
}
// fill indir ect array __a[__i[<__n>]] with __i // fill indir ect array __a[__i[<__n>]] with __i
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i, __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i,
size_t __n, const _Tp& __t) size_t __n, const _Tp& __t)
{ for (size_t __j=0; __j<__n; ++__j, ++__i) __a[*__i] = __t; } {
for (size_t __j = 0; __j < __n; ++__j, ++__i)
__a[*__i] = __t;
}
// copy plain array __a[<__n>] in __b[<__n>] // copy plain array __a[<__n>] in __b[<__n>]
// For non-fundamental types, it is wrong to say 'memcpy()' // For non-fundamental types, it is wrong to say 'memcpy()'
...@@ -224,7 +259,10 @@ namespace std ...@@ -224,7 +259,10 @@ namespace std
{ {
inline static void inline static void
_S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b)
{ while (__n--) *__b++ = *__a++; } {
while(__n--)
*__b++ = *__a++;
}
}; };
template<typename _Tp> template<typename _Tp>
...@@ -250,14 +288,20 @@ namespace std ...@@ -250,14 +288,20 @@ namespace std
inline void inline void
__valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s, __valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s,
_Tp* __restrict__ __b) _Tp* __restrict__ __b)
{ for (size_t __i=0; __i<__n; ++__i, ++__b, __a += __s) *__b = *__a; } {
for (size_t __i = 0; __i < __n; ++__i, ++__b, __a += __s)
*__b = *__a;
}
// Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>] // Copy a plain array __a[<__n>] into a strided array __b[<__n : __s>]
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b, __valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b,
size_t __n, size_t __s) size_t __n, size_t __s)
{ for (size_t __i=0; __i<__n; ++__i, ++__a, __b+=__s) *__b = *__a; } {
for (size_t __i = 0; __i < __n; ++__i, ++__a, __b += __s)
*__b = *__a;
}
// Copy strided array __src[<__n : __s1>] into another // Copy strided array __src[<__n : __s1>] into another
// strided array __dst[< : __s2>]. Their sizes must match. // strided array __dst[< : __s2>]. Their sizes must match.
...@@ -267,7 +311,7 @@ namespace std ...@@ -267,7 +311,7 @@ namespace std
_Tp* __restrict__ __dst, size_t __s2) _Tp* __restrict__ __dst, size_t __s2)
{ {
for (size_t __i = 0; __i < __n; ++__i) for (size_t __i = 0; __i < __n; ++__i)
__dst[__i * __s2] = __src [ __i * __s1]; __dst[__i * __s2] = __src[__i * __s1];
} }
...@@ -277,14 +321,20 @@ namespace std ...@@ -277,14 +321,20 @@ namespace std
__valarray_copy (const _Tp* __restrict__ __a, __valarray_copy (const _Tp* __restrict__ __a,
const size_t* __restrict__ __i, const size_t* __restrict__ __i,
_Tp* __restrict__ __b, size_t __n) _Tp* __restrict__ __b, size_t __n)
{ for (size_t __j=0; __j<__n; ++__j, ++__b, ++__i) *__b = __a[*__i]; } {
for (size_t __j = 0; __j < __n; ++__j, ++__b, ++__i)
*__b = __a[*__i];
}
// Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]]
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_copy (const _Tp* __restrict__ __a, size_t __n, __valarray_copy (const _Tp* __restrict__ __a, size_t __n,
_Tp* __restrict__ __b, const size_t* __restrict__ __i) _Tp* __restrict__ __b, const size_t* __restrict__ __i)
{ for (size_t __j=0; __j<__n; ++__j, ++__a, ++__i) __b[*__i] = *__a; } {
for (size_t __j = 0; __j < __n; ++__j, ++__a, ++__i)
__b[*__i] = *__a;
}
// Copy the __n first elements of an indexed array __src[<__i>] into // Copy the __n first elements of an indexed array __src[<__i>] into
// another indexed array __dst[<__j>]. // another indexed array __dst[<__j>].
...@@ -310,7 +360,8 @@ namespace std ...@@ -310,7 +360,8 @@ namespace std
__valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l) __valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l)
{ {
_Tp __r = _Tp(); _Tp __r = _Tp();
while (__f != __l) __r += *__f++; while (__f != __l)
__r += *__f++;
return __r; return __r;
} }
...@@ -321,7 +372,8 @@ namespace std ...@@ -321,7 +372,8 @@ namespace std
const _Tp* __restrict__ __l) const _Tp* __restrict__ __l)
{ {
_Tp __r = _Tp(1); _Tp __r = _Tp(1);
while (__f != __l) __r = __r * *__f++; while (__f != __l)
__r = __r * *__f++;
return __r; return __r;
} }
...@@ -367,12 +419,12 @@ namespace std ...@@ -367,12 +419,12 @@ namespace std
template<typename _Tp> template<typename _Tp>
struct _Array struct _Array
{ {
explicit _Array (size_t); explicit _Array(size_t);
explicit _Array (_Tp* const __restrict__); explicit _Array(_Tp* const __restrict__);
explicit _Array (const valarray<_Tp>&); explicit _Array(const valarray<_Tp>&);
_Array (const _Tp* __restrict__, size_t); _Array(const _Tp* __restrict__, size_t);
_Tp* begin () const; _Tp* begin() const;
_Tp* const __restrict__ _M_data; _Tp* const __restrict__ _M_data;
}; };
...@@ -380,18 +432,18 @@ namespace std ...@@ -380,18 +432,18 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t) __valarray_fill (_Array<_Tp> __a, size_t __n, const _Tp& __t)
{ std::__valarray_fill (__a._M_data, __n, __t); } { std::__valarray_fill(__a._M_data, __n, __t); }
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_fill (_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) __valarray_fill(_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t)
{ std::__valarray_fill (__a._M_data, __n, __s, __t); } { std::__valarray_fill(__a._M_data, __n, __s, __t); }
template<typename _Tp> template<typename _Tp>
inline void inline void
__valarray_fill (_Array<_Tp> __a, _Array<size_t> __i, __valarray_fill(_Array<_Tp> __a, _Array<size_t> __i,
size_t __n, const _Tp& __t) size_t __n, const _Tp& __t)
{ std::__valarray_fill (__a._M_data, __i._M_data, __n, __t); } { std::__valarray_fill(__a._M_data, __i._M_data, __n, __t); }
// Copy a plain array __a[<__n>] into a play array __b[<>] // Copy a plain array __a[<__n>] into a play array __b[<>]
template<typename _Tp> template<typename _Tp>
...@@ -447,21 +499,23 @@ namespace std ...@@ -447,21 +499,23 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline inline
_Array<_Tp>::_Array (size_t __n) _Array<_Tp>::_Array(size_t __n)
: _M_data(__valarray_get_storage<_Tp>(__n)) : _M_data(__valarray_get_storage<_Tp>(__n))
{ std::__valarray_default_construct(_M_data, _M_data + __n); } { std::__valarray_default_construct(_M_data, _M_data + __n); }
template<typename _Tp> template<typename _Tp>
inline inline
_Array<_Tp>::_Array (_Tp* const __restrict__ __p) : _M_data (__p) {} _Array<_Tp>::_Array(_Tp* const __restrict__ __p)
: _M_data (__p) {}
template<typename _Tp> template<typename _Tp>
inline _Array<_Tp>::_Array (const valarray<_Tp>& __v) inline
_Array<_Tp>::_Array(const valarray<_Tp>& __v)
: _M_data (__v._M_data) {} : _M_data (__v._M_data) {}
template<typename _Tp> template<typename _Tp>
inline inline
_Array<_Tp>::_Array (const _Tp* __restrict__ __b, size_t __s) _Array<_Tp>::_Array(const _Tp* __restrict__ __b, size_t __s)
: _M_data(__valarray_get_storage<_Tp>(__s)) : _M_data(__valarray_get_storage<_Tp>(__s))
{ std::__valarray_copy_construct(__b, __s, _M_data); } { std::__valarray_copy_construct(__b, __s, _M_data); }
...@@ -471,138 +525,152 @@ namespace std ...@@ -471,138 +525,152 @@ namespace std
{ return _M_data; } { return _M_data; }
#define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \ #define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \
template<typename _Tp> \ template<typename _Tp> \
inline void \ inline void \
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, const _Tp& __t) \ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, const _Tp& __t) \
{ \ { \
for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p) \ for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; ++__p) \
*__p _Op##= __t; \ *__p _Op##= __t; \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline void \ inline void \
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \
{ \ { \
_Tp* __p = __a._M_data; \ _Tp* __p = __a._M_data; \
for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__p, ++__q) \ for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; ++__p, ++__q) \
*__p _Op##= *__q; \ *__p _Op##= *__q; \
} \ } \
\ \
template<typename _Tp, class _Dom> \ template<typename _Tp, class _Dom> \
void \ void \
_Array_augmented_##_Name (_Array<_Tp> __a, \ _Array_augmented_##_Name(_Array<_Tp> __a, \
const _Expr<_Dom,_Tp>& __e, size_t __n) \ const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \ { \
_Tp* __p (__a._M_data); \ _Tp* __p(__a._M_data); \
for (size_t __i=0; __i<__n; ++__i, ++__p) *__p _Op##= __e[__i]; \ for (size_t __i = 0; __i < __n; ++__i, ++__p) \
} \ *__p _Op##= __e[__i]; \
} \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline void \ inline void \
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, size_t __s, \ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, size_t __s, \
_Array<_Tp> __b) \ _Array<_Tp> __b) \
{ \ { \
_Tp* __q (__b._M_data); \ _Tp* __q(__b._M_data); \
for (_Tp* __p=__a._M_data; __p<__a._M_data+__s*__n; __p+=__s, ++__q) \ for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \
__p += __s, ++__q) \
*__p _Op##= *__q; \ *__p _Op##= *__q; \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline void \ inline void \
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<_Tp> __b, \ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<_Tp> __b, \
size_t __n, size_t __s) \ size_t __n, size_t __s) \
{ \ { \
_Tp* __q (__b._M_data); \ _Tp* __q(__b._M_data); \
for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, __q+=__s) \ for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
++__p, __q += __s) \
*__p _Op##= *__q; \ *__p _Op##= *__q; \
} \ } \
\ \
template<typename _Tp, class _Dom> \ template<typename _Tp, class _Dom> \
void \ void \
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __s, \ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __s, \
const _Expr<_Dom,_Tp>& __e, size_t __n) \ const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \ { \
_Tp* __p (__a._M_data); \ _Tp* __p(__a._M_data); \
for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p _Op##= __e[__i]; \ for (size_t __i = 0; __i < __n; ++__i, __p += __s) \
} \ *__p _Op##= __e[__i]; \
} \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline void \ inline void \
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \
_Array<_Tp> __b, size_t __n) \ _Array<_Tp> __b, size_t __n) \
{ \ { \
_Tp* __q (__b._M_data); \ _Tp* __q(__b._M_data); \
for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__q) \ for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \
++__j, ++__q) \
__a._M_data[*__j] _Op##= *__q; \ __a._M_data[*__j] _Op##= *__q; \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline void \ inline void \
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \
_Array<_Tp> __b, _Array<size_t> __i) \ _Array<_Tp> __b, _Array<size_t> __i) \
{ \ { \
_Tp* __p (__a._M_data); \ _Tp* __p(__a._M_data); \
for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__p) \ for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \
++__j, ++__p) \
*__p _Op##= __b._M_data[*__j]; \ *__p _Op##= __b._M_data[*__j]; \
} \ } \
\ \
template<typename _Tp, class _Dom> \ template<typename _Tp, class _Dom> \
void \ void \
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \
const _Expr<_Dom, _Tp>& __e, size_t __n) \ const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \ { \
size_t* __j (__i._M_data); \ size_t* __j(__i._M_data); \
for (size_t __k=0; __k<__n; ++__k, ++__j) \ for (size_t __k = 0; __k<__n; ++__k, ++__j) \
__a._M_data[*__j] _Op##= __e[__k]; \ __a._M_data[*__j] _Op##= __e[__k]; \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
void \ void \
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
_Array<_Tp> __b, size_t __n) \ _Array<_Tp> __b, size_t __n) \
{ \ { \
bool* ok (__m._M_data); \ bool* __ok(__m._M_data); \
_Tp* __p (__a._M_data); \ _Tp* __p(__a._M_data); \
for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++ok, ++__p) { \ for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \
while (! *ok) { \ ++__q, ++__ok, ++__p) \
++ok; \ { \
while (! *__ok) \
{ \
++__ok; \
++__p; \ ++__p; \
} \ } \
*__p _Op##= *__q; \ *__p _Op##= *__q; \
} \ } \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
void \ void \
_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \
_Array<_Tp> __b, _Array<bool> __m) \ _Array<_Tp> __b, _Array<bool> __m) \
{ \ { \
bool* ok (__m._M_data); \ bool* __ok(__m._M_data); \
_Tp* __q (__b._M_data); \ _Tp* __q(__b._M_data); \
for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++ok, ++__q) { \ for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
while (! *ok) { \ ++__p, ++__ok, ++__q) \
++ok; \ { \
while (! *__ok) \
{ \
++__ok; \
++__q; \ ++__q; \
} \ } \
*__p _Op##= *__q; \ *__p _Op##= *__q; \
} \ } \
} \ } \
\ \
template<typename _Tp, class _Dom> \ template<typename _Tp, class _Dom> \
void \ void \
_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \ _Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
const _Expr<_Dom, _Tp>& __e, size_t __n) \ const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \ { \
bool* ok(__m._M_data); \ bool* __ok(__m._M_data); \
_Tp* __p (__a._M_data); \ _Tp* __p(__a._M_data); \
for (size_t __i=0; __i<__n; ++__i, ++ok, ++__p) { \ for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \
while (! *ok) { \ { \
++ok; \ while (! *__ok) \
{ \
++__ok; \
++__p; \ ++__p; \
} \ } \
*__p _Op##= __e[__i]; \ *__p _Op##= __e[__i]; \
} \ } \
} }
_DEFINE_ARRAY_FUNCTION(+, __plus) _DEFINE_ARRAY_FUNCTION(+, __plus)
_DEFINE_ARRAY_FUNCTION(-, __minus) _DEFINE_ARRAY_FUNCTION(-, __minus)
......
// The template and inlines for the -*- C++ -*- internal _Meta class. // The template and inlines for the -*- C++ -*- internal _Meta class.
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -66,85 +67,99 @@ namespace std ...@@ -66,85 +67,99 @@ namespace std
struct __abs struct __abs
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return abs(__t); } _Tp operator()(const _Tp& __t) const
{ return abs(__t); }
}; };
struct __cos struct __cos
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return cos(__t); } _Tp operator()(const _Tp& __t) const
{ return cos(__t); }
}; };
struct __acos struct __acos
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return acos(__t); } _Tp operator()(const _Tp& __t) const
{ return acos(__t); }
}; };
struct __cosh struct __cosh
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return cosh(__t); } _Tp operator()(const _Tp& __t) const
{ return cosh(__t); }
}; };
struct __sin struct __sin
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return sin(__t); } _Tp operator()(const _Tp& __t) const
{ return sin(__t); }
}; };
struct __asin struct __asin
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return asin(__t); } _Tp operator()(const _Tp& __t) const
{ return asin(__t); }
}; };
struct __sinh struct __sinh
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return sinh(__t); } _Tp operator()(const _Tp& __t) const
{ return sinh(__t); }
}; };
struct __tan struct __tan
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return tan(__t); } _Tp operator()(const _Tp& __t) const
{ return tan(__t); }
}; };
struct __atan struct __atan
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return atan(__t); } _Tp operator()(const _Tp& __t) const
{ return atan(__t); }
}; };
struct __tanh struct __tanh
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return tanh(__t); } _Tp operator()(const _Tp& __t) const
{ return tanh(__t); }
}; };
struct __exp struct __exp
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return exp(__t); } _Tp operator()(const _Tp& __t) const
{ return exp(__t); }
}; };
struct __log struct __log
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return log(__t); } _Tp operator()(const _Tp& __t) const
{ return log(__t); }
}; };
struct __log10 struct __log10
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return log10(__t); } _Tp operator()(const _Tp& __t) const
{ return log10(__t); }
}; };
struct __sqrt struct __sqrt
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return sqrt(__t); } _Tp operator()(const _Tp& __t) const
{ return sqrt(__t); }
}; };
// In the past, we used to tailor operator applications semantics // In the past, we used to tailor operator applications semantics
...@@ -154,19 +169,22 @@ namespace std ...@@ -154,19 +169,22 @@ namespace std
struct __unary_plus struct __unary_plus
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return +__t; } _Tp operator()(const _Tp& __t) const
{ return +__t; }
}; };
struct __negate struct __negate
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return -__t; } _Tp operator()(const _Tp& __t) const
{ return -__t; }
}; };
struct __bitwise_not struct __bitwise_not
{ {
template<typename _Tp> template<typename _Tp>
_Tp operator()(const _Tp& __t) const { return ~__t; } _Tp operator()(const _Tp& __t) const
{ return ~__t; }
}; };
struct __plus struct __plus
...@@ -424,8 +442,8 @@ namespace std ...@@ -424,8 +442,8 @@ namespace std
}; };
template<class _Dom> template<class _Dom>
struct _RefFunClos<_Expr,_Dom> : struct _RefFunClos<_Expr, _Dom>
_FunBase<_Dom, const typename _Dom::value_type&> : _FunBase<_Dom, const typename _Dom::value_type&>
{ {
typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base; typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
...@@ -436,7 +454,8 @@ namespace std ...@@ -436,7 +454,8 @@ namespace std
}; };
template<typename _Tp> template<typename _Tp>
struct _RefFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, const _Tp&> struct _RefFunClos<_ValArray, _Tp>
: _FunBase<valarray<_Tp>, const _Tp&>
{ {
typedef _FunBase<valarray<_Tp>, const _Tp&> _Base; typedef _FunBase<valarray<_Tp>, const _Tp&> _Base;
typedef _Tp value_type; typedef _Tp value_type;
...@@ -468,7 +487,8 @@ namespace std ...@@ -468,7 +487,8 @@ namespace std
}; };
template<class _Oper, class _Dom> template<class _Oper, class _Dom>
struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom> struct _UnClos<_Oper, _Expr, _Dom>
: _UnBase<_Oper, _Dom>
{ {
typedef _Dom _Arg; typedef _Dom _Arg;
typedef _UnBase<_Oper, _Dom> _Base; typedef _UnBase<_Oper, _Dom> _Base;
...@@ -478,7 +498,8 @@ namespace std ...@@ -478,7 +498,8 @@ namespace std
}; };
template<class _Oper, typename _Tp> template<class _Oper, typename _Tp>
struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > struct _UnClos<_Oper, _ValArray, _Tp>
: _UnBase<_Oper, valarray<_Tp> >
{ {
typedef valarray<_Tp> _Arg; typedef valarray<_Tp> _Arg;
typedef _UnBase<_Oper, valarray<_Tp> > _Base; typedef _UnBase<_Oper, valarray<_Tp> > _Base;
...@@ -555,19 +576,19 @@ namespace std ...@@ -555,19 +576,19 @@ namespace std
template<class _Oper, class _Dom1, class _Dom2> template<class _Oper, class _Dom1, class _Dom2>
struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2> struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
: _BinBase<_Oper,_Dom1,_Dom2> : _BinBase<_Oper, _Dom1, _Dom2>
{ {
typedef _BinBase<_Oper,_Dom1,_Dom2> _Base; typedef _BinBase<_Oper, _Dom1, _Dom2> _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
_BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {} _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {}
}; };
template<class _Oper, typename _Tp> template<class _Oper, typename _Tp>
struct _BinClos<_Oper,_ValArray,_ValArray,_Tp,_Tp> struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _Tp>
: _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> >
{ {
typedef _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > _Base; typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base;
typedef _Tp value_type; typedef _Tp value_type;
_BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w) _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w)
...@@ -575,8 +596,8 @@ namespace std ...@@ -575,8 +596,8 @@ namespace std
}; };
template<class _Oper, class _Dom> template<class _Oper, class _Dom>
struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type> struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type>
: _BinBase<_Oper,_Dom,valarray<typename _Dom::value_type> > : _BinBase<_Oper, _Dom, valarray<typename _Dom::value_type> >
{ {
typedef typename _Dom::value_type _Tp; typedef typename _Dom::value_type _Tp;
typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base; typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
...@@ -587,11 +608,11 @@ namespace std ...@@ -587,11 +608,11 @@ namespace std
}; };
template<class _Oper, class _Dom> template<class _Oper, class _Dom>
struct _BinClos<_Oper,_ValArray,_Expr,typename _Dom::value_type,_Dom> struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom>
: _BinBase<_Oper,valarray<typename _Dom::value_type>,_Dom> : _BinBase<_Oper, valarray<typename _Dom::value_type>,_Dom>
{ {
typedef typename _Dom::value_type _Tp; typedef typename _Dom::value_type _Tp;
typedef _BinBase<_Oper,valarray<_Tp>,_Dom> _Base; typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
_BinClos(const valarray<_Tp>& __e1, const _Dom& __e2) _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2)
...@@ -599,8 +620,8 @@ namespace std ...@@ -599,8 +620,8 @@ namespace std
}; };
template<class _Oper, class _Dom> template<class _Oper, class _Dom>
struct _BinClos<_Oper,_Expr,_Constant,_Dom,typename _Dom::value_type> struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type>
: _BinBase2<_Oper,_Dom> : _BinBase2<_Oper, _Dom>
{ {
typedef typename _Dom::value_type _Tp; typedef typename _Dom::value_type _Tp;
typedef _BinBase2<_Oper,_Dom> _Base; typedef _BinBase2<_Oper,_Dom> _Base;
...@@ -610,19 +631,19 @@ namespace std ...@@ -610,19 +631,19 @@ namespace std
}; };
template<class _Oper, class _Dom> template<class _Oper, class _Dom>
struct _BinClos<_Oper,_Constant,_Expr,typename _Dom::value_type,_Dom> struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom>
: _BinBase1<_Oper,_Dom> : _BinBase1<_Oper, _Dom>
{ {
typedef typename _Dom::value_type _Tp; typedef typename _Dom::value_type _Tp;
typedef _BinBase1<_Oper,_Dom> _Base; typedef _BinBase1<_Oper, _Dom> _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
_BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {} _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {}
}; };
template<class _Oper, typename _Tp> template<class _Oper, typename _Tp>
struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp> struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp>
: _BinBase2<_Oper,valarray<_Tp> > : _BinBase2<_Oper, valarray<_Tp> >
{ {
typedef _BinBase2<_Oper,valarray<_Tp> > _Base; typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
...@@ -631,44 +652,57 @@ namespace std ...@@ -631,44 +652,57 @@ namespace std
}; };
template<class _Oper, typename _Tp> template<class _Oper, typename _Tp>
struct _BinClos<_Oper,_Constant,_ValArray,_Tp,_Tp> struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp>
: _BinBase1<_Oper,valarray<_Tp> > : _BinBase1<_Oper, valarray<_Tp> >
{ {
typedef _BinBase1<_Oper,valarray<_Tp> > _Base; typedef _BinBase1<_Oper, valarray<_Tp> > _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
_BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {} _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {}
}; };
// //
// slice_array closure. // slice_array closure.
// //
template<typename _Dom> class _SBase { template<typename _Dom>
class _SBase
{
public: public:
typedef typename _Dom::value_type value_type; typedef typename _Dom::value_type value_type;
_SBase (const _Dom& __e, const slice& __s) _SBase (const _Dom& __e, const slice& __s)
: _M_expr (__e), _M_slice (__s) {} : _M_expr (__e), _M_slice (__s) {}
value_type operator[] (size_t __i) const
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; }
size_t size() const { return _M_slice.size (); }
size_t
size() const
{ return _M_slice.size (); }
private: private:
const _Dom& _M_expr; const _Dom& _M_expr;
const slice& _M_slice; const slice& _M_slice;
}; };
template<typename _Tp> class _SBase<_Array<_Tp> > { template<typename _Tp>
class _SBase<_Array<_Tp> >
{
public: public:
typedef _Tp value_type; typedef _Tp value_type;
_SBase (_Array<_Tp> __a, const slice& __s) _SBase (_Array<_Tp> __a, const slice& __s)
: _M_array (__a._M_data+__s.start()), _M_size (__s.size()), : _M_array (__a._M_data+__s.start()), _M_size (__s.size()),
_M_stride (__s.stride()) {} _M_stride (__s.stride()) {}
value_type operator[] (size_t __i) const
value_type
operator[] (size_t __i) const
{ return _M_array._M_data[__i * _M_stride]; } { return _M_array._M_data[__i * _M_stride]; }
size_t size() const { return _M_size; }
size_t
size() const
{ return _M_size; }
private: private:
const _Array<_Tp> _M_array; const _Array<_Tp> _M_array;
...@@ -676,7 +710,10 @@ namespace std ...@@ -676,7 +710,10 @@ namespace std
const size_t _M_stride; const size_t _M_stride;
}; };
template<class _Dom> struct _SClos<_Expr,_Dom> : _SBase<_Dom> { template<class _Dom>
struct _SClos<_Expr, _Dom>
: _SBase<_Dom>
{
typedef _SBase<_Dom> _Base; typedef _SBase<_Dom> _Base;
typedef typename _Base::value_type value_type; typedef typename _Base::value_type value_type;
...@@ -684,7 +721,9 @@ namespace std ...@@ -684,7 +721,9 @@ namespace std
}; };
template<typename _Tp> template<typename _Tp>
struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > { struct _SClos<_ValArray, _Tp>
: _SBase<_Array<_Tp> >
{
typedef _SBase<_Array<_Tp> > _Base; typedef _SBase<_Array<_Tp> > _Base;
typedef _Tp value_type; typedef _Tp value_type;
...@@ -693,7 +732,6 @@ namespace std ...@@ -693,7 +732,6 @@ namespace std
} // std:: } // std::
#endif /* _CPP_VALARRAY_BEFORE_H */ #endif /* _CPP_VALARRAY_BEFORE_H */
// Local Variables: // Local Variables:
......
...@@ -147,7 +147,8 @@ namespace std ...@@ -147,7 +147,8 @@ namespace std
valarray(const indirect_array<_Tp>&); valarray(const indirect_array<_Tp>&);
template<class _Dom> template<class _Dom>
valarray(const _Expr<_Dom,_Tp>& __e); valarray(const _Expr<_Dom, _Tp>& __e);
~valarray(); ~valarray();
// _lib.valarray.assign_ assignment: // _lib.valarray.assign_ assignment:
...@@ -211,7 +212,7 @@ namespace std ...@@ -211,7 +212,7 @@ namespace std
valarray<_Tp>& operator=(const indirect_array<_Tp>&); valarray<_Tp>& operator=(const indirect_array<_Tp>&);
template<class _Dom> valarray<_Tp>& template<class _Dom> valarray<_Tp>&
operator= (const _Expr<_Dom,_Tp>&); operator= (const _Expr<_Dom, _Tp>&);
// _lib.valarray.access_ element access: // _lib.valarray.access_ element access:
/** /**
...@@ -237,7 +238,7 @@ namespace std ...@@ -237,7 +238,7 @@ namespace std
* @param s The source slice. * @param s The source slice.
* @return New valarray containing elements in @a s. * @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. * @brief Return a reference to an array subset.
...@@ -260,7 +261,7 @@ namespace std ...@@ -260,7 +261,7 @@ namespace std
* @param s The source slice. * @param s The source slice.
* @return Slice_array referencing elements indicated by @a s. * @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. * @brief Return a reference to an array subset.
...@@ -405,26 +406,25 @@ namespace std ...@@ -405,26 +406,25 @@ namespace std
valarray<_Tp>& operator>>=(const valarray<_Tp>&); valarray<_Tp>& operator>>=(const valarray<_Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator*=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator*=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator/=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator/=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator%=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator%=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator+=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator+=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator-=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator-=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator^=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator^=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator|=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator|=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator&=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator&=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator<<=(const _Expr<_Dom, _Tp>&);
template<class _Dom> template<class _Dom>
valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&); valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&);
// _lib.valarray.members_ member functions: // _lib.valarray.members_ member functions:
/// Return the number of elements in array. /// Return the number of elements in array.
...@@ -444,9 +444,6 @@ namespace std ...@@ -444,9 +444,6 @@ namespace std
/// Return the maximum element using operator<(). /// Return the maximum element using operator<().
_Tp max() const; _Tp max() const;
// // FIXME: Extension
// _Tp product () const;
/** /**
* @brief Return a shifted array. * @brief Return a shifted array.
* *
...@@ -491,7 +488,7 @@ namespace std ...@@ -491,7 +488,7 @@ namespace std
* @param func Function of Tp returning Tp to apply. * @param func Function of Tp returning Tp to apply.
* @return New valarray with transformed elements. * @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. * @brief Apply a function to the array.
...@@ -503,7 +500,7 @@ namespace std ...@@ -503,7 +500,7 @@ namespace std
* @param func Function of const Tp& returning Tp to apply. * @param func Function of const Tp& returning Tp to apply.
* @return New valarray with transformed elements. * @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. * @brief Resize array.
...@@ -580,7 +577,8 @@ namespace std ...@@ -580,7 +577,8 @@ namespace std
inline inline
valarray<_Tp>::valarray(const valarray<_Tp>& __v) valarray<_Tp>::valarray(const valarray<_Tp>& __v)
: _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size)) : _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); } { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
_M_data); }
template<typename _Tp> template<typename _Tp>
inline inline
...@@ -711,9 +709,7 @@ namespace std ...@@ -711,9 +709,7 @@ namespace std
template<typename _Tp> template<typename _Tp>
inline slice_array<_Tp> inline slice_array<_Tp>
valarray<_Tp>::operator[](slice __s) 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> template<typename _Tp>
inline _Expr<_GClos<_ValArray,_Tp>, _Tp> inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
...@@ -784,13 +780,6 @@ namespace std ...@@ -784,13 +780,6 @@ namespace std
return std::__valarray_sum(_M_data, _M_data + _M_size); 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> inline valarray<_Tp>
valarray<_Tp>::shift(int __n) const valarray<_Tp>::shift(int __n) const
...@@ -805,16 +794,19 @@ namespace std ...@@ -805,16 +794,19 @@ namespace std
std::__valarray_default_construct(__a, __a + __n); std::__valarray_default_construct(__a, __a + __n);
else else
{ {
std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a); std::__valarray_copy_construct(_M_data + __n,
std::__valarray_default_construct(__a+_M_size-__n, __a + _M_size); _M_data + _M_size, __a);
std::__valarray_default_construct(__a + _M_size -__n,
__a + _M_size);
} }
} }
else // __n < 0: shift right else // __n < 0: shift right
{ {
std::__valarray_copy_construct (_M_data, _M_data+_M_size+__n, __a-__n); std::__valarray_copy_construct (_M_data, _M_data + _M_size + __n,
__a - __n);
std::__valarray_default_construct(__a, __a - __n); std::__valarray_default_construct(__a, __a - __n);
} }
return valarray<_Tp> (__a, _M_size); return valarray<_Tp>(__a, _M_size);
} }
template <class _Tp> template <class _Tp>
...@@ -827,13 +819,15 @@ namespace std ...@@ -827,13 +819,15 @@ namespace std
std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a); std::__valarray_copy_construct(_M_data, _M_data + _M_size, __a);
else if (__n > 0) // cshift left 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, _M_data + __n,
std::__valarray_copy_construct(_M_data+__n, _M_data + _M_size, __a); __a + _M_size - __n);
std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size,
__a);
} }
else // cshift right else // cshift right
{ {
std::__valarray_copy_construct std::__valarray_copy_construct
(_M_data + _M_size+__n, _M_data + _M_size, __a); (_M_data + _M_size + __n, _M_data + _M_size, __a);
std::__valarray_copy_construct std::__valarray_copy_construct
(_M_data, _M_data + _M_size+__n, __a - __n); (_M_data, _M_data + _M_size+__n, __a - __n);
} }
...@@ -862,7 +856,7 @@ namespace std ...@@ -862,7 +856,7 @@ namespace std
valarray<_Tp>::min() const valarray<_Tp>::min() const
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size > 0); _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> template<typename _Tp>
...@@ -870,23 +864,23 @@ namespace std ...@@ -870,23 +864,23 @@ namespace std
valarray<_Tp>::max() const valarray<_Tp>::max() const
{ {
_GLIBCXX_DEBUG_ASSERT(_M_size > 0); _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> template<class _Tp>
inline _Expr<_ValFunClos<_ValArray,_Tp>,_Tp> inline _Expr<_ValFunClos<_ValArray, _Tp>, _Tp>
valarray<_Tp>::apply(_Tp func(_Tp)) const valarray<_Tp>::apply(_Tp func(_Tp)) const
{ {
typedef _ValFunClos<_ValArray,_Tp> _Closure; typedef _ValFunClos<_ValArray, _Tp> _Closure;
return _Expr<_Closure,_Tp>(_Closure(*this, func)); return _Expr<_Closure, _Tp>(_Closure(*this, func));
} }
template<class _Tp> template<class _Tp>
inline _Expr<_RefFunClos<_ValArray,_Tp>,_Tp> inline _Expr<_RefFunClos<_ValArray, _Tp>, _Tp>
valarray<_Tp>::apply(_Tp func(const _Tp &)) const valarray<_Tp>::apply(_Tp func(const _Tp &)) const
{ {
typedef _RefFunClos<_ValArray,_Tp> _Closure; typedef _RefFunClos<_ValArray, _Tp> _Closure;
return _Expr<_Closure,_Tp>(_Closure(*this, func)); return _Expr<_Closure, _Tp>(_Closure(*this, func));
} }
#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \ #define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
...@@ -894,7 +888,7 @@ namespace std ...@@ -894,7 +888,7 @@ namespace std
inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \ inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
valarray<_Tp>::operator _Op() const \ valarray<_Tp>::operator _Op() const \
{ \ { \
typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \ typedef _UnClos<_Name, _ValArray, _Tp> _Closure; \
typedef typename __fun<_Name, _Tp>::result_type _Rt; \ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
return _Expr<_Closure, _Rt>(_Closure(*this)); \ return _Expr<_Closure, _Rt>(_Closure(*this)); \
} }
...@@ -941,7 +935,7 @@ _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right) ...@@ -941,7 +935,7 @@ _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \ #define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
template<class _Tp> template<class _Dom> \ template<class _Tp> template<class _Dom> \
inline valarray<_Tp>& \ 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); \ _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \
return *this; \ return *this; \
...@@ -963,32 +957,32 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right) ...@@ -963,32 +957,32 @@ _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \ #define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \ 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> \ typename __fun<_Name, _Tp>::result_type> \
operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
{ \ { \
_GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \ _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; \ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \ return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>, \ inline _Expr<_BinClos<_Name, _ValArray,_Constant, _Tp, _Tp>, \
typename __fun<_Name, _Tp>::result_type> \ typename __fun<_Name, _Tp>::result_type> \
operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \ operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \
{ \ { \
typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure; \ typedef _BinClos<_Name, _ValArray, _Constant, _Tp, _Tp> _Closure; \
typedef typename __fun<_Name, _Tp>::result_type _Rt; \ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \ return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \
} \ } \
\ \
template<typename _Tp> \ template<typename _Tp> \
inline _Expr<_BinClos<_Name,_Constant,_ValArray,_Tp,_Tp>, \ inline _Expr<_BinClos<_Name, _Constant, _ValArray, _Tp, _Tp>, \
typename __fun<_Name, _Tp>::result_type> \ typename __fun<_Name, _Tp>::result_type> \
operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \ operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \
{ \ { \
typedef _BinClos<_Name,_Constant,_ValArray,_Tp,_Tp> _Closure; \ typedef _BinClos<_Name, _Constant, _ValArray, _Tp, _Tp> _Closure; \
typedef typename __fun<_Name, _Tp>::result_type _Rt; \ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \ return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment