-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcarray.h
More file actions
34 lines (26 loc) · 769 Bytes
/
carray.h
File metadata and controls
34 lines (26 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef CARRAY_H
#define CARRAY_H
#include <cstddef>
template<typename T, size_t thesize>
class carray {
private :
T v[thesize];
public :
typedef T value_type;
typedef T* iterator;
typedef const T* const_iterator;
typedef T& reference;
typedef const T& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
iterator begin() { return v; }
const_iterator begin() const { return v; }
iterator end() { return v+thesize; }
const_iterator end() const { return v+thesize; }
reference operator[](size_t i) { return v[i]; }
const_reference operator[](size_t i) const { return v[i]; }
size_type size() const { return thesize; }
size_type max_size() const { return thesize; }
T* as_array() { return v; }
};
#endif