cartobase 6.0.6
block.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34#ifndef CARTOBASE_BLOCK_BLOCK_H
35#define CARTOBASE_BLOCK_BLOCK_H
36
37
39#include <iterator>
40#include <assert.h>
41
42
43namespace carto
44{
45
60
61template < class T, size_t N >
62struct block
63{
64
65 typedef T value_type;
67 typedef const value_type* const_pointer;
70
71 typedef ptrdiff_t difference_type;
72 typedef size_t size_type;
73
76
77#if defined(CARTO_NO_PARTIAL_TEMPLATE_SPECIALIZATION)
78
79 typedef std::reverse_iterator< iterator, value_type > reverse_iterator;
80 typedef std::reverse_iterator< const_iterator,
82#else
83
84 typedef std::reverse_iterator< iterator > reverse_iterator;
85 typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
86
87#endif
88
89 reference operator[]( size_t d );
90 const_reference operator[]( size_t d ) const;
91
93 iterator end();
94 const_iterator begin() const;
95 const_iterator end() const;
100
101 size_type size() const;
102 size_type max_size() const;
103 bool empty() const;
104
105 T data[ N ];
106
107};
108
109
110} // namespace carto
111
112
113template < class T, size_t N>
114inline
117{
118
119 assert( d < N );
120 return data[ d ];
121
122}
123
124
125template < class T, size_t N >
126inline
129{
130
131 assert( d < N );
132 return data[ d ];
133
134}
135
136
137template < class T, size_t N >
138inline
140{
141
142 return data;
143
144}
145
146
147template < class T, size_t N >
148inline
150{
151
152 return data + N;
153
154}
155
156
157template < class T, size_t N >
158inline
161{
162
163 return data;
164
165}
166
167
168template < class T, size_t N >
169inline
171{
172
173 return data + N;
174
175}
176
177
178template < class T, size_t N >
179inline
186
187
188template < class T, size_t N >
189inline
196
197
198template < class T, size_t N >
199inline
202{
203
204 return const_reverse_iterator( end() );
205
206}
207
208
209template < class T, size_t N >
210inline
213{
214
215 return const_reverse_iterator( begin() );
216
217}
218
219
220template < class T, size_t N >
221inline
223{
224
225 return N;
226
227}
228
229
230template < class T, size_t N >
231inline
233{
234
235 return N;
236
237}
238
239
240template < class T, size_t N >
241inline
243{
244
245 return N == 0;
246
247}
248
249
250template < class T, size_t N >
251inline
253 const carto::block< T, N >& b2)
254{
255
256 for ( size_t n = 0; n < N; ++n )
257 if ( b1.data[ n ] != b2.data[ n ] )
258 return false;
259 return true;
260
261}
262
263
264#endif
bool operator==(const carto::block< T, N > &b1, const carto::block< T, N > &b2)
Definition block.h:252
This array class extends the STL.
Definition block.h:63
size_type max_size() const
Definition block.h:232
reverse_iterator rbegin()
Definition block.h:180
pointer iterator
Definition block.h:74
iterator end()
Definition block.h:149
const value_type * const_pointer
Definition block.h:67
ptrdiff_t difference_type
Definition block.h:71
value_type * pointer
Definition block.h:66
iterator begin()
Definition block.h:139
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition block.h:85
size_type size() const
Definition block.h:222
const_pointer const_iterator
Definition block.h:75
size_t size_type
Definition block.h:72
reverse_iterator rend()
Definition block.h:190
reference operator[](size_t d)
Definition block.h:116
T data[N]
Definition block.h:105
value_type & reference
Definition block.h:68
const value_type & const_reference
Definition block.h:69
std::reverse_iterator< iterator > reverse_iterator
Definition block.h:84
T value_type
Definition block.h:65
bool empty() const
Definition block.h:242