indirect_array.h

Go to the documentation of this file.
00001 // The template and inlines for the -*- C++ -*- indirect_array class. 00002 00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 00004 // Free Software Foundation, Inc. 00005 // 00006 // This file is part of the GNU ISO C++ Library. This library is free 00007 // software; you can redistribute it and/or modify it under the 00008 // terms of the GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 00017 // You should have received a copy of the GNU General Public License along 00018 // with this library; see the file COPYING. If not, write to the Free 00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00020 // USA. 00021 00022 // As a special exception, you may use this file as part of a free software 00023 // library without restriction. Specifically, if other files instantiate 00024 // templates or use macros or inline functions from this file, or you compile 00025 // this file and link it with other files to produce an executable, this 00026 // file does not by itself cause the resulting executable to be covered by 00027 // the GNU General Public License. This exception does not however 00028 // invalidate any other reasons why the executable file might be covered by 00029 // the GNU General Public License. 00030 00031 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr> 00032 00033 /** @file indirect_array.h 00034 * This is an internal header file, included by other library headers. 00035 * You should not attempt to use it directly. 00036 */ 00037 00038 #ifndef _CPP_BITS_INDIRECT_ARRAY_H 00039 #define _CPP_BITS_INDIRECT_ARRAY_H 1 00040 00041 #pragma GCC system_header 00042 00043 namespace std 00044 { 00045 template <class _Tp> 00046 class indirect_array 00047 { 00048 public: 00049 typedef _Tp value_type; 00050 00051 // XXX: This is a proposed resolution for DR-253. 00052 indirect_array& operator=(const indirect_array&); 00053 00054 void operator=(const valarray<_Tp>&) const; 00055 void operator*=(const valarray<_Tp>&) const; 00056 void operator/=(const valarray<_Tp>&) const; 00057 void operator%=(const valarray<_Tp>&) const; 00058 void operator+=(const valarray<_Tp>&) const; 00059 void operator-=(const valarray<_Tp>&) const; 00060 void operator^=(const valarray<_Tp>&) const; 00061 void operator&=(const valarray<_Tp>&) const; 00062 void operator|=(const valarray<_Tp>&) const; 00063 void operator<<=(const valarray<_Tp>&) const; 00064 void operator>>=(const valarray<_Tp>&) const; 00065 void operator= (const _Tp&) const; 00066 // ~indirect_array(); 00067 00068 template<class _Dom> 00069 void operator=(const _Expr<_Dom, _Tp>&) const; 00070 template<class _Dom> 00071 void operator*=(const _Expr<_Dom, _Tp>&) const; 00072 template<class _Dom> 00073 void operator/=(const _Expr<_Dom, _Tp>&) const; 00074 template<class _Dom> 00075 void operator%=(const _Expr<_Dom, _Tp>&) const; 00076 template<class _Dom> 00077 void operator+=(const _Expr<_Dom, _Tp>&) const; 00078 template<class _Dom> 00079 void operator-=(const _Expr<_Dom, _Tp>&) const; 00080 template<class _Dom> 00081 void operator^=(const _Expr<_Dom, _Tp>&) const; 00082 template<class _Dom> 00083 void operator&=(const _Expr<_Dom, _Tp>&) const; 00084 template<class _Dom> 00085 void operator|=(const _Expr<_Dom, _Tp>&) const; 00086 template<class _Dom> 00087 void operator<<=(const _Expr<_Dom, _Tp>&) const; 00088 template<class _Dom> 00089 void operator>>=(const _Expr<_Dom, _Tp>&) const; 00090 00091 private: 00092 indirect_array(const indirect_array&); 00093 indirect_array(_Array<_Tp>, size_t, _Array<size_t>); 00094 00095 friend class valarray<_Tp>; 00096 friend class gslice_array<_Tp>; 00097 00098 const size_t _M_sz; 00099 const _Array<size_t> _M_index; 00100 const _Array<_Tp> _M_array; 00101 00102 // not implemented 00103 indirect_array(); 00104 }; 00105 00106 template<typename _Tp> 00107 inline 00108 indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a) 00109 : _M_sz(__a._M_sz), _M_index(__a._M_index), _M_array(__a._M_array) {} 00110 00111 template<typename _Tp> 00112 inline 00113 indirect_array<_Tp>::indirect_array(_Array<_Tp> __a, size_t __s, 00114 _Array<size_t> __i) 00115 : _M_sz(__s), _M_index(__i), _M_array(__a) {} 00116 00117 template<typename _Tp> 00118 inline indirect_array<_Tp>& 00119 indirect_array<_Tp>::operator=(const indirect_array<_Tp>& __a) 00120 { 00121 __valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array, _M_index); 00122 return *this; 00123 } 00124 00125 00126 template<typename _Tp> 00127 inline void 00128 indirect_array<_Tp>::operator=(const _Tp& __t) const 00129 { __valarray_fill(_M_array, _M_index, _M_sz, __t); } 00130 00131 template<typename _Tp> 00132 inline void 00133 indirect_array<_Tp>::operator=(const valarray<_Tp>& __v) const 00134 { __valarray_copy(_Array<_Tp>(__v), _M_sz, _M_array, _M_index); } 00135 00136 template<typename _Tp> 00137 template<class _Dom> 00138 inline void 00139 indirect_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const 00140 { __valarray_copy(__e, _M_sz, _M_array, _M_index); } 00141 00142 #undef _DEFINE_VALARRAY_OPERATOR 00143 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \ 00144 template<typename _Tp> \ 00145 inline void \ 00146 indirect_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const\ 00147 { \ 00148 _Array_augmented_##_Name(_M_array, _M_index, _Array<_Tp>(__v), _M_sz); \ 00149 } \ 00150 \ 00151 template<typename _Tp> \ 00152 template<class _Dom> \ 00153 inline void \ 00154 indirect_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\ 00155 { \ 00156 _Array_augmented_##_Name(_M_array, _M_index, __e, _M_sz); \ 00157 } 00158 00159 _DEFINE_VALARRAY_OPERATOR(*, __multiplies) 00160 _DEFINE_VALARRAY_OPERATOR(/, __divides) 00161 _DEFINE_VALARRAY_OPERATOR(%, __modulus) 00162 _DEFINE_VALARRAY_OPERATOR(+, __plus) 00163 _DEFINE_VALARRAY_OPERATOR(-, __minus) 00164 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor) 00165 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and) 00166 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or) 00167 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left) 00168 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right) 00169 00170 #undef _DEFINE_VALARRAY_OPERATOR 00171 00172 } // std:: 00173 00174 #endif /* _CPP_BITS_INDIRECT_ARRAY_H */ 00175 00176 // Local Variables: 00177 // mode:c++ 00178 // End:

Generated on Wed Aug 4 21:43:12 2004 for libstdc++-v3 Source by doxygen 1.3.8