diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-07-08 20:48:04 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-07-08 20:48:04 +0000 |
commit | b714a4192e2ec903b99d1d8a7c664fab099f4908 (patch) | |
tree | c345e28ccd3636c8452b4c27d9d6316feb397664 /libstdc++-v3/include | |
parent | d222b827dcf997b0d161a0741017df029fa4d5d9 (diff) | |
download | gcc-b714a4192e2ec903b99d1d8a7c664fab099f4908.zip gcc-b714a4192e2ec903b99d1d8a7c664fab099f4908.tar.gz gcc-b714a4192e2ec903b99d1d8a7c664fab099f4908.tar.bz2 |
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
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/gslice.h | 181 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/gslice_array.h | 30 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/indirect_array.h | 1 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/mask_array.h | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/slice_array.h | 28 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/valarray_after.h | 395 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/valarray_array.h | 390 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/valarray_before.h | 228 | ||||
-rw-r--r-- | libstdc++-v3/include/std/std_valarray.h | 164 |
9 files changed, 781 insertions, 643 deletions
diff --git a/libstdc++-v3/include/bits/gslice.h b/libstdc++-v3/include/bits/gslice.h index 78f8a67..2dd2cab 100644 --- a/libstdc++-v3/include/bits/gslice.h +++ b/libstdc++-v3/include/bits/gslice.h @@ -40,8 +40,8 @@ #pragma GCC system_header -namespace std { - +namespace std +{ /** * @brief Class defining multi-dimensional subset of an array. * @@ -60,103 +60,112 @@ namespace std { * slice[0,2]==array[9], slice[1,0]==array[14], slice[1,1]==array[17], * slice[1,2]==array[20]. */ - class gslice + class gslice + { + public: + /// Construct an empty slice. + gslice (); + + /** + * @brief Construct a slice. + * + * Constructs a slice with as many dimensions as the length of the @a l + * and @a s arrays. + * + * @param o Offset in array of first element. + * @param l Array of dimension lengths. + * @param s Array of dimension strides between array elements. + */ + gslice(size_t, const valarray<size_t>&, const valarray<size_t>&); + + // XXX: the IS says the copy-ctor and copy-assignment operators are + // synthetized by the compiler but they are just unsuitable + // for a ref-counted semantic + /// Copy constructor. + gslice(const gslice&); + + /// Destructor. + ~gslice(); + + // XXX: See the note above. + /// Assignment operator. + gslice& operator=(const gslice&); + + /// Return array offset of first slice element. + size_t start() const; + + /// Return array of sizes of slice dimensions. + valarray<size_t> size() const; + + /// Return array of array strides for each dimension. + valarray<size_t> stride() const; + + private: + struct _Indexer { - public: - /// Construct an empty slice. - gslice (); - - /** - * @brief Construct a slice. - * - * Constructs a slice with as many dimensions as the length of the @a l - * and @a s arrays. - * - * @param o Offset in array of first element. - * @param l Array of dimension lengths. - * @param s Array of dimension strides between array elements. - */ - gslice(size_t, const valarray<size_t>&, const valarray<size_t>&); - - // XXX: the IS says the copy-ctor and copy-assignment operators are - // synthetized by the compiler but they are just unsuitable - // for a ref-counted semantic - /// Copy constructor. - gslice(const gslice&); - - /// Destructor. - ~gslice(); - - // XXX: See the note above. - /// Assignment operator. - gslice& operator=(const gslice&); - - /// Return array offset of first slice element. - size_t start() const; - - /// Return array of sizes of slice dimensions. - valarray<size_t> size() const; - - /// Return array of array strides for each dimension. - valarray<size_t> stride() const; - - private: - struct _Indexer { - size_t _M_count; - size_t _M_start; - valarray<size_t> _M_size; - valarray<size_t> _M_stride; - valarray<size_t> _M_index; // Linear array of referenced indices - _Indexer(size_t, const valarray<size_t>&, - const valarray<size_t>&); - void _M_increment_use() { ++_M_count; } - size_t _M_decrement_use() { return --_M_count; } - }; - - _Indexer* _M_index; - - template<typename _Tp> friend class valarray; + size_t _M_count; + size_t _M_start; + valarray<size_t> _M_size; + valarray<size_t> _M_stride; + valarray<size_t> _M_index; // Linear array of referenced indices + _Indexer(size_t, const valarray<size_t>&, + const valarray<size_t>&); + void + _M_increment_use() + { ++_M_count; } + + size_t + _M_decrement_use() + { return --_M_count; } }; - inline size_t - gslice::start () const - { return _M_index ? _M_index->_M_start : 0; } + _Indexer* _M_index; - inline valarray<size_t> - gslice::size () const - { return _M_index ? _M_index->_M_size : valarray<size_t>(); } + template<typename _Tp> friend class valarray; + }; - inline valarray<size_t> - gslice::stride () const - { return _M_index ? _M_index->_M_stride : valarray<size_t>(); } + inline size_t + gslice::start () const + { return _M_index ? _M_index->_M_start : 0; } - inline gslice::gslice () : _M_index(0) {} + inline valarray<size_t> + gslice::size () const + { return _M_index ? _M_index->_M_size : valarray<size_t>(); } - inline - gslice::gslice(size_t __o, const valarray<size_t>& __l, - const valarray<size_t>& __s) - : _M_index(new gslice::_Indexer(__o, __l, __s)) {} + inline valarray<size_t> + gslice::stride () const + { return _M_index ? _M_index->_M_stride : valarray<size_t>(); } - inline - gslice::gslice(const gslice& __g) : _M_index(__g._M_index) - { if (_M_index) _M_index->_M_increment_use(); } + inline gslice::gslice () : _M_index(0) {} - inline - gslice::~gslice() - { if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; } + inline + gslice::gslice(size_t __o, const valarray<size_t>& __l, + const valarray<size_t>& __s) + : _M_index(new gslice::_Indexer(__o, __l, __s)) {} - inline gslice& - gslice::operator= (const gslice& __g) - { - if (__g._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; - return *this; - } + inline + gslice::gslice(const gslice& __g) : _M_index(__g._M_index) + { if (_M_index) _M_index->_M_increment_use(); } + inline + gslice::~gslice() + { + if (_M_index && _M_index->_M_decrement_use() == 0) + delete _M_index; + } -} // std:: + inline gslice& + gslice::operator= (const gslice& __g) + { + if (__g._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; + return *this; + } +} // std:: #endif /* _GSLICE_H */ diff --git a/libstdc++-v3/include/bits/gslice_array.h b/libstdc++-v3/include/bits/gslice_array.h index 7e2e684..f0f9eec 100644 --- a/libstdc++-v3/include/bits/gslice_array.h +++ b/libstdc++-v3/include/bits/gslice_array.h @@ -40,8 +40,8 @@ #pragma GCC system_header -namespace std { - +namespace std +{ /** * @brief Reference to multi-dimensional subset of an array. * @@ -97,27 +97,27 @@ namespace std { void operator=(const _Tp&) const; template<class _Dom> - void operator=(const _Expr<_Dom,_Tp>&) const; + void operator=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator*=(const _Expr<_Dom,_Tp>&) const; + void operator*=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator/=(const _Expr<_Dom,_Tp>&) const; + void operator/=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator%=(const _Expr<_Dom,_Tp>&) const; + void operator%=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator+=(const _Expr<_Dom,_Tp>&) const; + void operator+=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator-=(const _Expr<_Dom,_Tp>&) const; + void operator-=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator^=(const _Expr<_Dom,_Tp>&) const; + void operator^=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator&=(const _Expr<_Dom,_Tp>&) const; + void operator&=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator|=(const _Expr<_Dom,_Tp>&) const; + void operator|=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator<<=(const _Expr<_Dom,_Tp>&) const; + void operator<<=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator>>=(const _Expr<_Dom,_Tp>&) const; + void operator>>=(const _Expr<_Dom, _Tp>&) const; private: _Array<_Tp> _M_array; @@ -137,13 +137,11 @@ namespace std { const valarray<size_t>& __i) : _M_array(__a), _M_index(__i) {} - template<typename _Tp> inline gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a) : _M_array(__a._M_array), _M_index(__a._M_index) {} - template<typename _Tp> inline gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a) @@ -186,7 +184,7 @@ namespace std { gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \ { \ _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), \ - _Array<_Tp>(__v), __v.size()); \ + _Array<_Tp>(__v), __v.size()); \ } \ \ template<typename _Tp> \ diff --git a/libstdc++-v3/include/bits/indirect_array.h b/libstdc++-v3/include/bits/indirect_array.h index 912f522..b5de990 100644 --- a/libstdc++-v3/include/bits/indirect_array.h +++ b/libstdc++-v3/include/bits/indirect_array.h @@ -156,7 +156,6 @@ namespace std return *this; } - template<typename _Tp> inline void indirect_array<_Tp>::operator=(const _Tp& __t) const diff --git a/libstdc++-v3/include/bits/mask_array.h b/libstdc++-v3/include/bits/mask_array.h index 1a694f3..0393357 100644 --- a/libstdc++-v3/include/bits/mask_array.h +++ b/libstdc++-v3/include/bits/mask_array.h @@ -40,8 +40,8 @@ #pragma GCC system_header -namespace std { - +namespace std +{ /** * @brief Reference to selected subset of an array. * @@ -128,13 +128,12 @@ namespace std { const size_t _M_sz; const _Array<bool> _M_mask; - const _Array<_Tp> _M_array; + const _Array<_Tp> _M_array; // not implemented mask_array(); }; - template<typename _Tp> 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) {} diff --git a/libstdc++-v3/include/bits/slice_array.h b/libstdc++-v3/include/bits/slice_array.h index 31c89bc..42da0d2 100644 --- a/libstdc++-v3/include/bits/slice_array.h +++ b/libstdc++-v3/include/bits/slice_array.h @@ -90,7 +90,7 @@ namespace std inline slice::slice(size_t __o, size_t __d, size_t __s) - : _M_off(__o), _M_sz(__d), _M_st(__s) {} + : _M_off(__o), _M_sz(__d), _M_st(__s) {} inline size_t slice::start() const @@ -160,34 +160,34 @@ namespace std // ~slice_array (); template<class _Dom> - void operator=(const _Expr<_Dom,_Tp>&) const; + void operator=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator*=(const _Expr<_Dom,_Tp>&) const; + void operator*=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator/=(const _Expr<_Dom,_Tp>&) const; + void operator/=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator%=(const _Expr<_Dom,_Tp>&) const; + void operator%=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator+=(const _Expr<_Dom,_Tp>&) const; + void operator+=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator-=(const _Expr<_Dom,_Tp>&) const; + void operator-=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator^=(const _Expr<_Dom,_Tp>&) const; + void operator^=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator&=(const _Expr<_Dom,_Tp>&) const; + void operator&=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator|=(const _Expr<_Dom,_Tp>&) const; + void operator|=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator<<=(const _Expr<_Dom,_Tp>&) const; + void operator<<=(const _Expr<_Dom, _Tp>&) const; template<class _Dom> - void operator>>=(const _Expr<_Dom,_Tp>&) const; + void operator>>=(const _Expr<_Dom, _Tp>&) const; private: friend class valarray<_Tp>; slice_array(_Array<_Tp>, const slice&); - const size_t _M_sz; - const size_t _M_stride; + const size_t _M_sz; + const size_t _M_stride; const _Array<_Tp> _M_array; // not implemented diff --git a/libstdc++-v3/include/bits/valarray_after.h b/libstdc++-v3/include/bits/valarray_after.h index b74cab5..e231127 100644 --- a/libstdc++-v3/include/bits/valarray_after.h +++ b/libstdc++-v3/include/bits/valarray_after.h @@ -1,6 +1,7 @@ // 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 // software; you can redistribute it and/or modify it under the @@ -41,92 +42,120 @@ namespace std { - - // - // gslice_array closure. - // - template<class _Dom> class _GBase { + // + // gslice_array closure. + // + template<class _Dom> + class _GBase + { public: - typedef typename _Dom::value_type value_type; - - _GBase (const _Dom& __e, const valarray<size_t>& __i) - : _M_expr (__e), _M_index(__i) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_index[__i]]; } - size_t size () const { return _M_index.size(); } + typedef typename _Dom::value_type value_type; + + _GBase (const _Dom& __e, const valarray<size_t>& __i) + : _M_expr (__e), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } private: - const _Dom& _M_expr; - const valarray<size_t>& _M_index; + const _Dom& _M_expr; + const valarray<size_t>& _M_index; }; - template<typename _Tp> class _GBase<_Array<_Tp> > { + template<typename _Tp> + class _GBase<_Array<_Tp> > + { public: - typedef _Tp value_type; - - _GBase (_Array<_Tp> __a, const valarray<size_t>& __i) - : _M_array (__a), _M_index(__i) {} - value_type operator[] (size_t __i) const - { return _M_array._M_data[_M_index[__i]]; } - size_t size () const { return _M_index.size(); } + typedef _Tp value_type; + + _GBase (_Array<_Tp> __a, const valarray<size_t>& __i) + : _M_array (__a), _M_index(__i) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[_M_index[__i]]; } + + size_t + size () const + { return _M_index.size(); } private: - const _Array<_Tp> _M_array; - const valarray<size_t>& _M_index; + const _Array<_Tp> _M_array; + const valarray<size_t>& _M_index; }; - template<class _Dom> struct _GClos<_Expr,_Dom> : _GBase<_Dom> { - typedef _GBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _GClos (const _Dom& __e, const valarray<size_t>& __i) - : _Base (__e, __i) {} + template<class _Dom> + struct _GClos<_Expr, _Dom> + : _GBase<_Dom> + { + typedef _GBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _GClos (const _Dom& __e, const valarray<size_t>& __i) + : _Base (__e, __i) {} }; - template<typename _Tp> - struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > { - typedef _GBase<_Array<_Tp> > _Base; - typedef typename _Base::value_type value_type; - - _GClos (_Array<_Tp> __a, const valarray<size_t>& __i) - : _Base (__a, __i) {} + template<typename _Tp> + struct _GClos<_ValArray, _Tp> + : _GBase<_Array<_Tp> > + { + typedef _GBase<_Array<_Tp> > _Base; + typedef typename _Base::value_type value_type; + + _GClos (_Array<_Tp> __a, const valarray<size_t>& __i) + : _Base (__a, __i) {} }; - // - // indirect_array closure - // - template<class _Dom> class _IBase { + // + // indirect_array closure + // + template<class _Dom> + class _IBase + { public: - typedef typename _Dom::value_type value_type; + typedef typename _Dom::value_type value_type; - _IBase (const _Dom& __e, const valarray<size_t>& __i) - : _M_expr (__e), _M_index (__i) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_index[__i]]; } - size_t size() const { return _M_index.size(); } + _IBase (const _Dom& __e, const valarray<size_t>& __i) + : _M_expr (__e), _M_index (__i) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_index[__i]]; } + + size_t size() const { return _M_index.size(); } private: - const _Dom& _M_expr; - const valarray<size_t>& _M_index; + const _Dom& _M_expr; + const valarray<size_t>& _M_index; }; - template<class _Dom> struct _IClos<_Expr,_Dom> : _IBase<_Dom> { - typedef _IBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _IClos (const _Dom& __e, const valarray<size_t>& __i) - : _Base (__e, __i) {} + template<class _Dom> + struct _IClos<_Expr, _Dom> + : _IBase<_Dom> + { + typedef _IBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _IClos (const _Dom& __e, const valarray<size_t>& __i) + : _Base (__e, __i) {} }; - template<typename _Tp> - struct _IClos<_ValArray,_Tp> : _IBase<valarray<_Tp> > { - typedef _IBase<valarray<_Tp> > _Base; - typedef _Tp value_type; - - _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i) - : _Base (__a, __i) {} + template<typename _Tp> + struct _IClos<_ValArray, _Tp> + : _IBase<valarray<_Tp> > + { + typedef _IBase<valarray<_Tp> > _Base; + typedef _Tp value_type; + + _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i) + : _Base (__a, __i) {} }; - + // // class _Expr // @@ -146,17 +175,17 @@ namespace std valarray<value_type> operator[](const valarray<bool>&) const; valarray<value_type> operator[](const valarray<size_t>&) const; - _Expr<_UnClos<__unary_plus,std::_Expr,_Clos>, value_type> - operator+() const; + _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type> + operator+() const; - _Expr<_UnClos<__negate,std::_Expr,_Clos>, value_type> - operator-() const; + _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type> + operator-() const; - _Expr<_UnClos<__bitwise_not,std::_Expr,_Clos>, value_type> - operator~() const; + _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type> + operator~() const; - _Expr<_UnClos<__logical_not,std::_Expr,_Clos>, bool> - operator!() const; + _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool> + operator!() const; size_t size() const; value_type sum() const; @@ -176,41 +205,42 @@ namespace std template<class _Clos, typename _Tp> 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> inline const _Clos& - _Expr<_Clos,_Tp>::operator()() const + _Expr<_Clos, _Tp>::operator()() const { return _M_closure; } template<class _Clos, typename _Tp> inline _Tp - _Expr<_Clos,_Tp>::operator[](size_t __i) const + _Expr<_Clos, _Tp>::operator[](size_t __i) const { return _M_closure[__i]; } template<class _Clos, typename _Tp> inline valarray<_Tp> - _Expr<_Clos,_Tp>::operator[](slice __s) const + _Expr<_Clos, _Tp>::operator[](slice __s) const { return _M_closure[__s]; } template<class _Clos, typename _Tp> inline valarray<_Tp> - _Expr<_Clos,_Tp>::operator[](const gslice& __gs) const + _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const { return _M_closure[__gs]; } template<class _Clos, typename _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]; } template<class _Clos, typename _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]; } template<class _Clos, typename _Tp> 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> inline valarray<_Tp> @@ -235,7 +265,7 @@ namespace std // XXX: replace this with a more robust summation algorithm. template<class _Clos, typename _Tp> inline _Tp - _Expr<_Clos,_Tp>::sum() const + _Expr<_Clos, _Tp>::sum() const { size_t __n = _M_closure.size(); if (__n == 0) @@ -260,20 +290,20 @@ namespace std { return __valarray_max(_M_closure); } template<class _Dom, typename _Tp> - inline _Expr<_UnClos<__logical_not,_Expr,_Dom>, bool> - _Expr<_Dom,_Tp>::operator!() const + inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool> + _Expr<_Dom, _Tp>::operator!() const { - typedef _UnClos<__logical_not,std::_Expr,_Dom> _Closure; - return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); + typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure; + return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); } #define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \ template<class _Dom, typename _Tp> \ - inline _Expr<_UnClos<_Name,std::_Expr,_Dom>,_Tp> \ - _Expr<_Dom,_Tp>::operator _Op() const \ + inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \ + _Expr<_Dom, _Tp>::operator _Op() const \ { \ - typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); \ + typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \ } _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus) @@ -282,67 +312,70 @@ namespace std #undef _DEFINE_EXPR_UNARY_OPERATOR - #define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \ template<class _Dom1, class _Dom2> \ - inline _Expr<_BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2>, \ - typename __fun<_Name, typename _Dom1::value_type>::result_type>\ - operator _Op(const _Expr<_Dom1,typename _Dom1::value_type>& __v, \ - const _Expr<_Dom2,typename _Dom2::value_type>& __w) \ - { \ - typedef typename _Dom1::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Expr,_Expr,_Dom1,_Dom2> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__v(), __w())); \ - } \ + inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \ + typename __fun<_Name, typename _Dom1::value_type>::result_type> \ + operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __w) \ + { \ + typedef typename _Dom1::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \ + } \ \ -template<class _Dom> \ -inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>,\ - 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) \ -{ \ - typedef typename _Dom::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Expr,_Constant,_Dom,_Arg> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__v(), __t)); \ -} \ + template<class _Dom> \ + inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \ + typename _Dom::value_type>, \ + 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) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \ + } \ \ -template<class _Dom> \ -inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_Dom>,\ - typename __fun<_Name, typename _Dom::value_type>::result_type>\ -operator _Op(const typename _Dom::value_type& __t, \ - const _Expr<_Dom,typename _Dom::value_type>& __v) \ -{ \ - typedef typename _Dom::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Constant,_Expr,_Arg,_Dom> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__t, __v())); \ -} \ + template<class _Dom> \ + inline _Expr<_BinClos<_Name, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + operator _Op(const typename _Dom::value_type& __t, \ + const _Expr<_Dom, typename _Dom::value_type>& __v) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__t, __v())); \ + } \ \ -template<class _Dom> \ -inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>,\ - 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) \ -{ \ - typedef typename _Dom::value_type _Arg; \ - typedef typename __fun<_Name, _Arg>::result_type _Value; \ - typedef _BinClos<_Name,_Expr,_ValArray,_Dom,_Arg> _Closure; \ - return _Expr<_Closure,_Value>(_Closure(__e(), __v)); \ -} \ + template<class _Dom> \ + inline _Expr<_BinClos<_Name, _Expr, _ValArray, \ + _Dom, typename _Dom::value_type>, \ + 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) \ + { \ + typedef typename _Dom::value_type _Arg; \ + typedef typename __fun<_Name, _Arg>::result_type _Value; \ + typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \ + } \ \ -template<class _Dom> \ -inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_Dom>,\ - typename __fun<_Name, typename _Dom::value_type>::result_type>\ -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 __fun<_Name, _Tp>::result_type _Value; \ - typedef _BinClos<_Name,_ValArray,_Expr,_Tp,_Dom> _Closure; \ - return _Expr<_Closure,_Value> (_Closure (__v, __e ())); \ -} + template<class _Dom> \ + inline _Expr<_BinClos<_Name, _ValArray, _Expr, \ + typename _Dom::value_type, _Dom>, \ + typename __fun<_Name, typename _Dom::value_type>::result_type> \ + 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 __fun<_Name, _Tp>::result_type _Value; \ + typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \ + } _DEFINE_EXPR_BINARY_OPERATOR(+, __plus) _DEFINE_EXPR_BINARY_OPERATOR(-, __minus) @@ -367,20 +400,21 @@ operator _Op(const valarray<typename _Dom::value_type>& __v, \ #define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \ template<class _Dom> \ - inline _Expr<_UnClos<__##_Name,_Expr,_Dom>,typename _Dom::value_type>\ - _Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \ + inline _Expr<_UnClos<__##_Name, _Expr, _Dom>, \ + typename _Dom::value_type> \ + _Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _UnClos<__##_Name,_Expr,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__e())); \ + typedef _UnClos<__##_Name, _Expr, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e())); \ } \ \ template<typename _Tp> \ - inline _Expr<_UnClos<__##_Name,_ValArray,_Tp>,_Tp> \ + inline _Expr<_UnClos<__##_Name, _ValArray, _Tp>, _Tp> \ _Name(const valarray<_Tp>& __v) \ { \ - typedef _UnClos<__##_Name,_ValArray,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v)); \ + typedef _UnClos<__##_Name, _ValArray, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v)); \ } _DEFINE_EXPR_UNARY_FUNCTION(abs) @@ -402,86 +436,86 @@ operator _Op(const valarray<typename _Dom::value_type>& __v, \ #define _DEFINE_EXPR_BINARY_FUNCTION(_Fun) \ 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> \ - _Fun(const _Expr<_Dom1,typename _Dom1::value_type>& __e1, \ - const _Expr<_Dom2,typename _Dom2::value_type>& __e2) \ + _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \ + const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \ { \ typedef typename _Dom1::value_type _Tp; \ - typedef _BinClos<__##_Fun,_Expr,_Expr,_Dom1,_Dom2> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__e1(), __e2())); \ + typedef _BinClos<__##_Fun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \ } \ \ template<class _Dom> \ inline _Expr<_BinClos<__##_Fun, _Expr, _ValArray, _Dom, \ 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) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure;\ - return _Expr<_Closure,_Tp>(_Closure(__e(), __v)); \ + typedef _BinClos<__##_Fun, _Expr, _ValArray, _Dom, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \ } \ \ template<class _Dom> \ inline _Expr<_BinClos<__##_Fun, _ValArray, _Expr, \ - typename _Dom::value_type,_Dom>, \ + typename _Dom::value_type, _Dom>, \ typename _Dom::value_type> \ _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 _BinClos<__##_Fun,_ValArray,_Expr,_Tp,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v, __e())); \ + typedef _BinClos<__##_Fun, _ValArray, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \ } \ \ 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> \ _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ const typename _Dom::value_type& __t) \ { \ typedef typename _Dom::value_type _Tp; \ - typedef _BinClos<__##_Fun,_Expr,_Constant,_Dom,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__e(), __t)); \ + typedef _BinClos<__##_Fun, _Expr, _Constant, _Dom, _Tp> _Closure;\ + return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \ } \ \ template<class _Dom> \ - inline _Expr<_BinClos<__##_Fun,_Constant,_Expr, \ - typename _Dom::value_type,_Dom>, \ + inline _Expr<_BinClos<__##_Fun, _Constant, _Expr, \ + typename _Dom::value_type, _Dom>, \ typename _Dom::value_type> \ _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 _BinClos<__##_Fun, _Constant,_Expr,_Tp,_Dom> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__t, __e())); \ + typedef _BinClos<__##_Fun, _Constant, _Expr, _Tp, _Dom> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \ } \ \ 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) \ { \ - typedef _BinClos<__##_Fun,_ValArray,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v, __w)); \ + typedef _BinClos<__##_Fun, _ValArray, _ValArray, _Tp, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \ } \ \ 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) \ { \ - typedef _BinClos<__##_Fun,_ValArray,_Constant,_Tp,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__v, __t)); \ + typedef _BinClos<__##_Fun, _ValArray, _Constant, _Tp, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \ } \ \ 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) \ { \ - typedef _BinClos<__##_Fun,_Constant,_ValArray,_Tp,_Tp> _Closure; \ - return _Expr<_Closure,_Tp>(_Closure(__t, __v)); \ + typedef _BinClos<__##_Fun, _Constant, _ValArray, _Tp, _Tp> _Closure; \ + return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \ } _DEFINE_EXPR_BINARY_FUNCTION(atan2) @@ -491,7 +525,6 @@ _DEFINE_EXPR_BINARY_FUNCTION(pow) } // std:: - #endif /* _CPP_VALARRAY_AFTER_H */ // Local Variables: diff --git a/libstdc++-v3/include/bits/valarray_array.h b/libstdc++-v3/include/bits/valarray_array.h index e18e8e8..a104f7b 100644 --- a/libstdc++-v3/include/bits/valarray_array.h +++ b/libstdc++-v3/include/bits/valarray_array.h @@ -79,7 +79,10 @@ namespace std // valarrays aren't required to be exception safe. inline static void _S_do_it(_Tp* __restrict__ __b, _Tp* __restrict__ __e) - { while (__b != __e) new(__b++) _Tp(); } + { + while (__b != __e) + new(__b++) _Tp(); + } }; template<typename _Tp> @@ -88,7 +91,7 @@ namespace std // For fundamental types, it suffices to say 'memset()' inline static void _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> @@ -109,7 +112,10 @@ namespace std // valarrays aren't required to be exception safe. inline static void _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> @@ -117,7 +123,10 @@ namespace std { inline static void _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> @@ -141,7 +150,10 @@ namespace std inline static void _S_do_it(const _Tp* __restrict__ __b, const _Tp* __restrict__ __e, _Tp* __restrict__ __o) - { while (__b != __e) new(__o++) _Tp(*__b++); } + { + while (__b != __e) + new(__o++) _Tp(*__b++); + } }; template<typename _Tp> @@ -170,9 +182,17 @@ namespace std size_t __s, _Tp* __restrict__ __o) { if (__is_fundamental<_Tp>::_M_type) - while (__n--) { *__o++ = *__a; __a += __s; } + while (__n--) + { + *__o++ = *__a; + __a += __s; + } 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>]] @@ -183,9 +203,11 @@ namespace std _Tp* __restrict__ __o, size_t __n) { if (__is_fundamental<_Tp>::_M_type) - while (__n--) *__o++ = __a[*__i++]; + while (__n--) + *__o++ = __a[*__i++]; 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. @@ -194,28 +216,41 @@ namespace std __valarray_destroy_elements(_Tp* __restrict__ __b, _Tp* __restrict__ __e) { 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 template<typename _Tp> inline void - __valarray_fill (_Tp* __restrict__ __a, size_t __n, const _Tp& __t) - { while (__n--) *__a++ = __t; } + __valarray_fill(_Tp* __restrict__ __a, size_t __n, const _Tp& __t) + { + while (__n--) + *__a++ = __t; + } // fill strided array __a[<__n-1 : __s>] with __t template<typename _Tp> inline void - __valarray_fill (_Tp* __restrict__ __a, size_t __n, - size_t __s, const _Tp& __t) - { for (size_t __i=0; __i<__n; ++__i, __a+=__s) *__a = __t; } + __valarray_fill(_Tp* __restrict__ __a, size_t __n, + size_t __s, const _Tp& __t) + { + for (size_t __i = 0; __i < __n; ++__i, __a += __s) + *__a = __t; + } // fill indir ect array __a[__i[<__n>]] with __i template<typename _Tp> inline void __valarray_fill(_Tp* __restrict__ __a, const size_t* __restrict__ __i, 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>] // For non-fundamental types, it is wrong to say 'memcpy()' @@ -224,7 +259,10 @@ namespace std { inline static void _S_do_it(const _Tp* __restrict__ __a, size_t __n, _Tp* __restrict__ __b) - { while (__n--) *__b++ = *__a++; } + { + while(__n--) + *__b++ = *__a++; + } }; template<typename _Tp> @@ -239,7 +277,7 @@ namespace std template<typename _Tp> inline void __valarray_copy(const _Tp* __restrict__ __a, size_t __n, - _Tp* __restrict__ __b) + _Tp* __restrict__ __b) { _Array_copier<_Tp, __is_fundamental<_Tp>::_M_type>:: _S_do_it(__a, __n, __b); @@ -249,15 +287,21 @@ namespace std template<typename _Tp> inline void __valarray_copy(const _Tp* __restrict__ __a, size_t __n, size_t __s, - _Tp* __restrict__ __b) - { for (size_t __i=0; __i<__n; ++__i, ++__b, __a += __s) *__b = *__a; } + _Tp* __restrict__ __b) + { + 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>] template<typename _Tp> inline void __valarray_copy(const _Tp* __restrict__ __a, _Tp* __restrict__ __b, - size_t __n, size_t __s) - { for (size_t __i=0; __i<__n; ++__i, ++__a, __b+=__s) *__b = *__a; } + size_t __n, size_t __s) + { + for (size_t __i = 0; __i < __n; ++__i, ++__a, __b += __s) + *__b = *__a; + } // Copy strided array __src[<__n : __s1>] into another // strided array __dst[< : __s2>]. Their sizes must match. @@ -267,7 +311,7 @@ namespace std _Tp* __restrict__ __dst, size_t __s2) { 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 __valarray_copy (const _Tp* __restrict__ __a, const size_t* __restrict__ __i, _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>]] template<typename _Tp> inline void __valarray_copy (const _Tp* __restrict__ __a, size_t __n, _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 // another indexed array __dst[<__j>]. @@ -310,7 +360,8 @@ namespace std __valarray_sum(const _Tp* __restrict__ __f, const _Tp* __restrict__ __l) { _Tp __r = _Tp(); - while (__f != __l) __r += *__f++; + while (__f != __l) + __r += *__f++; return __r; } @@ -321,7 +372,8 @@ namespace std const _Tp* __restrict__ __l) { _Tp __r = _Tp(1); - while (__f != __l) __r = __r * *__f++; + while (__f != __l) + __r = __r * *__f++; return __r; } @@ -367,12 +419,12 @@ namespace std template<typename _Tp> struct _Array { - explicit _Array (size_t); - explicit _Array (_Tp* const __restrict__); - explicit _Array (const valarray<_Tp>&); - _Array (const _Tp* __restrict__, size_t); + explicit _Array(size_t); + explicit _Array(_Tp* const __restrict__); + explicit _Array(const valarray<_Tp>&); + _Array(const _Tp* __restrict__, size_t); - _Tp* begin () const; + _Tp* begin() const; _Tp* const __restrict__ _M_data; }; @@ -380,18 +432,18 @@ namespace std template<typename _Tp> inline void __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> inline void - __valarray_fill (_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) - { std::__valarray_fill (__a._M_data, __n, __s, __t); } + __valarray_fill(_Array<_Tp> __a, size_t __n, size_t __s, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __n, __s, __t); } template<typename _Tp> inline void - __valarray_fill (_Array<_Tp> __a, _Array<size_t> __i, - size_t __n, const _Tp& __t) - { std::__valarray_fill (__a._M_data, __i._M_data, __n, __t); } + __valarray_fill(_Array<_Tp> __a, _Array<size_t> __i, + size_t __n, const _Tp& __t) + { std::__valarray_fill(__a._M_data, __i._M_data, __n, __t); } // Copy a plain array __a[<__n>] into a play array __b[<>] template<typename _Tp> @@ -424,14 +476,14 @@ namespace std template<typename _Tp> inline void __valarray_copy(_Array<_Tp> __a, _Array<size_t> __i, - _Array<_Tp> __b, size_t __n) + _Array<_Tp> __b, size_t __n) { std::__valarray_copy(__a._M_data, __i._M_data, __b._M_data, __n); } // Copy a plain array __a[<__n>] in an indexed array __b[__i[<__n>]] template<typename _Tp> inline void __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, - _Array<size_t> __i) + _Array<size_t> __i) { std::__valarray_copy(__a._M_data, __n, __b._M_data, __i._M_data); } // Copy the __n first elements of an indexed array __src[<__i>] into @@ -447,22 +499,24 @@ namespace std template<typename _Tp> inline - _Array<_Tp>::_Array (size_t __n) - : _M_data(__valarray_get_storage<_Tp>(__n)) + _Array<_Tp>::_Array(size_t __n) + : _M_data(__valarray_get_storage<_Tp>(__n)) { std::__valarray_default_construct(_M_data, _M_data + __n); } template<typename _Tp> inline - _Array<_Tp>::_Array (_Tp* const __restrict__ __p) : _M_data (__p) {} + _Array<_Tp>::_Array(_Tp* const __restrict__ __p) + : _M_data (__p) {} template<typename _Tp> - inline _Array<_Tp>::_Array (const valarray<_Tp>& __v) - : _M_data (__v._M_data) {} + inline + _Array<_Tp>::_Array(const valarray<_Tp>& __v) + : _M_data (__v._M_data) {} template<typename _Tp> inline - _Array<_Tp>::_Array (const _Tp* __restrict__ __b, size_t __s) - : _M_data(__valarray_get_storage<_Tp>(__s)) + _Array<_Tp>::_Array(const _Tp* __restrict__ __b, size_t __s) + : _M_data(__valarray_get_storage<_Tp>(__s)) { std::__valarray_copy_construct(__b, __s, _M_data); } template<typename _Tp> @@ -471,138 +525,152 @@ namespace std { return _M_data; } #define _DEFINE_ARRAY_FUNCTION(_Op, _Name) \ -template<typename _Tp> \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, const _Tp& __t) \ -{ \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p) \ - *__p _Op##= __t; \ -} \ + template<typename _Tp> \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, const _Tp& __t) \ + { \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; ++__p) \ + *__p _Op##= __t; \ + } \ \ -template<typename _Tp> \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ -{ \ - _Tp* __p = __a._M_data; \ - for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__p, ++__q) \ - *__p _Op##= *__q; \ -} \ + template<typename _Tp> \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b) \ + { \ + _Tp* __p = __a._M_data; \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; ++__p, ++__q) \ + *__p _Op##= *__q; \ + } \ \ -template<typename _Tp, class _Dom> \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, \ - const _Expr<_Dom,_Tp>& __e, size_t __n) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, ++__p) *__p _Op##= __e[__i]; \ -} \ + template<typename _Tp, class _Dom> \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__p) \ + *__p _Op##= __e[__i]; \ + } \ \ -template<typename _Tp> \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, size_t __s, \ - _Array<_Tp> __b) \ -{ \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__s*__n; __p+=__s, ++__q) \ - *__p _Op##= *__q; \ -} \ + template<typename _Tp> \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, size_t __s, \ + _Array<_Tp> __b) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \ + __p += __s, ++__q) \ + *__p _Op##= *__q; \ + } \ \ -template<typename _Tp> \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array<_Tp> __b, \ - size_t __n, size_t __s) \ -{ \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, __q+=__s) \ - *__p _Op##= *__q; \ -} \ + template<typename _Tp> \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<_Tp> __b, \ + size_t __n, size_t __s) \ + { \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, __q += __s) \ + *__p _Op##= *__q; \ + } \ \ -template<typename _Tp, class _Dom> \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __s, \ - const _Expr<_Dom,_Tp>& __e, size_t __n) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p _Op##= __e[__i]; \ -} \ + template<typename _Tp, class _Dom> \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __s, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, __p += __s) \ + *__p _Op##= __e[__i]; \ + } \ \ -template<typename _Tp> \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \ - _Array<_Tp> __b, size_t __n) \ -{ \ - _Tp* __q (__b._M_data); \ - for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__q) \ + template<typename _Tp> \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \ + _Array<_Tp> __b, size_t __n) \ + { \ + _Tp* __q(__b._M_data); \ + for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \ + ++__j, ++__q) \ __a._M_data[*__j] _Op##= *__q; \ -} \ + } \ \ -template<typename _Tp> \ -inline void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ - _Array<_Tp> __b, _Array<size_t> __i) \ -{ \ - _Tp* __p (__a._M_data); \ - for (size_t* __j=__i._M_data; __j<__i._M_data+__n; ++__j, ++__p) \ + template<typename _Tp> \ + inline void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array<size_t> __i) \ + { \ + _Tp* __p(__a._M_data); \ + for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \ + ++__j, ++__p) \ *__p _Op##= __b._M_data[*__j]; \ -} \ + } \ \ -template<typename _Tp, class _Dom> \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array<size_t> __i, \ - const _Expr<_Dom, _Tp>& __e, size_t __n) \ -{ \ - size_t* __j (__i._M_data); \ - for (size_t __k=0; __k<__n; ++__k, ++__j) \ - __a._M_data[*__j] _Op##= __e[__k]; \ -} \ + template<typename _Tp, class _Dom> \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<size_t> __i, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + size_t* __j(__i._M_data); \ + for (size_t __k = 0; __k<__n; ++__k, ++__j) \ + __a._M_data[*__j] _Op##= __e[__k]; \ + } \ \ -template<typename _Tp> \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \ - _Array<_Tp> __b, size_t __n) \ -{ \ - bool* ok (__m._M_data); \ - _Tp* __p (__a._M_data); \ - for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++ok, ++__p) { \ - while (! *ok) { \ - ++ok; \ - ++__p; \ + template<typename _Tp> \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \ + _Array<_Tp> __b, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \ + ++__q, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= *__q; \ } \ - *__p _Op##= *__q; \ } \ -} \ \ -template<typename _Tp> \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, size_t __n, \ - _Array<_Tp> __b, _Array<bool> __m) \ -{ \ - bool* ok (__m._M_data); \ - _Tp* __q (__b._M_data); \ - for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++ok, ++__q) { \ - while (! *ok) { \ - ++ok; \ - ++__q; \ + template<typename _Tp> \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \ + _Array<_Tp> __b, _Array<bool> __m) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __q(__b._M_data); \ + for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \ + ++__p, ++__ok, ++__q) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__q; \ + } \ + *__p _Op##= *__q; \ } \ - *__p _Op##= *__q; \ } \ -} \ \ -template<typename _Tp, class _Dom> \ -void \ -_Array_augmented_##_Name (_Array<_Tp> __a, _Array<bool> __m, \ - const _Expr<_Dom, _Tp>& __e, size_t __n) \ -{ \ - bool* ok(__m._M_data); \ - _Tp* __p (__a._M_data); \ - for (size_t __i=0; __i<__n; ++__i, ++ok, ++__p) { \ - while (! *ok) { \ - ++ok; \ - ++__p; \ + template<typename _Tp, class _Dom> \ + void \ + _Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \ + const _Expr<_Dom, _Tp>& __e, size_t __n) \ + { \ + bool* __ok(__m._M_data); \ + _Tp* __p(__a._M_data); \ + for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \ + { \ + while (! *__ok) \ + { \ + ++__ok; \ + ++__p; \ + } \ + *__p _Op##= __e[__i]; \ } \ - *__p _Op##= __e[__i]; \ - } \ -} + } _DEFINE_ARRAY_FUNCTION(+, __plus) _DEFINE_ARRAY_FUNCTION(-, __minus) diff --git a/libstdc++-v3/include/bits/valarray_before.h b/libstdc++-v3/include/bits/valarray_before.h index 263ac2f..e1576f0 100644 --- a/libstdc++-v3/include/bits/valarray_before.h +++ b/libstdc++-v3/include/bits/valarray_before.h @@ -1,6 +1,7 @@ // 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 // software; you can redistribute it and/or modify it under the @@ -66,85 +67,99 @@ namespace std struct __abs { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return abs(__t); } + _Tp operator()(const _Tp& __t) const + { return abs(__t); } }; struct __cos { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return cos(__t); } + _Tp operator()(const _Tp& __t) const + { return cos(__t); } }; struct __acos { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return acos(__t); } + _Tp operator()(const _Tp& __t) const + { return acos(__t); } }; struct __cosh { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return cosh(__t); } + _Tp operator()(const _Tp& __t) const + { return cosh(__t); } }; struct __sin { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return sin(__t); } + _Tp operator()(const _Tp& __t) const + { return sin(__t); } }; struct __asin { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return asin(__t); } + _Tp operator()(const _Tp& __t) const + { return asin(__t); } }; struct __sinh { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return sinh(__t); } + _Tp operator()(const _Tp& __t) const + { return sinh(__t); } }; struct __tan { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return tan(__t); } + _Tp operator()(const _Tp& __t) const + { return tan(__t); } }; struct __atan { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return atan(__t); } + _Tp operator()(const _Tp& __t) const + { return atan(__t); } }; struct __tanh { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return tanh(__t); } + _Tp operator()(const _Tp& __t) const + { return tanh(__t); } }; struct __exp { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return exp(__t); } + _Tp operator()(const _Tp& __t) const + { return exp(__t); } }; struct __log { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return log(__t); } + _Tp operator()(const _Tp& __t) const + { return log(__t); } }; struct __log10 { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return log10(__t); } + _Tp operator()(const _Tp& __t) const + { return log10(__t); } }; struct __sqrt { 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 @@ -154,19 +169,22 @@ namespace std struct __unary_plus { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return +__t; } + _Tp operator()(const _Tp& __t) const + { return +__t; } }; struct __negate { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return -__t; } + _Tp operator()(const _Tp& __t) const + { return -__t; } }; struct __bitwise_not { template<typename _Tp> - _Tp operator()(const _Tp& __t) const { return ~__t; } + _Tp operator()(const _Tp& __t) const + { return ~__t; } }; struct __plus @@ -381,9 +399,9 @@ namespace std typedef bool result_type; }; - // - // Apply function taking a value/const reference closure - // + // + // Apply function taking a value/const reference closure + // template<typename _Dom, typename _Arg> class _FunBase @@ -392,7 +410,7 @@ namespace std typedef typename _Dom::value_type value_type; _FunBase(const _Dom& __e, value_type __f(_Arg)) - : _M_expr(__e), _M_func(__f) {} + : _M_expr(__e), _M_func(__f) {} value_type operator[](size_t __i) const { return _M_func (_M_expr[__i]); } @@ -400,8 +418,8 @@ namespace std size_t size() const { return _M_expr.size ();} private: - const _Dom& _M_expr; - value_type (*_M_func)(_Arg); + const _Dom& _M_expr; + value_type (*_M_func)(_Arg); }; template<class _Dom> @@ -424,25 +442,26 @@ namespace std }; template<class _Dom> - struct _RefFunClos<_Expr,_Dom> : - _FunBase<_Dom, const typename _Dom::value_type&> + struct _RefFunClos<_Expr, _Dom> + : _FunBase<_Dom, const typename _Dom::value_type&> { typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base; typedef typename _Base::value_type value_type; typedef value_type _Tp; _RefFunClos(const _Dom& __e, _Tp __f(const _Tp&)) - : _Base(__e, __f) {} + : _Base(__e, __f) {} }; 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 _Tp value_type; _RefFunClos(const valarray<_Tp>& __v, _Tp __f(const _Tp&)) - : _Base(__v, __f) {} + : _Base(__v, __f) {} }; // @@ -462,13 +481,14 @@ namespace std { return _Oper()(_M_expr[__i]); } size_t size() const { return _M_expr.size(); } - + private: const _Arg& _M_expr; }; 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 _UnBase<_Oper, _Dom> _Base; @@ -478,7 +498,8 @@ namespace std }; 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 _UnBase<_Oper, valarray<_Tp> > _Base; @@ -496,11 +517,11 @@ namespace std class _BinBase { public: - typedef typename _FirstArg::value_type _Vt; - typedef typename __fun<_Oper, _Vt>::result_type value_type; + typedef typename _FirstArg::value_type _Vt; + typedef typename __fun<_Oper, _Vt>::result_type value_type; _BinBase(const _FirstArg& __e1, const _SecondArg& __e2) - : _M_expr1(__e1), _M_expr2(__e2) {} + : _M_expr1(__e1), _M_expr2(__e2) {} value_type operator[](size_t __i) const { return _Oper()(_M_expr1[__i], _M_expr2[__i]); } @@ -521,7 +542,7 @@ namespace std typedef typename __fun<_Oper, _Vt>::result_type value_type; _BinBase2(const _Clos& __e, const _Vt& __t) - : _M_expr1(__e), _M_expr2(__t) {} + : _M_expr1(__e), _M_expr2(__t) {} value_type operator[](size_t __i) const { return _Oper()(_M_expr1[__i], _M_expr2); } @@ -541,7 +562,7 @@ namespace std typedef typename __fun<_Oper, _Vt>::result_type value_type; _BinBase1(const _Vt& __t, const _Clos& __e) - : _M_expr1(__t), _M_expr2(__e) {} + : _M_expr1(__t), _M_expr2(__e) {} value_type operator[](size_t __i) const { return _Oper()(_M_expr1, _M_expr2[__i]); } @@ -555,52 +576,52 @@ namespace std template<class _Oper, class _Dom1, class _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; _BinClos(const _Dom1& __e1, const _Dom2& __e2) : _Base(__e1, __e2) {} }; template<class _Oper, typename _Tp> - struct _BinClos<_Oper,_ValArray,_ValArray,_Tp,_Tp> - : _BinBase<_Oper,valarray<_Tp>,valarray<_Tp> > + struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _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; _BinClos(const valarray<_Tp>& __v, const valarray<_Tp>& __w) - : _Base(__v, __w) {} + : _Base(__v, __w) {} }; template<class _Oper, class _Dom> - struct _BinClos<_Oper,_Expr,_ValArray,_Dom,typename _Dom::value_type> - : _BinBase<_Oper,_Dom,valarray<typename _Dom::value_type> > + struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type> + : _BinBase<_Oper, _Dom, valarray<typename _Dom::value_type> > { typedef typename _Dom::value_type _Tp; typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base; typedef typename _Base::value_type value_type; _BinClos(const _Dom& __e1, const valarray<_Tp>& __e2) - : _Base(__e1, __e2) {} + : _Base(__e1, __e2) {} }; template<class _Oper, class _Dom> - struct _BinClos<_Oper,_ValArray,_Expr,typename _Dom::value_type,_Dom> - : _BinBase<_Oper,valarray<typename _Dom::value_type>,_Dom> + struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom> + : _BinBase<_Oper, valarray<typename _Dom::value_type>,_Dom> { 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; _BinClos(const valarray<_Tp>& __e1, const _Dom& __e2) - : _Base(__e1, __e2) {} + : _Base(__e1, __e2) {} }; template<class _Oper, class _Dom> - struct _BinClos<_Oper,_Expr,_Constant,_Dom,typename _Dom::value_type> - : _BinBase2<_Oper,_Dom> + struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type> + : _BinBase2<_Oper, _Dom> { typedef typename _Dom::value_type _Tp; typedef _BinBase2<_Oper,_Dom> _Base; @@ -610,19 +631,19 @@ namespace std }; template<class _Oper, class _Dom> - struct _BinClos<_Oper,_Constant,_Expr,typename _Dom::value_type,_Dom> - : _BinBase1<_Oper,_Dom> + struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom> + : _BinBase1<_Oper, _Dom> { typedef typename _Dom::value_type _Tp; - typedef _BinBase1<_Oper,_Dom> _Base; + typedef _BinBase1<_Oper, _Dom> _Base; typedef typename _Base::value_type value_type; _BinClos(const _Tp& __e1, const _Dom& __e2) : _Base(__e1, __e2) {} }; template<class _Oper, typename _Tp> - struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp> - : _BinBase2<_Oper,valarray<_Tp> > + struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp> + : _BinBase2<_Oper, valarray<_Tp> > { typedef _BinBase2<_Oper,valarray<_Tp> > _Base; typedef typename _Base::value_type value_type; @@ -631,69 +652,86 @@ namespace std }; template<class _Oper, typename _Tp> - struct _BinClos<_Oper,_Constant,_ValArray,_Tp,_Tp> - : _BinBase1<_Oper,valarray<_Tp> > + struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp> + : _BinBase1<_Oper, valarray<_Tp> > { - typedef _BinBase1<_Oper,valarray<_Tp> > _Base; + typedef _BinBase1<_Oper, valarray<_Tp> > _Base; typedef typename _Base::value_type value_type; _BinClos(const _Tp& __t, const valarray<_Tp>& __v) : _Base(__t, __v) {} }; - // // slice_array closure. // - template<typename _Dom> class _SBase { + template<typename _Dom> + class _SBase + { public: - typedef typename _Dom::value_type value_type; - - _SBase (const _Dom& __e, const slice& __s) - : _M_expr (__e), _M_slice (__s) {} - value_type operator[] (size_t __i) const - { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } - size_t size() const { return _M_slice.size (); } + typedef typename _Dom::value_type value_type; + + _SBase (const _Dom& __e, const slice& __s) + : _M_expr (__e), _M_slice (__s) {} + + value_type + operator[] (size_t __i) const + { return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; } + + size_t + size() const + { return _M_slice.size (); } private: - const _Dom& _M_expr; - const slice& _M_slice; + const _Dom& _M_expr; + const slice& _M_slice; }; - template<typename _Tp> class _SBase<_Array<_Tp> > { + template<typename _Tp> + class _SBase<_Array<_Tp> > + { public: - typedef _Tp value_type; - - _SBase (_Array<_Tp> __a, const slice& __s) - : _M_array (__a._M_data+__s.start()), _M_size (__s.size()), - _M_stride (__s.stride()) {} - value_type operator[] (size_t __i) const - { return _M_array._M_data[__i * _M_stride]; } - size_t size() const { return _M_size; } + typedef _Tp value_type; + + _SBase (_Array<_Tp> __a, const slice& __s) + : _M_array (__a._M_data+__s.start()), _M_size (__s.size()), + _M_stride (__s.stride()) {} + + value_type + operator[] (size_t __i) const + { return _M_array._M_data[__i * _M_stride]; } + + size_t + size() const + { return _M_size; } private: - const _Array<_Tp> _M_array; - const size_t _M_size; - const size_t _M_stride; + const _Array<_Tp> _M_array; + const size_t _M_size; + const size_t _M_stride; }; - template<class _Dom> struct _SClos<_Expr,_Dom> : _SBase<_Dom> { - typedef _SBase<_Dom> _Base; - typedef typename _Base::value_type value_type; - - _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {} + template<class _Dom> + struct _SClos<_Expr, _Dom> + : _SBase<_Dom> + { + typedef _SBase<_Dom> _Base; + typedef typename _Base::value_type value_type; + + _SClos (const _Dom& __e, const slice& __s) : _Base (__e, __s) {} }; - template<typename _Tp> - struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > { - typedef _SBase<_Array<_Tp> > _Base; - typedef _Tp value_type; - - _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {} + template<typename _Tp> + struct _SClos<_ValArray, _Tp> + : _SBase<_Array<_Tp> > + { + typedef _SBase<_Array<_Tp> > _Base; + typedef _Tp value_type; + + _SClos (_Array<_Tp> __a, const slice& __s) : _Base (__a, __s) {} }; } // std:: - #endif /* _CPP_VALARRAY_BEFORE_H */ // Local Variables: diff --git a/libstdc++-v3/include/std/std_valarray.h b/libstdc++-v3/include/std/std_valarray.h index b893b33..08ea909 100644 --- a/libstdc++-v3/include/std/std_valarray.h +++ b/libstdc++-v3/include/std/std_valarray.h @@ -147,7 +147,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: @@ -211,7 +212,7 @@ namespace std 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: /** @@ -237,7 +238,7 @@ namespace std * @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. @@ -260,7 +261,7 @@ 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. @@ -286,7 +287,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 +406,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,9 +444,6 @@ namespace std /// Return the maximum element using operator<(). _Tp max() const; - // // FIXME: Extension - // _Tp product () const; - /** * @brief Return a shifted array. * @@ -491,7 +488,7 @@ namespace std * @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. @@ -503,7 +500,7 @@ namespace std * @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. @@ -528,7 +525,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,7 +533,7 @@ namespace std valarray<_Tp>::operator[](size_t __i) { __glibcxx_requires_subscript(__i); - return _M_data[__i]; + return _M_data[__i]; } } // std:: @@ -558,19 +555,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,13 +576,14 @@ 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 (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data)); @@ -594,8 +592,8 @@ namespace std 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 (__ga._M_array, _Array<size_t>(__ga._M_index), @@ -605,7 +603,7 @@ 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 (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size); @@ -614,7 +612,7 @@ namespace std 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 (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); @@ -623,7 +621,7 @@ namespace std 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)) + : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size)) { std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); } template<typename _Tp> @@ -711,9 +709,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,13 +780,6 @@ 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> inline valarray<_Tp> valarray<_Tp>::shift(int __n) const @@ -805,16 +794,19 @@ namespace std 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); + 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_copy_construct (_M_data, _M_data + _M_size + __n, + __a - __n); std::__valarray_default_construct(__a, __a - __n); } - return valarray<_Tp> (__a, _M_size); + return valarray<_Tp>(__a, _M_size); } template <class _Tp> @@ -827,13 +819,15 @@ namespace std 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); + 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); + (_M_data + _M_size + __n, _M_data + _M_size, __a); std::__valarray_copy_construct (_M_data, _M_data + _M_size+__n, __a - __n); } @@ -862,7 +856,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 +864,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 +935,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 +957,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) |