Subversion Repositories Kolibri OS

Rev

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

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