Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4680 right-hear 1
// The template and inlines for the -*- C++ -*- mask_array class.
2
 
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.
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 
31
 
32
#ifndef _CPP_BITS_MASK_ARRAY_H
33
#define _CPP_BITS_MASK_ARRAY_H 1
34
 
35
#pragma GCC system_header
36
 
37
namespace std {
38
 
39
    template  class mask_array
40
    {
41
    public:
42
        typedef _Tp value_type;
43
 
44
        void operator=  (const valarray<_Tp>&) const;
45
        void operator*= (const valarray<_Tp>&) const;
46
        void operator/= (const valarray<_Tp>&) const;
47
        void operator%= (const valarray<_Tp>&) const;
48
        void operator+= (const valarray<_Tp>&) const;
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 _Tp&);
56
 
57
        //        ~mask_array ();
58
 
59
        template
60
        void operator=  (const _Expr<_Dom,_Tp>&) const;
61
        template
62
        void operator*= (const _Expr<_Dom,_Tp>&) const;
63
        template
64
        void operator/= (const _Expr<_Dom,_Tp>&) const;
65
        template
66
        void operator%= (const _Expr<_Dom,_Tp>&) const;
67
        template
68
        void operator+= (const _Expr<_Dom,_Tp>&) const;
69
        template
70
        void operator-= (const _Expr<_Dom,_Tp>&) const;
71
        template
72
        void operator^= (const _Expr<_Dom,_Tp>&) const;
73
        template
74
        void operator&= (const _Expr<_Dom,_Tp>&) const;
75
        template
76
        void operator|= (const _Expr<_Dom,_Tp>&) const;
77
        template
78
        void operator<<=(const _Expr<_Dom,_Tp>&) const;
79
        template
80
        void operator>>=(const _Expr<_Dom,_Tp>&) const;
81
 
82
    private:
83
        mask_array (_Array<_Tp>, size_t, _Array);
84
        friend class valarray<_Tp>;
85
 
86
        const size_t       _M_sz;
87
        const _Array _M_mask;
88
        const _Array<_Tp>   _M_array;
89
 
90
        mask_array (const mask_array&);
91
 
92
        // not implemented
93
        mask_array ();
94
        mask_array& operator= (const mask_array&);
95
    };
96
 
97
 
98
    template
99
    inline mask_array<_Tp>::mask_array (const mask_array<_Tp>& a)
100
            : _M_sz (a._M_sz), _M_mask (a._M_mask), _M_array (a._M_array) {}
101
 
102
    template
103
    inline
104
    mask_array<_Tp>::mask_array (_Array<_Tp> __a, size_t __s, _Array __m)
105
            : _M_sz (__s), _M_mask (__m), _M_array (__a) {}
106
 
107
    //    template
108
    //    inline mask_array<_Tp>::~mask_array () {}
109
 
110
    template
111
    inline void
112
    mask_array<_Tp>::operator= (const _Tp& __t)
113
    { __valarray_fill (_M_array, _M_sz, _M_mask, __t); }
114
 
115
    template
116
    inline void
117
    mask_array<_Tp>::operator= (const valarray<_Tp>& __v) const
118
    { __valarray_copy (_Array<_Tp> (__v), __v.size (), _M_array, _M_mask); }
119
 
120
    template
121
    template
122
    inline void
123
    mask_array<_Tp>::operator= (const _Expr& __e) const
124
    { __valarray_copy (__e, __e.size (), _M_array, _M_mask); }
125
 
126
#undef _DEFINE_VALARRAY_OPERATOR
127
#define _DEFINE_VALARRAY_OPERATOR(op, name)				\
128
template							\
129
inline void								\
130
mask_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const	\
131
{									\
132
  _Array_augmented_##name (_M_array, _M_mask, 				\
133
                           _Array<_Tp> (__v), __v.size ());		\
134
}									\
135
									\
136
template template				\
137
inline void								\
138
mask_array<_Tp>::operator op##= (const _Expr& __e) const	\
139
{									\
140
  _Array_augmented_##name (_M_array, _M_mask, __e, __e.size ());	\
141
}
142
 
143
_DEFINE_VALARRAY_OPERATOR(*, multiplies)
144
_DEFINE_VALARRAY_OPERATOR(/, divides)
145
_DEFINE_VALARRAY_OPERATOR(%, modulus)
146
_DEFINE_VALARRAY_OPERATOR(+, plus)
147
_DEFINE_VALARRAY_OPERATOR(-, minus)
148
_DEFINE_VALARRAY_OPERATOR(^, xor)
149
_DEFINE_VALARRAY_OPERATOR(&, and)
150
_DEFINE_VALARRAY_OPERATOR(|, or)
151
_DEFINE_VALARRAY_OPERATOR(<<, shift_left)
152
_DEFINE_VALARRAY_OPERATOR(>>, shift_right)
153
 
154
#undef _DEFINE_VALARRAY_OPERATOR
155
 
156
} // std::
157
 
158
#endif /* _CPP_BITS_MASK_ARRAY_H */
159
 
160
// Local Variables:
161
// mode:c++
162
// End: