]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/bits/gslice_array.h
Move from CPP to CXX.
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / gslice_array.h
CommitLineData
725dc051
BK
1// The template and inlines for the -*- C++ -*- gslice_array class.
2
aefb3380 3// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
725dc051
BK
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 <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
31
729e3d3f
PE
32/** @file gslice_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
3d7c150e
BK
37#ifndef _GSLICE_ARRAY_H
38#define _GSLICE_ARRAY_H 1
725dc051 39
b0a85b86
GDR
40#pragma GCC system_header
41
725dc051
BK
42namespace std {
43
00386a9b
GDR
44 template<typename _Tp>
45 class gslice_array
725dc051
BK
46 {
47 public:
00386a9b
GDR
48 typedef _Tp value_type;
49
50 void operator=(const valarray<_Tp>&) const;
51 void operator*=(const valarray<_Tp>&) const;
52 void operator/=(const valarray<_Tp>&) const;
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 _Tp&) const;
62
63 template<class _Dom>
64 void operator=(const _Expr<_Dom,_Tp>&) const;
65 template<class _Dom>
66 void operator*=(const _Expr<_Dom,_Tp>&) const;
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;
725dc051
BK
85
86 private:
00386a9b
GDR
87 _Array<_Tp> _M_array;
88 const valarray<size_t>& _M_index;
725dc051 89
00386a9b
GDR
90 friend class valarray<_Tp>;
91
92 gslice_array(_Array<_Tp>, const valarray<size_t>&);
725dc051 93
00386a9b
GDR
94 // this constructor needs to be implemented.
95 gslice_array(const gslice_array&);
725dc051 96
00386a9b
GDR
97 // not implemented
98 gslice_array();
99 gslice_array& operator= (const gslice_array&);
725dc051
BK
100 };
101
00386a9b 102 template<typename _Tp>
725dc051 103 inline
00386a9b
GDR
104 gslice_array<_Tp>::gslice_array(_Array<_Tp> __a,
105 const valarray<size_t>& __i)
106 : _M_array(__a), _M_index(__i) {}
725dc051
BK
107
108
00386a9b 109 template<typename _Tp>
725dc051 110 inline
00386a9b
GDR
111 gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a)
112 : _M_array(__a._M_array), _M_index(__a._M_index) {}
725dc051
BK
113
114
00386a9b 115 template<typename _Tp>
725dc051 116 inline void
00386a9b 117 gslice_array<_Tp>::operator=(const _Tp& __t) const
725dc051 118 {
5b5bf717
PC
119 std::__valarray_fill(_M_array, _Array<size_t>(_M_index),
120 _M_index.size(), __t);
725dc051
BK
121 }
122
00386a9b 123 template<typename _Tp>
725dc051 124 inline void
00386a9b 125 gslice_array<_Tp>::operator=(const valarray<_Tp>& __v) const
725dc051 126 {
5b5bf717
PC
127 std::__valarray_copy(_Array<_Tp>(__v), __v.size(),
128 _M_array, _Array<size_t>(_M_index));
725dc051
BK
129 }
130
00386a9b
GDR
131 template<typename _Tp>
132 template<class _Dom>
133 inline void
134 gslice_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const
135 {
5b5bf717
PC
136 std::__valarray_copy (__e, _M_index.size(), _M_array,
137 _Array<size_t>(_M_index));
00386a9b 138 }
725dc051
BK
139
140#undef _DEFINE_VALARRAY_OPERATOR
00386a9b
GDR
141#define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
142 template<typename _Tp> \
143 inline void \
144 gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
145 { \
146 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), \
147 _Array<_Tp>(__v), __v.size()); \
148 } \
725dc051 149 \
00386a9b
GDR
150 template<typename _Tp> \
151 template<class _Dom> \
152 inline void \
153 gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\
154 { \
155 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), __e,\
156 _M_index.size()); \
157 }
158
159_DEFINE_VALARRAY_OPERATOR(*, __multiplies)
160_DEFINE_VALARRAY_OPERATOR(/, __divides)
161_DEFINE_VALARRAY_OPERATOR(%, __modulus)
162_DEFINE_VALARRAY_OPERATOR(+, __plus)
163_DEFINE_VALARRAY_OPERATOR(-, __minus)
164_DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
165_DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
166_DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
167_DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
168_DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
725dc051
BK
169
170#undef _DEFINE_VALARRAY_OPERATOR
171
172} // std::
173
3d7c150e 174#endif /* _GSLICE_ARRAY_H */
725dc051
BK
175
176// Local Variables:
177// mode:c++
178// End: