4 #ifndef _util_container_stdarraybits_h
5 #define _util_container_stdarraybits_h
13 template <
typename T, std::
size_t N>
22 typedef const T* const_iterator;
24 typedef const T& const_reference;
25 typedef std::size_t size_type;
26 typedef std::ptrdiff_t difference_type;
29 iterator begin() {
return elems; }
30 const_iterator begin()
const {
return elems; }
31 iterator end() {
return elems+N; }
32 const_iterator end()
const {
return elems+N; }
35 typedef std::reverse_iterator<iterator> reverse_iterator;
36 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
38 reverse_iterator rbegin() {
return reverse_iterator(end()); }
39 const_reverse_iterator rbegin()
const {
40 return const_reverse_iterator(end());
42 reverse_iterator rend() {
return reverse_iterator(begin()); }
43 const_reverse_iterator rend()
const {
44 return const_reverse_iterator(begin());
48 reference operator[](size_type i) {
return elems[i]; }
49 const_reference operator[](size_type i)
const {
return elems[i]; }
52 reference at(size_type i) { rangecheck(i);
return elems[i]; }
53 const_reference at(size_type i)
const { rangecheck(i);
return elems[i]; }
56 reference front() {
return elems[0]; }
57 const_reference front()
const {
return elems[0]; }
58 reference back() {
return elems[N-1]; }
59 const_reference back()
const {
return elems[N-1]; }
62 static size_type size() {
return N; }
63 static bool empty() {
return false; }
64 static size_type max_size() {
return N; }
65 enum { static_size = N };
69 std::swap_ranges(begin(),end(),y.begin());
73 const T* data()
const {
return elems; }
76 T* data() {
return elems; }
79 template <
typename T2>
81 std::copy(rhs.begin(),rhs.end(), begin());
86 void assign (
const T& value)
88 std::fill_n(begin(),size(),value);
93 static void rangecheck (size_type i) {
95 throw std::out_of_range(
"array<>: index out of range");
100 template <
typename T>
107 typedef T value_type;
109 typedef const T* const_iterator;
110 typedef T& reference;
111 typedef const T& const_reference;
112 typedef std::size_t size_type;
113 typedef std::ptrdiff_t difference_type;
116 iterator begin() {
return reinterpret_cast< iterator >( &c ); }
117 const_iterator begin()
const {
return reinterpret_cast< const_iterator >( &c ); }
118 iterator end() {
return reinterpret_cast< iterator >( &c ); }
119 const_iterator end()
const {
return reinterpret_cast< const_iterator >( &c ); }
122 typedef std::reverse_iterator<iterator> reverse_iterator;
123 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
125 reverse_iterator rbegin() {
return reverse_iterator(end()); }
126 const_reverse_iterator rbegin()
const {
127 return const_reverse_iterator(end());
129 reverse_iterator rend() {
return reverse_iterator(begin()); }
130 const_reverse_iterator rend()
const {
131 return const_reverse_iterator(begin());
135 reference at(size_type i) {
138 const_reference at(size_type i)
const {
143 static size_type size() {
return 0; }
144 static bool empty() {
return true; }
145 static size_type max_size() {
return 0; }
146 enum { static_size = 0 };
154 const T* data()
const {
return NULL; }
155 T* data() {
return NULL; }
158 template <
typename T2 >
166 reference operator[](size_type i) { makes_no_sense(); }
167 const_reference operator[](size_type i)
const { makes_no_sense(); }
170 reference front() { makes_no_sense(); }
171 const_reference front()
const { makes_no_sense(); }
172 reference back() { makes_no_sense(); }
173 const_reference back()
const { makes_no_sense(); }
178 static void makes_no_sense () {
180 throw std::out_of_range(
"array<0>: index out of range");
185 template<
class T, std::
size_t N>
187 return std::equal(x.begin(), x.end(), y.begin());
189 template<
class T, std::
size_t N>
190 bool operator< (
const array<T,N>& x,
const array<T,N>& y) {
191 return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
193 template<
class T, std::
size_t N>
194 bool operator!= (
const array<T,N>& x,
const array<T,N>& y) {
197 template<
class T, std::
size_t N>
198 bool operator> (
const array<T,N>& x,
const array<T,N>& y) {
201 template<
class T, std::
size_t N>
202 bool operator<= (
const array<T,N>& x,
const array<T,N>& y) {
205 template<
class T, std::
size_t N>
206 bool operator>= (
const array<T,N>& x,
const array<T,N>& y) {
211 template<
class T, std::
size_t N>
212 inline void swap (array<T,N>& x, array<T,N>& y) {