stl_bvector.h: Change calls to 3-argument distance() into standard 2-argument version.
[official-gcc.git] / libstdc++-v3 / include / bits / mask_array.h
blob13c01d3cc226e70d8abbf5660af084cf0fc064c7
1 // The template and inlines for the -*- C++ -*- mask_array class.
3 // Copyright (C) 1997-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.
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.
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.
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.
30 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
32 /** @file mask_array.h
33 * This is an internal header file, included by other library headers.
34 * You should not attempt to use it directly.
37 #ifndef _CPP_BITS_MASK_ARRAY_H
38 #define _CPP_BITS_MASK_ARRAY_H 1
40 #pragma GCC system_header
42 namespace std {
44 template <class _Tp> class mask_array
46 public:
47 typedef _Tp value_type;
49 void operator= (const valarray<_Tp>&) const;
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 _Tp&);
62 // ~mask_array ();
64 template<class _Dom>
65 void operator= (const _Expr<_Dom,_Tp>&) const;
66 template<class _Dom>
67 void operator*= (const _Expr<_Dom,_Tp>&) const;
68 template<class _Dom>
69 void operator/= (const _Expr<_Dom,_Tp>&) const;
70 template<class _Dom>
71 void operator%= (const _Expr<_Dom,_Tp>&) const;
72 template<class _Dom>
73 void operator+= (const _Expr<_Dom,_Tp>&) const;
74 template<class _Dom>
75 void operator-= (const _Expr<_Dom,_Tp>&) const;
76 template<class _Dom>
77 void operator^= (const _Expr<_Dom,_Tp>&) const;
78 template<class _Dom>
79 void operator&= (const _Expr<_Dom,_Tp>&) const;
80 template<class _Dom>
81 void operator|= (const _Expr<_Dom,_Tp>&) const;
82 template<class _Dom>
83 void operator<<=(const _Expr<_Dom,_Tp>&) const;
84 template<class _Dom>
85 void operator>>=(const _Expr<_Dom,_Tp>&) const;
87 private:
88 mask_array (_Array<_Tp>, size_t, _Array<bool>);
89 friend class valarray<_Tp>;
91 const size_t _M_sz;
92 const _Array<bool> _M_mask;
93 const _Array<_Tp> _M_array;
95 mask_array (const mask_array&);
97 // not implemented
98 mask_array ();
99 mask_array& operator= (const mask_array&);
103 template<typename _Tp>
104 inline mask_array<_Tp>::mask_array (const mask_array<_Tp>& a)
105 : _M_sz (a._M_sz), _M_mask (a._M_mask), _M_array (a._M_array) {}
107 template<typename _Tp>
108 inline
109 mask_array<_Tp>::mask_array (_Array<_Tp> __a, size_t __s, _Array<bool> __m)
110 : _M_sz (__s), _M_mask (__m), _M_array (__a) {}
112 // template<typename _Tp>
113 // inline mask_array<_Tp>::~mask_array () {}
115 template<typename _Tp>
116 inline void
117 mask_array<_Tp>::operator= (const _Tp& __t)
118 { __valarray_fill (_M_array, _M_sz, _M_mask, __t); }
120 template<typename _Tp>
121 inline void
122 mask_array<_Tp>::operator= (const valarray<_Tp>& __v) const
123 { __valarray_copy (_Array<_Tp> (__v), __v.size (), _M_array, _M_mask); }
125 template<typename _Tp>
126 template<class E>
127 inline void
128 mask_array<_Tp>::operator= (const _Expr<E, _Tp>& __e) const
129 { __valarray_copy (__e, __e.size (), _M_array, _M_mask); }
131 #undef _DEFINE_VALARRAY_OPERATOR
132 #define _DEFINE_VALARRAY_OPERATOR(op, name) \
133 template<typename _Tp> \
134 inline void \
135 mask_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \
137 _Array_augmented_##name (_M_array, _M_mask, \
138 _Array<_Tp> (__v), __v.size ()); \
141 template<typename _Tp> template<class E> \
142 inline void \
143 mask_array<_Tp>::operator op##= (const _Expr<E, _Tp>& __e) const \
145 _Array_augmented_##name (_M_array, _M_mask, __e, __e.size ()); \
148 _DEFINE_VALARRAY_OPERATOR(*, multiplies)
149 _DEFINE_VALARRAY_OPERATOR(/, divides)
150 _DEFINE_VALARRAY_OPERATOR(%, modulus)
151 _DEFINE_VALARRAY_OPERATOR(+, plus)
152 _DEFINE_VALARRAY_OPERATOR(-, minus)
153 _DEFINE_VALARRAY_OPERATOR(^, xor)
154 _DEFINE_VALARRAY_OPERATOR(&, and)
155 _DEFINE_VALARRAY_OPERATOR(|, or)
156 _DEFINE_VALARRAY_OPERATOR(<<, shift_left)
157 _DEFINE_VALARRAY_OPERATOR(>>, shift_right)
159 #undef _DEFINE_VALARRAY_OPERATOR
161 } // std::
163 #endif /* _CPP_BITS_MASK_ARRAY_H */
165 // Local Variables:
166 // mode:c++
167 // End: