This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project. See the libstdc++ home page for more information.
>>>>> «Thomas», Thomas Kunert <kunert@physik.tu-dresden.de> wrote: Thomas> Gabriel Dos Reis wrote: >> Actually that was an oversight. I'll send you a patch as soon as I'm >> back (I'm currently out for one week). >> Thomas> Fine. I was afraid a major redesign is necessary to fix this without Thomas> performance loss. Here is a patch for the problem you reported. Nathan, please could you install it? Any comment welcome. Best, -- Gaby Index: valarray_meta.h =================================================================== RCS file: /seoul/dosreis/cvsroot/libstdc++_v3/bits/valarray_meta.h,v retrieving revision 1.1.1.1 diff -c -r1.1.1.1 valarray_meta.h *** valarray_meta.h 1998/08/29 12:16:27 1.1.1.1 --- valarray_meta.h 1998/10/17 23:56:18 *************** *** 53,64 **** --- 53,107 ---- const _Expr2& _M_expr2; }; + template<class _Expr1, class _Expr2, class _Oper> inline typename _BinaryExpression<_Expr1,_Expr2,_Oper>::value_type _BinaryExpression<_Expr1,_Expr2,_Oper>::operator[] (size_t __i) const { return _Oper() (_M_expr1[__i], _M_expr2[__i]); } + template<typename _Tp, class _Expr, class _Oper> + class _BinaryExpression<_Constant<_Tp>, _Expr, _Oper> { + public: + typedef typename _Oper::result_type value_type; + _BinaryExpression (const _Constant<_Tp>& __c, const _Expr& __e) + : _M_expr1(__c()), _M_expr2(__e) {} + value_type operator[] (size_t __i) const; + size_t size() const { return _M_expr2.size(); } + + private: + const _Tp& _M_expr1; + const _Expr& _M_expr2; + }; + + + template<typename _Tp, class _Expr, class _Oper> + inline typename _BinaryExpression<_Constant<_Tp>,_Expr,_Oper>::value_type + _BinaryExpression<_Constant<_Tp>,_Expr,_Oper>::operator[] (size_t __i) const + { return _Oper() (_M_expr1, _M_expr2[__i]); } + + + template<class _Expr, typename _Tp, class _Oper> + class _BinaryExpression<_Expr, _Constant<_Tp>, _Oper> { + public: + typedef typename _Oper::result_type value_type; + _BinaryExpression (const _Expr& __e, const _Constant<_Tp>& __c) + : _M_expr1(__e), _M_expr2(__c()) {} + value_type operator[] (size_t __i) const; + size_t size() const { return _M_expr1.size(); } + + private: + const _Expr& _M_expr1; + const _Tp& _M_expr2; + }; + + + template<class _Expr, typename _Tp, class _Oper> + inline typename _BinaryExpression<_Expr,_Constant<_Tp>,_Oper>::value_type + _BinaryExpression<_Expr,_Constant<_Tp>,_Oper>::operator[] (size_t __i) const + { return _Oper() (_M_expr1[__i], _M_expr2); } + + template<class _Expr> class _SliceExpression { public: typedef typename _Expr::value_type value_type; *************** *** 540,545 **** --- 583,629 ---- const _Expr2& _M_expr2; _Tp (*_M_func)(_Tp,_Tp); }; + + template<typename _Tp, class _Expr> + class _ApplyBinaryFunction<_Constant<_Tp>, _Expr> + { + public: + typedef _Tp value_type ; + + _ApplyBinaryFunction (const _Constant<_Tp>& __c, const _Expr& __e, + _Tp __f (_Tp, _Tp)) + : _M_expr1 (__c()), _M_expr2 (__e), _M_func (__f) {} + + value_type operator[] (size_t __i) const + { return _M_func (_M_expr1, _M_expr2[__i]); } + size_t size () const { return _M_expr2.size (); } + + private: + const _Tp& _M_expr1; + const _Expr& _M_expr2; + _Tp (*_M_func)(_Tp,_Tp); + }; + + template<class _Expr, typename _Tp> + class _ApplyBinaryFunction<_Expr, _Constant<_Tp> > + { + public: + typedef _Tp value_type; + + _ApplyBinaryFunction (const _Expr& __e, const _Constant<_Tp>& __c, + _Tp __f (_Tp, _Tp)) + : _M_expr1 (__e), _M_expr2 (__c()), _M_func (__f) {} + + value_type operator[] (size_t __i) const + { return _M_func (_M_expr1[__i], _M_expr2; } + size_t size () const { return _M_expr1.size (); } + + private: + const _Expr& _M_expr1; + const _Tp& _M_expr2; + _Tp (*_M_func)(_Tp,_Tp); + }; + #define _DEFINE_VALARRAY_FUNCTION(name) \ template<class _Expr1, class _Expr2> \