]> git.lyx.org Git - lyx.git/blob - src/support/block.h
in addition to the changes mentioned in ChangeLog, there is the usual batch of whites...
[lyx.git] / src / support / block.h
1 // -*- C++ -*-
2
3 #ifndef BLOCK_H
4 #define BLOCK_H
5
6 #include "LAssert.h"
7
8 template <class T, size_t s>
9 class block {
10 public:
11         typedef T value_type;
12         typedef size_t size_type;
13         typedef value_type * pointer;
14         typedef value_type const * const_pointer;
15         typedef value_type & reference;
16         typedef value_type const & const_reference;
17         typedef value_type * iterator;
18         typedef value_type const * const_iterator;
19         size_type size() const { return s; }
20         reference operator[](int i) { return arr[i]; }
21         const_reference operator[](int i) const { return arr[i]; }
22         void operator=(block const & b) {
23                 Assert(b.size() == size());
24                 for (size_t i = 0; i < size(); ++i) {
25                         arr[i] == b[i];
26                 }
27         }
28         bool operator==(block const & b) const {
29                 Assert(b.size() == size());
30                 for (size_t i = 0; i < size(); ++i) {
31                         if (arr[i] != b[i]) return false;
32                 }
33                 return true;
34         }
35         iterator begin() { return arr[0]; }
36         iterator end() { return arr[s]; }
37         const_iterator begin() const { return arr[0]; }
38         const_iterator end() const { return arr[s]; }
39 private:
40         value_type arr[s + 1];
41 };
42
43 #endif // BLOCK_H_