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
This commit is contained in:
Paolo Carlini 2004-07-08 20:48:04 +00:00 committed by Paolo Carlini
parent d222b827dc
commit b714a4192e
10 changed files with 798 additions and 648 deletions

View File

@ -1,3 +1,15 @@
2004-07-08 Paolo Carlini <pcarlini@suse.de>
* include/bits/gslice.h: Trivial formatting fixes.
* include/bits/gslice_array.h: Likewise.
* include/bits/indirect_array.h: Likewise.
* include/bits/mask_array.h: Likewise.
* include/bits/slice_array.h: Likewise.
* include/bits/valarray_after.h: Likewise.
* include/bits/valarray_array.h: Likewise.
* include/bits/valarray_before.h: Likewise.
* include/std/std_valarray.h: Likewise.
2004-07-08 Benjamin Kosnik <bkoz@redhat.com>
PR c++/16169

View File

@ -40,8 +40,8 @@
#pragma GCC system_header
namespace std {
namespace std
{
/**
* @brief Class defining multi-dimensional subset of an array.
*
@ -101,7 +101,8 @@ namespace std {
valarray<size_t> stride() const;
private:
struct _Indexer {
struct _Indexer
{
size_t _M_count;
size_t _M_start;
valarray<size_t> _M_size;
@ -109,8 +110,13 @@ namespace std {
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; }
void
_M_increment_use()
{ ++_M_count; }
size_t
_M_decrement_use()
{ return --_M_count; }
};
_Indexer* _M_index;
@ -143,21 +149,24 @@ namespace std {
inline
gslice::~gslice()
{ if (_M_index && _M_index->_M_decrement_use() == 0) delete _M_index; }
{
if (_M_index && _M_index->_M_decrement_use() == 0)
delete _M_index;
}
inline gslice&
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;
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 */
// Local Variables:

View File

@ -40,8 +40,8 @@
#pragma GCC system_header
namespace std {
namespace std
{
/**
* @brief Reference to multi-dimensional subset of an 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)

View File

@ -156,7 +156,6 @@ namespace std
return *this;
}
template<typename _Tp>
inline void
indirect_array<_Tp>::operator=(const _Tp& __t) const

View File

@ -40,8 +40,8 @@
#pragma GCC system_header
namespace std {
namespace std
{
/**
* @brief Reference to selected subset of an array.
*
@ -134,7 +134,6 @@ namespace std {
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) {}

View File

@ -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,41 +42,57 @@
namespace std
{
//
// gslice_array closure.
//
template<class _Dom> class _GBase {
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
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_index[__i]]; }
size_t size () const { return _M_index.size(); }
size_t
size () const
{ return _M_index.size(); }
private:
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
value_type
operator[] (size_t __i) const
{ return _M_array._M_data[_M_index[__i]]; }
size_t size () const { return _M_index.size(); }
size_t
size () const
{ return _M_index.size(); }
private:
const _Array<_Tp> _M_array;
const valarray<size_t>& _M_index;
};
template<class _Dom> struct _GClos<_Expr,_Dom> : _GBase<_Dom> {
template<class _Dom>
struct _GClos<_Expr, _Dom>
: _GBase<_Dom>
{
typedef _GBase<_Dom> _Base;
typedef typename _Base::value_type value_type;
@ -84,7 +101,9 @@ namespace std
};
template<typename _Tp>
struct _GClos<_ValArray,_Tp> : _GBase<_Array<_Tp> > {
struct _GClos<_ValArray, _Tp>
: _GBase<_Array<_Tp> >
{
typedef _GBase<_Array<_Tp> > _Base;
typedef typename _Base::value_type value_type;
@ -95,14 +114,19 @@ namespace std
//
// indirect_array closure
//
template<class _Dom> class _IBase {
template<class _Dom>
class _IBase
{
public:
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
value_type
operator[] (size_t __i) const
{ return _M_expr[_M_index[__i]]; }
size_t size() const { return _M_index.size(); }
private:
@ -110,7 +134,10 @@ namespace std
const valarray<size_t>& _M_index;
};
template<class _Dom> struct _IClos<_Expr,_Dom> : _IBase<_Dom> {
template<class _Dom>
struct _IClos<_Expr, _Dom>
: _IBase<_Dom>
{
typedef _IBase<_Dom> _Base;
typedef typename _Base::value_type value_type;
@ -119,7 +146,9 @@ namespace std
};
template<typename _Tp>
struct _IClos<_ValArray,_Tp> : _IBase<valarray<_Tp> > {
struct _IClos<_ValArray, _Tp>
: _IBase<valarray<_Tp> >
{
typedef _IBase<valarray<_Tp> > _Base;
typedef _Tp value_type;
@ -210,7 +239,8 @@ namespace std
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>
@ -282,7 +312,6 @@ 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>, \
@ -297,7 +326,8 @@ namespace std
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name,_Expr,_Constant,_Dom,typename _Dom::value_type>,\
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) \
@ -309,7 +339,8 @@ operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __v, \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name,_Constant,_Expr,typename _Dom::value_type,_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) \
@ -321,7 +352,8 @@ operator _Op(const typename _Dom::value_type& __t, \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name,_Expr,_ValArray,_Dom,typename _Dom::value_type>,\
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) \
@ -333,7 +365,8 @@ operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \
} \
\
template<class _Dom> \
inline _Expr<_BinClos<_Name,_ValArray,_Expr,typename _Dom::value_type,_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) \
@ -367,7 +400,8 @@ 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>\
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; \
@ -491,7 +525,6 @@ _DEFINE_EXPR_BINARY_FUNCTION(pow)
} // std::
#endif /* _CPP_VALARRAY_AFTER_H */
// Local Variables:

View File

@ -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>
@ -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; }
{
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; }
{
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>
@ -250,14 +288,20 @@ namespace std
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; }
{
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; }
{
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.
@ -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;
}
@ -453,10 +505,12 @@ namespace std
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)
inline
_Array<_Tp>::_Array(const valarray<_Tp>& __v)
: _M_data (__v._M_data) {}
template<typename _Tp>
@ -494,7 +548,8 @@ _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]; \
for (size_t __i = 0; __i < __n; ++__i, ++__p) \
*__p _Op##= __e[__i]; \
} \
\
template<typename _Tp> \
@ -503,7 +558,8 @@ _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) \
for (_Tp* __p = __a._M_data; __p < __a._M_data + __s * __n; \
__p += __s, ++__q) \
*__p _Op##= *__q; \
} \
\
@ -513,7 +569,8 @@ _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) \
for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
++__p, __q += __s) \
*__p _Op##= *__q; \
} \
\
@ -523,7 +580,8 @@ _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]; \
for (size_t __i = 0; __i < __n; ++__i, __p += __s) \
*__p _Op##= __e[__i]; \
} \
\
template<typename _Tp> \
@ -532,7 +590,8 @@ _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) \
for (size_t* __j = __i._M_data; __j < __i._M_data + __n; \
++__j, ++__q) \
__a._M_data[*__j] _Op##= *__q; \
} \
\
@ -542,7 +601,8 @@ _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) \
for (size_t* __j = __i._M_data; __j<__i._M_data + __n; \
++__j, ++__p) \
*__p _Op##= __b._M_data[*__j]; \
} \
\
@ -561,11 +621,14 @@ void \
_Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
_Array<_Tp> __b, size_t __n) \
{ \
bool* ok (__m._M_data); \
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; \
for (_Tp* __q = __b._M_data; __q < __b._M_data + __n; \
++__q, ++__ok, ++__p) \
{ \
while (! *__ok) \
{ \
++__ok; \
++__p; \
} \
*__p _Op##= *__q; \
@ -577,11 +640,14 @@ void \
_Array_augmented_##_Name(_Array<_Tp> __a, size_t __n, \
_Array<_Tp> __b, _Array<bool> __m) \
{ \
bool* ok (__m._M_data); \
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; \
for (_Tp* __p = __a._M_data; __p < __a._M_data + __n; \
++__p, ++__ok, ++__q) \
{ \
while (! *__ok) \
{ \
++__ok; \
++__q; \
} \
*__p _Op##= *__q; \
@ -593,11 +659,13 @@ void \
_Array_augmented_##_Name(_Array<_Tp> __a, _Array<bool> __m, \
const _Expr<_Dom, _Tp>& __e, size_t __n) \
{ \
bool* ok(__m._M_data); \
bool* __ok(__m._M_data); \
_Tp* __p(__a._M_data); \
for (size_t __i=0; __i<__n; ++__i, ++ok, ++__p) { \
while (! *ok) { \
++ok; \
for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p) \
{ \
while (! *__ok) \
{ \
++__ok; \
++__p; \
} \
*__p _Op##= __e[__i]; \

View File

@ -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
@ -424,8 +442,8 @@ 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;
@ -436,7 +454,8 @@ namespace std
};
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;
@ -468,7 +487,8 @@ namespace std
};
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;
@ -640,35 +661,48 @@ namespace std
_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
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 (); }
size_t
size() const
{ return _M_slice.size (); }
private:
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
value_type
operator[] (size_t __i) const
{ return _M_array._M_data[__i * _M_stride]; }
size_t size() const { return _M_size; }
size_t
size() const
{ return _M_size; }
private:
const _Array<_Tp> _M_array;
@ -676,7 +710,10 @@ namespace std
const size_t _M_stride;
};
template<class _Dom> struct _SClos<_Expr,_Dom> : _SBase<_Dom> {
template<class _Dom>
struct _SClos<_Expr, _Dom>
: _SBase<_Dom>
{
typedef _SBase<_Dom> _Base;
typedef typename _Base::value_type value_type;
@ -684,7 +721,9 @@ namespace std
};
template<typename _Tp>
struct _SClos<_ValArray,_Tp> : _SBase<_Array<_Tp> > {
struct _SClos<_ValArray, _Tp>
: _SBase<_Array<_Tp> >
{
typedef _SBase<_Array<_Tp> > _Base;
typedef _Tp value_type;
@ -693,7 +732,6 @@ namespace std
} // std::
#endif /* _CPP_VALARRAY_BEFORE_H */
// Local Variables:

View File

@ -148,6 +148,7 @@ namespace std
template<class _Dom>
valarray(const _Expr<_Dom, _Tp>& __e);
~valarray();
// _lib.valarray.assign_ assignment:
@ -425,7 +426,6 @@ namespace std
template<class _Dom>
valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&);
// _lib.valarray.members_ member functions:
/// Return the number of elements in array.
size_t size() const;
@ -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.
*
@ -580,7 +577,8 @@ namespace std
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); }
{ std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
_M_data); }
template<typename _Tp>
inline
@ -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,13 +794,16 @@ 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);
@ -827,8 +819,10 @@ 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
{