source: trunk/src/gcc/libstdc++-v3/include/bits/indirect_array.h@ 284

Last change on this file since 284 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 6.1 KB
Line 
1// The template and inlines for the -*- C++ -*- indirect_array class.
2
3// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 2, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING. If not, write to the Free
18// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19// USA.
20
21// As a special exception, you may use this file as part of a free software
22// library without restriction. Specifically, if other files instantiate
23// templates or use macros or inline functions from this file, or you compile
24// this file and link it with other files to produce an executable, this
25// file does not by itself cause the resulting executable to be covered by
26// the GNU General Public License. This exception does not however
27// invalidate any other reasons why the executable file might be covered by
28// the GNU General Public License.
29
30// Written by Gabriel Dos Reis <[email protected]>
31
32/** @file indirect_array.h
33 * This is an internal header file, included by other library headers.
34 * You should not attempt to use it directly.
35 */
36
37#ifndef _CPP_BITS_INDIRECT_ARRAY_H
38#define _CPP_BITS_INDIRECT_ARRAY_H 1
39
40#pragma GCC system_header
41
42namespace std
43{
44 template <class _Tp>
45 class indirect_array
46 {
47 public:
48 typedef _Tp value_type;
49
50 // XXX: This is a proposed resolution for DR-253.
51 indirect_array& operator= (const indirect_array&);
52
53 void operator= (const valarray<_Tp>&) const;
54 void operator*= (const valarray<_Tp>&) const;
55 void operator/= (const valarray<_Tp>&) const;
56 void operator%= (const valarray<_Tp>&) const;
57 void operator+= (const valarray<_Tp>&) const;
58 void operator-= (const valarray<_Tp>&) const;
59 void operator^= (const valarray<_Tp>&) const;
60 void operator&= (const valarray<_Tp>&) const;
61 void operator|= (const valarray<_Tp>&) const;
62 void operator<<= (const valarray<_Tp>&) const;
63 void operator>>= (const valarray<_Tp>&) const;
64 void operator= (const _Tp&);
65 // ~indirect_array();
66
67 template<class _Dom>
68 void operator= (const _Expr<_Dom, _Tp>&) const;
69 template<class _Dom>
70 void operator*= (const _Expr<_Dom, _Tp>&) const;
71 template<class _Dom>
72 void operator/= (const _Expr<_Dom, _Tp>&) const;
73 template<class _Dom>
74 void operator%= (const _Expr<_Dom, _Tp>&) const;
75 template<class _Dom>
76 void operator+= (const _Expr<_Dom, _Tp>&) const;
77 template<class _Dom>
78 void operator-= (const _Expr<_Dom, _Tp>&) const;
79 template<class _Dom>
80 void operator^= (const _Expr<_Dom, _Tp>&) const;
81 template<class _Dom>
82 void operator&= (const _Expr<_Dom, _Tp>&) const;
83 template<class _Dom>
84 void operator|= (const _Expr<_Dom, _Tp>&) const;
85 template<class _Dom>
86 void operator<<= (const _Expr<_Dom, _Tp>&) const;
87 template<class _Dom>
88 void operator>>= (const _Expr<_Dom, _Tp>&) const;
89
90 private:
91 indirect_array (const indirect_array&);
92 indirect_array (_Array<_Tp>, size_t, _Array<size_t>);
93
94 friend class valarray<_Tp>;
95 friend class gslice_array<_Tp>;
96
97 const size_t _M_sz;
98 const _Array<size_t> _M_index;
99 const _Array<_Tp> _M_array;
100
101 // not implemented
102 indirect_array ();
103 };
104
105 template<typename _Tp>
106 inline indirect_array<_Tp>::indirect_array(const indirect_array<_Tp>& __a)
107 : _M_sz (__a._M_sz), _M_index (__a._M_index),
108 _M_array (__a._M_array) {}
109
110 template<typename _Tp>
111 inline
112 indirect_array<_Tp>::indirect_array (_Array<_Tp> __a, size_t __s,
113 _Array<size_t> __i)
114 : _M_sz (__s), _M_index (__i), _M_array (__a) {}
115
116 template<typename _Tp>
117 inline indirect_array<_Tp>&
118 indirect_array<_Tp>::operator=(const indirect_array<_Tp>& __a)
119 {
120 __valarray_copy(__a._M_array, _M_sz, __a._M_index, _M_array, _M_index);
121 return *this;
122 }
123
124
125 template<typename _Tp>
126 inline void
127 indirect_array<_Tp>::operator= (const _Tp& __t)
128 { __valarray_fill(_M_array, _M_index, _M_sz, __t); }
129
130 template<typename _Tp>
131 inline void
132 indirect_array<_Tp>::operator= (const valarray<_Tp>& __v) const
133 { __valarray_copy (_Array<_Tp> (__v), _M_sz, _M_array, _M_index); }
134
135 template<typename _Tp>
136 template<class _Dom>
137 inline void
138 indirect_array<_Tp>::operator= (const _Expr<_Dom,_Tp>& __e) const
139 { __valarray_copy (__e, _M_sz, _M_array, _M_index); }
140
141#undef _DEFINE_VALARRAY_OPERATOR
142#define _DEFINE_VALARRAY_OPERATOR(op, name) \
143template<typename _Tp> \
144inline void \
145indirect_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \
146{ \
147 _Array_augmented_##name (_M_array, _M_index, _Array<_Tp> (__v), _M_sz); \
148} \
149 \
150template<typename _Tp> template<class _Dom> \
151inline void \
152indirect_array<_Tp>::operator op##= (const _Expr<_Dom,_Tp>& __e) const \
153{ \
154 _Array_augmented_##name (_M_array, _M_index, __e, _M_sz); \
155}
156
157_DEFINE_VALARRAY_OPERATOR(*, multiplies)
158_DEFINE_VALARRAY_OPERATOR(/, divides)
159_DEFINE_VALARRAY_OPERATOR(%, modulus)
160_DEFINE_VALARRAY_OPERATOR(+, plus)
161_DEFINE_VALARRAY_OPERATOR(-, minus)
162_DEFINE_VALARRAY_OPERATOR(^, xor)
163_DEFINE_VALARRAY_OPERATOR(&, and)
164_DEFINE_VALARRAY_OPERATOR(|, or)
165_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
166_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
167
168#undef _DEFINE_VALARRAY_OPERATOR
169
170} // std::
171
172#endif /* _CPP_BITS_INDIRECT_ARRAY_H */
173
174// Local Variables:
175// mode:c++
176// End:
Note: See TracBrowser for help on using the repository browser.