* V3 PATCH: valarray<> fixes (2)
@ 2002-08-02 11:15 Gabriel Dos Reis
0 siblings, 0 replies; only message in thread
From: Gabriel Dos Reis @ 2002-08-02 11:15 UTC (permalink / raw)
To: libstdc++; +Cc: gcc-patches
This fixes unary operations on valarray<>s -- as far as name lookup is
concerned. Binary operations will be addressed in a separate patch.
Bootstrapped and tested on an i686-pc-linux.
Mainline.
-- Gaby
2002-08-02 Gabriel Dos Reis <gdr@nerim.net>
* include/bits/valarray_meta.h (_UnFunBase<>): Remove.
(_UnFunClos<>): Same.
(_UnBase<>): Reformat. Make first template-parameter non
template.
(_UnClos<>): Likewise.
(_Expr<>): Reformate. Adjust unary member operator return types.
(_DEFINE_EXPR_UNARY_OPERATOR): Adjust definition.
(_DEFINE_EXPR_UNARY_FUNCTION): Likewise.
* include/std/std_valarray.h (_UnClos<>): Adjust declaration.
(valarray<>::_UnaryOp<>): New nested traits. Adjust unary member
operator return types. Reformat.
(_Bitwise_not): Remove.
(_DEFINE_VALARRAY_UNARY_OPERATOR): Adjust definition.
* testsuite/26_numerics/valarray_name_lookup.C: New test.
Index: include/bits/valarray_meta.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/valarray_meta.h,v
retrieving revision 1.9
diff -p -r1.9 valarray_meta.h
*** include/bits/valarray_meta.h 2 Aug 2002 13:51:46 -0000 1.9
--- include/bits/valarray_meta.h 2 Aug 2002 16:41:06 -0000
***************
*** 41,77 ****
namespace std
{
!
! //
! // Implementing a loosened valarray return value is tricky.
! // First we need to meet 26.3.1/3: we should not add more than
! // two levels of template nesting. Therefore we resort to template
! // template to "flatten" loosened return value types.
! // At some point we use partial specialization to remove one level
! // template nesting due to _Expr<>
! //
!
!
! // This class is NOT defined. It doesn't need to.
! template<typename _Tp1, typename _Tp2> class _Constant;
!
! //
! // Unary function application closure.
! //
! template<class _Dom, typename _Op> class _UnFunBase
! {
! public:
! typedef typename _Dom::value_type value_type;
! typedef value_type _Vt;
!
! explicit _UnFunBase (const _Dom& __e) : _M_expr(__e) {}
!
! _Vt operator[] (size_t __i) const { return _Op()(_M_expr[__i]); }
! size_t size () const { return _M_expr.size(); }
!
! private:
! const _Dom& _M_expr;
! };
// Implementations of unary functions applied to valarray<>s.
// I use hard-coded object functions here instead of a generic
--- 41,58 ----
namespace std
{
! //
! // Implementing a loosened valarray return value is tricky.
! // First we need to meet 26.3.1/3: we should not add more than
! // two levels of template nesting. Therefore we resort to template
! // template to "flatten" loosened return value types.
! // At some point we use partial specialization to remove one level
! // template nesting due to _Expr<>
! //
!
!
! // This class is NOT defined. It doesn't need to.
! template<typename _Tp1, typename _Tp2> class _Constant;
// Implementations of unary functions applied to valarray<>s.
// I use hard-coded object functions here instead of a generic
*************** namespace std
*** 399,425 ****
typedef bool result_type;
};
- template<template<class, class> class _Meta, class _Dom, typename _Op>
- class _UnFunClos;
-
- template<class _Dom, typename _Op>
- struct _UnFunClos<_Expr,_Dom, _Op> : _UnFunBase<_Dom, _Op>
- {
- typedef _UnFunBase<_Dom, _Op> _Base;
- typedef typename _Base::value_type value_type;
-
- explicit _UnFunClos (const _Dom& __e) : _Base (__e) {}
- };
-
- template<typename _Tp, typename _Op>
- struct _UnFunClos<_ValArray,_Tp, _Op> : _UnFunBase<valarray<_Tp>, _Op>
- {
- typedef _UnFunBase<valarray<_Tp>, _Op> _Base;
- typedef typename _Base::value_type value_type;
-
- explicit _UnFunClos (const valarray<_Tp>& __v) : _Base (__v) {}
- };
-
//
// Binary function application closure.
//
--- 380,385 ----
*************** namespace std
*** 637,677 ****
// Unary expression closure.
//
! template<template<class> class _Oper, typename _Arg>
! class _UnBase {
public:
! typedef _Oper<typename _Arg::value_type> _Op;
! typedef typename _Op::result_type value_type;
! _UnBase (const _Arg& __e) : _M_expr(__e) {}
! value_type operator[] (size_t) const;
! size_t size () const { return _M_expr.size (); }
private:
! const _Arg& _M_expr;
};
! template<template<class> class _Oper, typename _Arg>
! inline typename _UnBase<_Oper, _Arg>::value_type
! _UnBase<_Oper, _Arg>::operator[] (size_t __i) const
! { return _Op() (_M_expr[__i]); }
!
! template<template<class> class _Oper, class _Dom>
! struct _UnClos<_Oper, _Expr, _Dom> : _UnBase<_Oper, _Dom> {
! typedef _Dom _Arg;
! typedef _UnBase<_Oper, _Dom> _Base;
! typedef typename _Base::value_type value_type;
!
! _UnClos (const _Arg& __e) : _Base(__e) {}
};
! template<template<class> class _Oper, typename _Tp>
! struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > {
! typedef valarray<_Tp> _Arg;
! typedef _UnBase<_Oper, valarray<_Tp> > _Base;
! typedef typename _Base::value_type value_type;
!
! _UnClos (const _Arg& __e) : _Base(__e) {}
};
--- 597,638 ----
// Unary expression closure.
//
! template<class _Oper, class _Arg>
! class _UnBase
! {
public:
! typedef typename _Arg::value_type _Vt;
! typedef typename __fun<_Oper, _Vt>::result_type value_type;
! _UnBase(const _Arg& __e) : _M_expr(__e) {}
!
! value_type operator[](size_t __i) const
! { return _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>
! {
! typedef _Dom _Arg;
! typedef _UnBase<_Oper, _Dom> _Base;
! typedef typename _Base::value_type value_type;
!
! _UnClos(const _Arg& __e) : _Base(__e) {}
};
! template<class _Oper, typename _Tp>
! struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> >
! {
! typedef valarray<_Tp> _Arg;
! typedef _UnBase<_Oper, valarray<_Tp> > _Base;
! typedef typename _Base::value_type value_type;
!
! _UnClos(const _Arg& __e) : _Base(__e) {}
};
*************** namespace std
*** 968,1120 ****
: _Base (__a, __i) {}
};
! //
! // class _Expr
! //
! template<class _Clos, typename _Tp> class _Expr {
public:
! typedef _Tp value_type;
!
! _Expr (const _Clos&);
!
! const _Clos& operator() () const;
! value_type operator[] (size_t) const;
! valarray<value_type> operator[] (slice) const;
! valarray<value_type> operator[] (const gslice&) const;
! 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<negate,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;
! size_t size () const;
! value_type sum () const;
! valarray<value_type> shift (int) const;
! valarray<value_type> cshift (int) const;
value_type min() const;
value_type max() const;
! valarray<value_type> apply(value_type (*) (const value_type&)) const;
! valarray<value_type> apply(value_type (*) (value_type)) const;
private:
! const _Clos _M_closure;
};
! template<class _Clos, typename _Tp>
inline
! _Expr<_Clos,_Tp>::_Expr (const _Clos& __c) : _M_closure(__c) {}
! template<class _Clos, typename _Tp>
inline const _Clos&
! _Expr<_Clos,_Tp>::operator() () const
{ return _M_closure; }
! template<class _Clos, typename _Tp>
inline _Tp
! _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
{ return _M_closure[__s]; }
! template<class _Clos, typename _Tp>
inline valarray<_Tp>
! _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
{ return _M_closure[__m]; }
! template<class _Clos, typename _Tp>
inline valarray<_Tp>
! _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 (); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::shift(int __n) const
! { return valarray<_Tp>(_M_closure).shift(__n); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::cshift(int __n) const
! { return valarray<_Tp>(_M_closure).cshift(__n); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
! { return valarray<_Tp>(_M_closure).apply(__f); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
! { return valarray<_Tp>(_M_closure).apply(__f); }
! // XXX: replace this with a more robust summation algorithm.
! template<class _Clos, typename _Tp>
inline _Tp
! _Expr<_Clos,_Tp>::sum () const
{
! size_t __n = _M_closure.size();
! if (__n == 0) return _Tp();
! else {
! _Tp __s = _M_closure[--__n];
! while (__n != 0) __s += _M_closure[--__n];
! return __s;
}
}
template<class _Clos, typename _Tp>
! inline _Tp
! _Expr<_Clos, _Tp>::min() const
! { return __valarray_min(_M_closure); }
template<class _Clos, typename _Tp>
! inline _Tp
! _Expr<_Clos, _Tp>::max() const
! { return __valarray_max(_M_closure); }
! template<class _Dom, typename _Tp>
! 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));
}
#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 \
{ \
typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \
! return _Expr<_Closure,_Tp> (_Closure (this->_M_closure)); \
}
! _DEFINE_EXPR_UNARY_OPERATOR(+, _Unary_plus)
! _DEFINE_EXPR_UNARY_OPERATOR(-, negate)
! _DEFINE_EXPR_UNARY_OPERATOR(~, _Bitwise_not)
#undef _DEFINE_EXPR_UNARY_OPERATOR
--- 929,1086 ----
: _Base (__a, __i) {}
};
! //
! // class _Expr
! //
! template<class _Clos, typename _Tp>
! class _Expr
! {
public:
! typedef _Tp value_type;
!
! _Expr(const _Clos&);
!
! const _Clos& operator()() const;
! value_type operator[](size_t) const;
! valarray<value_type> operator[](slice) const;
! valarray<value_type> operator[](const gslice&) const;
! 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<__negate,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;
! size_t size() const;
! value_type sum() const;
! valarray<value_type> shift(int) const;
! valarray<value_type> cshift(int) const;
value_type min() const;
value_type max() const;
! valarray<value_type> apply(value_type (*)(const value_type&)) const;
! valarray<value_type> apply(value_type (*)(value_type)) const;
private:
! const _Clos _M_closure;
};
! template<class _Clos, typename _Tp>
inline
! _Expr<_Clos,_Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {}
! template<class _Clos, typename _Tp>
inline const _Clos&
! _Expr<_Clos,_Tp>::operator()() const
{ return _M_closure; }
! template<class _Clos, typename _Tp>
inline _Tp
! _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
{ return _M_closure[__s]; }
! template<class _Clos, typename _Tp>
inline valarray<_Tp>
! _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
{ return _M_closure[__m]; }
! template<class _Clos, typename _Tp>
inline valarray<_Tp>
! _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 (); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::shift(int __n) const
! { return valarray<_Tp>(_M_closure).shift(__n); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::cshift(int __n) const
! { return valarray<_Tp>(_M_closure).cshift(__n); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const
! { return valarray<_Tp>(_M_closure).apply(__f); }
template<class _Clos, typename _Tp>
! inline valarray<_Tp>
! _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const
! { return valarray<_Tp>(_M_closure).apply(__f); }
! // XXX: replace this with a more robust summation algorithm.
! template<class _Clos, typename _Tp>
inline _Tp
! _Expr<_Clos,_Tp>::sum() const
{
! size_t __n = _M_closure.size();
! if (__n == 0)
! return _Tp();
! else
! {
! _Tp __s = _M_closure[--__n];
! while (__n != 0)
! __s += _M_closure[--__n];
! return __s;
}
}
template<class _Clos, typename _Tp>
! inline _Tp
! _Expr<_Clos, _Tp>::min() const
! { return __valarray_min(_M_closure); }
template<class _Clos, typename _Tp>
! inline _Tp
! _Expr<_Clos, _Tp>::max() const
! { return __valarray_max(_M_closure); }
! template<class _Dom, typename _Tp>
! 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));
}
#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 \
{ \
typedef _UnClos<_Name,std::_Expr,_Dom> _Closure; \
! return _Expr<_Closure,_Tp>(_Closure(this->_M_closure)); \
}
! _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus)
! _DEFINE_EXPR_UNARY_OPERATOR(-, __negate)
! _DEFINE_EXPR_UNARY_OPERATOR(~, __bitwise_not)
#undef _DEFINE_EXPR_UNARY_OPERATOR
*************** operator _Op (const valarray<typename _D
*** 1263,1281 ****
#define _DEFINE_EXPR_UNARY_FUNCTION(_Name) \
template<class _Dom> \
! inline _Expr<_UnFunClos<_Expr,_Dom,__##_Name>,typename _Dom::value_type>\
_Name(const _Expr<_Dom,typename _Dom::value_type>& __e) \
{ \
typedef typename _Dom::value_type _Tp; \
! typedef _UnFunClos<_Expr,_Dom,__##_Name> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__e())); \
} \
\
template<typename _Tp> \
! inline _Expr<_UnFunClos<_ValArray,_Tp,__##_Name>,_Tp> \
_Name(const valarray<_Tp>& __v) \
{ \
! typedef _UnFunClos<_ValArray,_Tp,__##_Name> _Closure; \
return _Expr<_Closure,_Tp>(_Closure (__v)); \
}
--- 1229,1247 ----
#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) \
{ \
typedef typename _Dom::value_type _Tp; \
! typedef _UnClos<__##_Name,_Expr,_Dom> _Closure; \
return _Expr<_Closure,_Tp>(_Closure(__e())); \
} \
\
template<typename _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)); \
}
Index: include/std/std_valarray.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/std/std_valarray.h,v
retrieving revision 1.3
diff -p -r1.3 std_valarray.h
*** include/std/std_valarray.h 16 Jul 2002 00:19:18 -0000 1.3
--- include/std/std_valarray.h 2 Aug 2002 16:41:06 -0000
***************
*** 50,92 ****
namespace std
{
! template<class _Clos, typename _Tp> class _Expr;
! template<typename _Tp1, typename _Tp2> class _ValArray;
! template<template<class> class _Oper,
! template<class, class> class _Meta, class _Dom> struct _UnClos;
! template<template<class> class _Oper,
template<class, class> class _Meta1,
template<class, class> class _Meta2,
! class _Dom1, class _Dom2> class _BinClos;
! template<template<class, class> class _Meta, class _Dom> class _SClos;
! template<template<class, class> class _Meta, class _Dom> class _GClos;
! template<template<class, class> class _Meta, class _Dom> class _IClos;
! template<template<class, class> class _Meta, class _Dom> class _ValFunClos;
!
! template<template<class, class> class _Meta, class _Dom> class _RefFunClos;
! template<class _Tp> struct _Unary_plus;
! template<class _Tp> struct _Bitwise_and;
! template<class _Tp> struct _Bitwise_or;
! template<class _Tp> struct _Bitwise_xor;
! template<class _Tp> struct _Bitwise_not;
! template<class _Tp> struct _Shift_left;
! template<class _Tp> struct _Shift_right;
! template<class _Tp> class valarray; // An array of type _Tp
! class slice; // BLAS-like slice out of an array
! template<class _Tp> class slice_array;
! class gslice; // generalized slice out of an array
! template<class _Tp> class gslice_array;
! template<class _Tp> class mask_array; // masked array
! template<class _Tp> class indirect_array; // indirected array
} // namespace std
--- 50,98 ----
namespace std
{
! template<class _Clos, typename _Tp>
! class _Expr;
! template<typename _Tp1, typename _Tp2>
! class _ValArray;
! template<class _Oper, template<class, class> class _Meta, class _Dom>
! struct _UnClos;
! template<template<class> class _Oper,
template<class, class> class _Meta1,
template<class, class> class _Meta2,
! class _Dom1, class _Dom2>
! class _BinClos;
! template<template<class, class> class _Meta, class _Dom>
! class _SClos;
! template<template<class, class> class _Meta, class _Dom>
! class _GClos;
! template<template<class, class> class _Meta, class _Dom>
! class _IClos;
! template<template<class, class> class _Meta, class _Dom>
! class _ValFunClos;
!
! template<template<class, class> class _Meta, class _Dom>
! class _RefFunClos;
! template<class _Tp> struct _Bitwise_and;
! template<class _Tp> struct _Bitwise_or;
! template<class _Tp> struct _Bitwise_xor;
! template<class _Tp> struct _Shift_left;
! template<class _Tp> struct _Shift_right;
! template<class _Tp> class valarray; // An array of type _Tp
! class slice; // BLAS-like slice out of an array
! template<class _Tp> class slice_array;
! class gslice; // generalized slice out of an array
! template<class _Tp> class gslice_array;
! template<class _Tp> class mask_array; // masked array
! template<class _Tp> class indirect_array; // indirected array
} // namespace std
*************** namespace std
*** 95,106 ****
namespace std
{
! template<class _Tp> class valarray
! {
! public:
typedef _Tp value_type;
!
! // _lib.valarray.cons_ construct/destroy:
valarray();
explicit valarray(size_t);
valarray(const _Tp&, size_t);
--- 101,119 ----
namespace std
{
! template<class _Tp>
! class valarray
! {
! template<class _Op>
! struct _UnaryOp
! {
! typedef typename __fun<_Op, _Tp>::result_type __rt;
! typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt;
! };
! public:
typedef _Tp value_type;
!
! // _lib.valarray.cons_ construct/destroy:
valarray();
explicit valarray(size_t);
valarray(const _Tp&, size_t);
*************** namespace std
*** 111,118 ****
valarray(const mask_array<_Tp>&);
valarray(const indirect_array<_Tp>&);
template<class _Dom>
! valarray(const _Expr<_Dom,_Tp>& __e);
! ~valarray();
// _lib.valarray.assign_ assignment:
valarray<_Tp>& operator=(const valarray<_Tp>&);
--- 124,131 ----
valarray(const mask_array<_Tp>&);
valarray(const indirect_array<_Tp>&);
template<class _Dom>
! valarray(const _Expr<_Dom,_Tp>& __e);
! ~valarray();
// _lib.valarray.assign_ assignment:
valarray<_Tp>& operator=(const valarray<_Tp>&);
*************** namespace std
*** 123,129 ****
valarray<_Tp>& operator=(const indirect_array<_Tp>&);
template<class _Dom> valarray<_Tp>&
! operator= (const _Expr<_Dom,_Tp>&);
// _lib.valarray.access_ element access:
// XXX: LWG to be resolved.
--- 136,142 ----
valarray<_Tp>& operator=(const indirect_array<_Tp>&);
template<class _Dom> valarray<_Tp>&
! operator= (const _Expr<_Dom,_Tp>&);
// _lib.valarray.access_ element access:
// XXX: LWG to be resolved.
*************** namespace std
*** 137,203 ****
valarray<_Tp> operator[](const valarray<bool>&) const;
mask_array<_Tp> operator[](const valarray<bool>&);
_Expr<_IClos<_ValArray, _Tp>, _Tp>
! operator[](const valarray<size_t>&) const;
indirect_array<_Tp> operator[](const valarray<size_t>&);
// _lib.valarray.unary_ unary operators:
! _Expr<_UnClos<_Unary_plus,_ValArray,_Tp>,_Tp> operator+ () const;
! _Expr<_UnClos<negate,_ValArray,_Tp>,_Tp> operator- () const;
! _Expr<_UnClos<_Bitwise_not,_ValArray,_Tp>,_Tp> operator~ () const;
! _Expr<_UnClos<logical_not,_ValArray,_Tp>,bool> operator! () const;
!
// _lib.valarray.cassign_ computed assignment:
! valarray<_Tp>& operator*= (const _Tp&);
! valarray<_Tp>& operator/= (const _Tp&);
! valarray<_Tp>& operator%= (const _Tp&);
! valarray<_Tp>& operator+= (const _Tp&);
! valarray<_Tp>& operator-= (const _Tp&);
! valarray<_Tp>& operator^= (const _Tp&);
! valarray<_Tp>& operator&= (const _Tp&);
! valarray<_Tp>& operator|= (const _Tp&);
valarray<_Tp>& operator<<=(const _Tp&);
valarray<_Tp>& operator>>=(const _Tp&);
! valarray<_Tp>& operator*= (const valarray<_Tp>&);
! valarray<_Tp>& operator/= (const valarray<_Tp>&);
! valarray<_Tp>& operator%= (const valarray<_Tp>&);
! valarray<_Tp>& operator+= (const valarray<_Tp>&);
! valarray<_Tp>& operator-= (const valarray<_Tp>&);
! valarray<_Tp>& operator^= (const valarray<_Tp>&);
! valarray<_Tp>& operator|= (const valarray<_Tp>&);
! valarray<_Tp>& operator&= (const valarray<_Tp>&);
valarray<_Tp>& operator<<=(const valarray<_Tp>&);
valarray<_Tp>& operator>>=(const valarray<_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator*= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator/= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator%= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator+= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator-= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator^= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator|= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator&= (const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
-
// _lib.valarray.members_ member functions:
size_t size() const;
_Tp sum() const;
_Tp min() const;
_Tp max() const;
! // // FIXME: Extension
! // _Tp product () const;
valarray<_Tp> shift (int) const;
valarray<_Tp> cshift(int) const;
--- 150,216 ----
valarray<_Tp> operator[](const valarray<bool>&) const;
mask_array<_Tp> operator[](const valarray<bool>&);
_Expr<_IClos<_ValArray, _Tp>, _Tp>
! operator[](const valarray<size_t>&) const;
indirect_array<_Tp> operator[](const valarray<size_t>&);
// _lib.valarray.unary_ unary operators:
! typename _UnaryOp<__unary_plus>::_Rt operator+() const;
! typename _UnaryOp<__negate>::_Rt operator-() const;
! typename _UnaryOp<__bitwise_not>::_Rt operator~() const;
! typename _UnaryOp<__logical_not>::_Rt operator!() const;
!
// _lib.valarray.cassign_ computed assignment:
! valarray<_Tp>& operator*=(const _Tp&);
! valarray<_Tp>& operator/=(const _Tp&);
! valarray<_Tp>& operator%=(const _Tp&);
! valarray<_Tp>& operator+=(const _Tp&);
! valarray<_Tp>& operator-=(const _Tp&);
! valarray<_Tp>& operator^=(const _Tp&);
! valarray<_Tp>& operator&=(const _Tp&);
! valarray<_Tp>& operator|=(const _Tp&);
valarray<_Tp>& operator<<=(const _Tp&);
valarray<_Tp>& operator>>=(const _Tp&);
! valarray<_Tp>& operator*=(const valarray<_Tp>&);
! valarray<_Tp>& operator/=(const valarray<_Tp>&);
! valarray<_Tp>& operator%=(const valarray<_Tp>&);
! valarray<_Tp>& operator+=(const valarray<_Tp>&);
! valarray<_Tp>& operator-=(const valarray<_Tp>&);
! valarray<_Tp>& operator^=(const valarray<_Tp>&);
! valarray<_Tp>& operator|=(const valarray<_Tp>&);
! valarray<_Tp>& operator&=(const valarray<_Tp>&);
valarray<_Tp>& operator<<=(const valarray<_Tp>&);
valarray<_Tp>& operator>>=(const valarray<_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator*=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator/=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator%=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator+=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator-=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator^=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator|=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator&=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator<<=(const _Expr<_Dom,_Tp>&);
template<class _Dom>
! valarray<_Tp>& operator>>=(const _Expr<_Dom,_Tp>&);
!
// _lib.valarray.members_ member functions:
size_t size() const;
_Tp sum() const;
_Tp min() const;
_Tp max() const;
! // // FIXME: Extension
! // _Tp product () const;
valarray<_Tp> shift (int) const;
valarray<_Tp> cshift(int) const;
*************** namespace std
*** 205,221 ****
_Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
void resize(size_t __size, _Tp __c = _Tp());
! private:
size_t _M_size;
_Tp* __restrict__ _M_data;
!
friend class _Array<_Tp>;
! };
!
!
! template<typename _Tp> struct _Unary_plus : unary_function<_Tp,_Tp> {
! _Tp operator() (const _Tp& __t) const { return __t; }
! };
template<typename _Tp> struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> {
_Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; }
--- 218,229 ----
_Expr<_RefFunClos<_ValArray,_Tp>,_Tp> apply(_Tp func(const _Tp&)) const;
void resize(size_t __size, _Tp __c = _Tp());
! private:
size_t _M_size;
_Tp* __restrict__ _M_data;
!
friend class _Array<_Tp>;
! };
template<typename _Tp> struct _Bitwise_and : binary_function<_Tp,_Tp,_Tp> {
_Tp operator() (_Tp __x, _Tp __y) const { return __x & __y; }
*************** namespace std
*** 229,238 ****
_Tp operator() (_Tp __x, _Tp __y) const { return __x ^ __y; }
};
- template<typename _Tp> struct _Bitwise_not : unary_function<_Tp,_Tp> {
- _Tp operator() (_Tp __t) const { return ~__t; }
- };
-
template<typename _Tp> struct _Shift_left : unary_function<_Tp,_Tp> {
_Tp operator() (_Tp __x, _Tp __y) const { return __x << __y; }
};
--- 237,242 ----
*************** namespace std
*** 243,256 ****
template<typename _Tp>
! inline const _Tp&
! valarray<_Tp>::operator[] (size_t __i) const
! { return _M_data[__i]; }
template<typename _Tp>
! inline _Tp&
! valarray<_Tp>::operator[] (size_t __i)
! { return _M_data[__i]; }
} // std::
--- 247,260 ----
template<typename _Tp>
! inline const _Tp&
! valarray<_Tp>::operator[](size_t __i) const
! { return _M_data[__i]; }
template<typename _Tp>
! inline _Tp&
! valarray<_Tp>::operator[](size_t __i)
! { return _M_data[__i]; }
} // std::
*************** namespace std
*** 263,476 ****
namespace std
{
template<typename _Tp>
! inline valarray<_Tp>::valarray () : _M_size (0), _M_data (0) {}
!
! template<typename _Tp>
! inline valarray<_Tp>::valarray (size_t __n)
! : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
! { __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))
! { __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))
! { __valarray_copy_construct (__p, __p + __n, _M_data); }
!
! 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))
! { __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))
! {
! __valarray_copy
! (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
! }
template<typename _Tp>
! inline valarray<_Tp>::valarray (const gslice_array<_Tp>& __ga)
! : _M_size(__ga._M_index.size()),
! _M_data(__valarray_get_storage<_Tp>(_M_size))
! {
! __valarray_copy
! (__ga._M_array, _Array<size_t>(__ga._M_index),
! _Array<_Tp>(_M_data), _M_size);
! }
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))
! {
! __valarray_copy
! (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
! }
template<typename _Tp>
! inline valarray<_Tp>::valarray (const indirect_array<_Tp>& __ia)
! : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
! {
! __valarray_copy
! (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
! }
template<typename _Tp> template<class _Dom>
! inline valarray<_Tp>::valarray (const _Expr<_Dom, _Tp>& __e)
! : _M_size(__e.size ()), _M_data(__valarray_get_storage<_Tp>(_M_size))
! { __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data)); }
template<typename _Tp>
! inline valarray<_Tp>::~valarray ()
! {
__valarray_destroy_elements(_M_data, _M_data + _M_size);
__valarray_release_memory(_M_data);
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator= (const valarray<_Tp>& __v)
! {
__valarray_copy(__v._M_data, _M_size, _M_data);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator= (const _Tp& __t)
! {
! __valarray_fill (_M_data, _M_size, __t);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator= (const slice_array<_Tp>& __sa)
! {
! __valarray_copy (__sa._M_array, __sa._M_sz,
! __sa._M_stride, _Array<_Tp>(_M_data));
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator= (const gslice_array<_Tp>& __ga)
! {
! __valarray_copy (__ga._M_array, _Array<size_t>(__ga._M_index),
! _Array<_Tp>(_M_data), _M_size);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator= (const mask_array<_Tp>& __ma)
! {
! __valarray_copy (__ma._M_array, __ma._M_mask,
! _Array<_Tp>(_M_data), _M_size);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator= (const indirect_array<_Tp>& __ia)
! {
! __valarray_copy (__ia._M_array, __ia._M_index,
! _Array<_Tp>(_M_data), _M_size);
return *this;
! }
template<typename _Tp> template<class _Dom>
! inline valarray<_Tp>&
! valarray<_Tp>::operator= (const _Expr<_Dom, _Tp>& __e)
! {
! __valarray_copy (__e, _M_size, _Array<_Tp>(_M_data));
! return *this;
! }
template<typename _Tp>
! inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
! valarray<_Tp>::operator[] (slice __s) const
! {
typedef _SClos<_ValArray,_Tp> _Closure;
! return _Expr<_Closure, _Tp> (_Closure (_Array<_Tp>(_M_data), __s));
! }
template<typename _Tp>
! inline slice_array<_Tp>
! valarray<_Tp>::operator[] (slice __s)
! {
! return slice_array<_Tp> (_Array<_Tp>(_M_data), __s);
! }
template<typename _Tp>
! inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
! valarray<_Tp>::operator[] (const gslice& __gs) const
! {
typedef _GClos<_ValArray,_Tp> _Closure;
return _Expr<_Closure, _Tp>
! (_Closure (_Array<_Tp>(_M_data), __gs._M_index->_M_index));
! }
template<typename _Tp>
! inline gslice_array<_Tp>
! valarray<_Tp>::operator[] (const gslice& __gs)
! {
return gslice_array<_Tp>
! (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
! }
template<typename _Tp>
! inline valarray<_Tp>
! valarray<_Tp>::operator[] (const valarray<bool>& __m) const
! {
! size_t __s (0);
! size_t __e (__m.size ());
for (size_t __i=0; __i<__e; ++__i)
! if (__m[__i]) ++__s;
! return valarray<_Tp> (mask_array<_Tp> (_Array<_Tp>(_M_data), __s,
! _Array<bool> (__m)));
! }
template<typename _Tp>
! inline mask_array<_Tp>
! valarray<_Tp>::operator[] (const valarray<bool>& __m)
! {
! size_t __s (0);
! size_t __e (__m.size ());
for (size_t __i=0; __i<__e; ++__i)
! if (__m[__i]) ++__s;
! return mask_array<_Tp> (_Array<_Tp>(_M_data), __s, _Array<bool> (__m));
! }
template<typename _Tp>
! inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
! valarray<_Tp>::operator[] (const valarray<size_t>& __i) const
! {
typedef _IClos<_ValArray,_Tp> _Closure;
! return _Expr<_Closure, _Tp> (_Closure (*this, __i));
! }
template<typename _Tp>
! inline indirect_array<_Tp>
! valarray<_Tp>::operator[] (const valarray<size_t>& __i)
! {
! return indirect_array<_Tp> (_Array<_Tp>(_M_data), __i.size(),
! _Array<size_t> (__i));
! }
template<class _Tp>
! inline size_t valarray<_Tp>::size () const { return _M_size; }
template<class _Tp>
! inline _Tp
! valarray<_Tp>::sum () const
! {
! return __valarray_sum(_M_data, _M_data + _M_size);
! }
// template<typename _Tp>
// inline _Tp
--- 267,493 ----
namespace std
{
template<typename _Tp>
! inline
! valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {}
template<typename _Tp>
! inline
! valarray<_Tp>::valarray(size_t __n)
! : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
! { __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))
! { __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))
! { __valarray_copy_construct(__p, __p + __n, _M_data); }
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))
! { __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))
! {
! __valarray_copy
! (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
! }
!
! template<typename _Tp>
! inline
! valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga)
! : _M_size(__ga._M_index.size()),
! _M_data(__valarray_get_storage<_Tp>(_M_size))
! {
! __valarray_copy
! (__ga._M_array, _Array<size_t>(__ga._M_index),
! _Array<_Tp>(_M_data), _M_size);
! }
!
! 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))
! {
! __valarray_copy
! (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
! }
!
! template<typename _Tp>
! inline
! valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia)
! : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
! {
! __valarray_copy
! (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
! }
template<typename _Tp> template<class _Dom>
! inline
! valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e)
! : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
! { __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data)); }
template<typename _Tp>
! inline
! valarray<_Tp>::~valarray()
! {
__valarray_destroy_elements(_M_data, _M_data + _M_size);
__valarray_release_memory(_M_data);
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator=(const valarray<_Tp>& __v)
! {
__valarray_copy(__v._M_data, _M_size, _M_data);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator=(const _Tp& __t)
! {
! __valarray_fill(_M_data, _M_size, __t);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator=(const slice_array<_Tp>& __sa)
! {
! __valarray_copy(__sa._M_array, __sa._M_sz,
! __sa._M_stride, _Array<_Tp>(_M_data));
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga)
! {
! __valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index),
! _Array<_Tp>(_M_data), _M_size);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator=(const mask_array<_Tp>& __ma)
! {
! __valarray_copy(__ma._M_array, __ma._M_mask,
! _Array<_Tp>(_M_data), _M_size);
return *this;
! }
template<typename _Tp>
! inline valarray<_Tp>&
! valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia)
! {
! __valarray_copy(__ia._M_array, __ia._M_index,
! _Array<_Tp>(_M_data), _M_size);
return *this;
! }
template<typename _Tp> template<class _Dom>
! inline valarray<_Tp>&
! valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
! {
! __valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
! return *this;
! }
template<typename _Tp>
! inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
! valarray<_Tp>::operator[](slice __s) const
! {
typedef _SClos<_ValArray,_Tp> _Closure;
! return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s));
! }
template<typename _Tp>
! inline slice_array<_Tp>
! valarray<_Tp>::operator[](slice __s)
! {
! return slice_array<_Tp>(_Array<_Tp>(_M_data), __s);
! }
template<typename _Tp>
! inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
! valarray<_Tp>::operator[](const gslice& __gs) const
! {
typedef _GClos<_ValArray,_Tp> _Closure;
return _Expr<_Closure, _Tp>
! (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index));
! }
template<typename _Tp>
! inline gslice_array<_Tp>
! valarray<_Tp>::operator[](const gslice& __gs)
! {
return gslice_array<_Tp>
! (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
! }
template<typename _Tp>
! inline valarray<_Tp>
! valarray<_Tp>::operator[](const valarray<bool>& __m) const
! {
! size_t __s = 0;
! size_t __e = __m.size();
for (size_t __i=0; __i<__e; ++__i)
! if (__m[__i]) ++__s;
! return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s,
! _Array<bool> (__m)));
! }
template<typename _Tp>
! inline mask_array<_Tp>
! valarray<_Tp>::operator[](const valarray<bool>& __m)
! {
! size_t __s = 0;
! size_t __e = __m.size();
for (size_t __i=0; __i<__e; ++__i)
! if (__m[__i]) ++__s;
! return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array<bool>(__m));
! }
template<typename _Tp>
! inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
! valarray<_Tp>::operator[](const valarray<size_t>& __i) const
! {
typedef _IClos<_ValArray,_Tp> _Closure;
! return _Expr<_Closure, _Tp>(_Closure(*this, __i));
! }
template<typename _Tp>
! inline indirect_array<_Tp>
! valarray<_Tp>::operator[](const valarray<size_t>& __i)
! {
! return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(),
! _Array<size_t>(__i));
! }
template<class _Tp>
! inline size_t
! valarray<_Tp>::size() const
! { return _M_size; }
template<class _Tp>
! inline _Tp
! valarray<_Tp>::sum() const
! {
! return __valarray_sum(_M_data, _M_data + _M_size);
! }
// template<typename _Tp>
// inline _Tp
*************** namespace std
*** 529,602 ****
}
template <class _Tp>
! inline void
! valarray<_Tp>::resize (size_t __n, _Tp __c)
! {
! // This complication is so to make valarray<valarray<T> > work
! // even though it is not required by the standard. Nobody should
! // be saying valarray<valarray<T> > anyway. See the specs.
! __valarray_destroy_elements(_M_data, _M_data + _M_size);
! if (_M_size != __n)
! {
! __valarray_release_memory(_M_data);
! _M_size = __n;
! _M_data = __valarray_get_storage<_Tp>(__n);
! }
! __valarray_fill_construct(_M_data, _M_data + __n, __c);
! }
template<typename _Tp>
! inline _Tp
! valarray<_Tp>::min() const
! {
return *min_element (_M_data, _M_data+_M_size);
! }
template<typename _Tp>
! inline _Tp
! valarray<_Tp>::max() const
! {
return *max_element (_M_data, _M_data+_M_size);
! }
template<class _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));
! }
template<class _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));
! }
#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
template<typename _Tp> \
! inline _Expr<_UnClos<_Name,_ValArray,_Tp>, _Tp> \
valarray<_Tp>::operator _Op() const \
{ \
! typedef _UnClos<_Name,_ValArray,_Tp> _Closure; \
! return _Expr<_Closure, _Tp> (_Closure (*this)); \
}
! _DEFINE_VALARRAY_UNARY_OPERATOR(+, _Unary_plus)
! _DEFINE_VALARRAY_UNARY_OPERATOR(-, negate)
! _DEFINE_VALARRAY_UNARY_OPERATOR(~, _Bitwise_not)
#undef _DEFINE_VALARRAY_UNARY_OPERATOR
-
- template<typename _Tp>
- inline _Expr<_UnClos<logical_not,_ValArray,_Tp>, bool>
- valarray<_Tp>::operator!() const
- {
- typedef _UnClos<logical_not,_ValArray,_Tp> _Closure;
- return _Expr<_Closure, bool> (_Closure (*this));
- }
#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
template<class _Tp> \
--- 546,613 ----
}
template <class _Tp>
! inline void
! valarray<_Tp>::resize (size_t __n, _Tp __c)
! {
! // This complication is so to make valarray<valarray<T> > work
! // even though it is not required by the standard. Nobody should
! // be saying valarray<valarray<T> > anyway. See the specs.
! __valarray_destroy_elements(_M_data, _M_data + _M_size);
! if (_M_size != __n)
! {
! __valarray_release_memory(_M_data);
! _M_size = __n;
! _M_data = __valarray_get_storage<_Tp>(__n);
! }
! __valarray_fill_construct(_M_data, _M_data + __n, __c);
! }
template<typename _Tp>
! inline _Tp
! valarray<_Tp>::min() const
! {
return *min_element (_M_data, _M_data+_M_size);
! }
template<typename _Tp>
! inline _Tp
! valarray<_Tp>::max() const
! {
return *max_element (_M_data, _M_data+_M_size);
! }
template<class _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));
! }
template<class _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));
! }
#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)); \
}
! _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus)
! _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate)
! _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not)
! _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not)
#undef _DEFINE_VALARRAY_UNARY_OPERATOR
#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
template<class _Tp> \
Index: testsuite/26_numerics/valarray_name_lookup.C
===================================================================
RCS file: testsuite/26_numerics/valarray_name_lookup.C
diff -N testsuite/26_numerics/valarray_name_lookup.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/26_numerics/valarray_name_lookup.C 2 Aug 2002 16:41:06 -0000
***************
*** 0 ****
--- 1,119 ----
+ // 2002-08-02 gdr
+
+ // Copyright (C) 2002 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
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ // GNU General Public License for more details.
+
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING. If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+
+ // As a special exception, you may use this file as part of a free software
+ // library without restriction. Specifically, if other files instantiate
+ // templates or use macros or inline functions from this file, or you compile
+ // this file and link it with other files to produce an executable, this
+ // file does not by itself cause the resulting executable to be covered by
+ // the GNU General Public License. This exception does not however
+ // invalidate any other reasons why the executable file might be covered by
+ // the GNU General Public License.
+
+ // Test name lookup resolutions for standard functions applied to an
+ // array expression.
+ // { dg-do compile }
+
+ #include <valarray>
+
+ namespace My
+ {
+ struct Number
+ {
+ operator bool() const;
+ };
+
+ Number operator+(Number);
+ Number operator-(Number);
+ Number operator~(Number);
+
+ bool operator!(Number);
+
+ Number operator+(Number, Number);
+ Number operator-(Number, Number);
+ Number operator*(Number, Number);
+ Number operator/(Number, Number);
+ Number operator%(Number, Number);
+
+ Number operator^(Number, Number);
+ Number operator&(Number, Number);
+ Number operator|(Number, Number);
+
+ Number operator<<(Number, Number);
+ Number operator>>(Number, Number);
+
+ bool operator==(Number, Number);
+ bool operator!=(Number, Number);
+ bool operator<(Number, Number);
+ bool operator<=(Number, Number);
+ bool operator>(Number, Number);
+ bool operator>=(Number, Number);
+
+ Number abs(Number);
+
+ Number cos(Number);
+ Number cosh(Number);
+ Number acosh(Number);
+
+ Number sin(Number);
+ Number sinh(Number);
+ Number asin(Number);
+
+ Number tan(Number);
+ Number tanh(Number);
+ Number atan(Number);
+
+ Number exp(Number);
+ Number log(Number);
+ Number log10(Number);
+ Number sqrt(Number);
+
+ Number atan2(Number, Number);
+ Number pow(Number, Number);
+ }
+
+ int main()
+ {
+ typedef std::valarray<My::Number> Array;
+ Array u(10), v(10);
+ v = +u;
+ v = -u;
+ v = ~u;
+ std::valarray<bool> z = !u;
+
+ v = abs(u);
+
+ v = cos(u);
+ v = cosh(u);
+ v = acos(u);
+
+ v = sin(u);
+ v = sinh(u);
+ v = asin(u);
+
+ v = tan(u);
+ v = tanh(u);
+ v = atan(u);
+
+ v = exp(u);
+ v = log(u);
+ v = log10(u);
+ v = sqrt(u);
+ }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-08-02 18:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-02 11:15 V3 PATCH: valarray<> fixes (2) Gabriel Dos Reis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).