00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 namespace std
00031 {
00032 _GLIBCXX_BEGIN_NAMESPACE_TR1
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 template<typename _Tp, std::size_t _Nm>
00049 struct array
00050 {
00051 typedef _Tp value_type;
00052 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00053 typedef _Tp* pointer;
00054 typedef const _Tp* const_pointer;
00055 #endif
00056 typedef value_type& reference;
00057 typedef const value_type& const_reference;
00058 typedef value_type* iterator;
00059 typedef const value_type* const_iterator;
00060 typedef std::size_t size_type;
00061 typedef std::ptrdiff_t difference_type;
00062 typedef std::reverse_iterator<iterator> reverse_iterator;
00063 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00064
00065
00066 value_type _M_instance[_Nm ? _Nm : 1];
00067
00068
00069
00070 void
00071 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00072
00073 fill(const value_type& __u)
00074 #else
00075 assign(const value_type& __u)
00076 #endif
00077 { std::fill_n(begin(), size(), __u); }
00078
00079 void
00080 swap(array& __other)
00081 { std::swap_ranges(begin(), end(), __other.begin()); }
00082
00083
00084 iterator
00085 begin()
00086 { return iterator(&_M_instance[0]); }
00087
00088 const_iterator
00089 begin() const
00090 { return const_iterator(&_M_instance[0]); }
00091
00092 iterator
00093 end()
00094 { return iterator(&_M_instance[_Nm]); }
00095
00096 const_iterator
00097 end() const
00098 { return const_iterator(&_M_instance[_Nm]); }
00099
00100 reverse_iterator
00101 rbegin()
00102 { return reverse_iterator(end()); }
00103
00104 const_reverse_iterator
00105 rbegin() const
00106 { return const_reverse_iterator(end()); }
00107
00108 reverse_iterator
00109 rend()
00110 { return reverse_iterator(begin()); }
00111
00112 const_reverse_iterator
00113 rend() const
00114 { return const_reverse_iterator(begin()); }
00115
00116 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00117 const_iterator
00118 cbegin() const
00119 { return const_iterator(&_M_instance[0]); }
00120
00121 const_iterator
00122 cend() const
00123 { return const_iterator(&_M_instance[_Nm]); }
00124
00125 const_reverse_iterator
00126 crbegin() const
00127 { return const_reverse_iterator(end()); }
00128
00129 const_reverse_iterator
00130 crend() const
00131 { return const_reverse_iterator(begin()); }
00132 #endif
00133
00134
00135 size_type
00136 size() const { return _Nm; }
00137
00138 size_type
00139 max_size() const { return _Nm; }
00140
00141 bool
00142 empty() const { return size() == 0; }
00143
00144
00145 reference
00146 operator[](size_type __n)
00147 { return _M_instance[__n]; }
00148
00149 const_reference
00150 operator[](size_type __n) const
00151 { return _M_instance[__n]; }
00152
00153 reference
00154 at(size_type __n)
00155 {
00156 if (__n >= _Nm)
00157 std::__throw_out_of_range(__N("array::at"));
00158 return _M_instance[__n];
00159 }
00160
00161 const_reference
00162 at(size_type __n) const
00163 {
00164 if (__n >= _Nm)
00165 std::__throw_out_of_range(__N("array::at"));
00166 return _M_instance[__n];
00167 }
00168
00169 reference
00170 front()
00171 { return *begin(); }
00172
00173 const_reference
00174 front() const
00175 { return *begin(); }
00176
00177 reference
00178 back()
00179 { return _Nm ? *(end() - 1) : *end(); }
00180
00181 const_reference
00182 back() const
00183 { return _Nm ? *(end() - 1) : *end(); }
00184
00185 _Tp*
00186 data()
00187 { return &_M_instance[0]; }
00188
00189 const _Tp*
00190 data() const
00191 { return &_M_instance[0]; }
00192 };
00193
00194
00195 template<typename _Tp, std::size_t _Nm>
00196 inline bool
00197 operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00198 { return std::equal(__one.begin(), __one.end(), __two.begin()); }
00199
00200 template<typename _Tp, std::size_t _Nm>
00201 inline bool
00202 operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00203 { return !(__one == __two); }
00204
00205 template<typename _Tp, std::size_t _Nm>
00206 inline bool
00207 operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
00208 {
00209 return std::lexicographical_compare(__a.begin(), __a.end(),
00210 __b.begin(), __b.end());
00211 }
00212
00213 template<typename _Tp, std::size_t _Nm>
00214 inline bool
00215 operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00216 { return __two < __one; }
00217
00218 template<typename _Tp, std::size_t _Nm>
00219 inline bool
00220 operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00221 { return !(__one > __two); }
00222
00223 template<typename _Tp, std::size_t _Nm>
00224 inline bool
00225 operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00226 { return !(__one < __two); }
00227
00228
00229 template<typename _Tp, std::size_t _Nm>
00230 inline void
00231 swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
00232 { __one.swap(__two); }
00233
00234
00235
00236
00237 template<typename _Tp>
00238 class tuple_size;
00239
00240
00241 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00242 template<std::size_t _Int, typename _Tp>
00243 #else
00244 template<int _Int, typename _Tp>
00245 #endif
00246 class tuple_element;
00247
00248 template<typename _Tp, std::size_t _Nm>
00249 struct tuple_size<array<_Tp, _Nm> >
00250 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00251 { static const std::size_t value = _Nm; };
00252 #else
00253 { static const int value = _Nm; };
00254 #endif
00255
00256 template<typename _Tp, std::size_t _Nm>
00257 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00258 const std::size_t
00259 #else
00260 const int
00261 #endif
00262 tuple_size<array<_Tp, _Nm> >::value;
00263
00264 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00265 template<std::size_t _Int, typename _Tp, std::size_t _Nm>
00266 #else
00267 template<int _Int, typename _Tp, std::size_t _Nm>
00268 #endif
00269 struct tuple_element<_Int, array<_Tp, _Nm> >
00270 { typedef _Tp type; };
00271
00272 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00273 template<std::size_t _Int, typename _Tp, std::size_t _Nm>
00274 #else
00275 template<int _Int, typename _Tp, std::size_t _Nm>
00276 #endif
00277 inline _Tp&
00278 get(array<_Tp, _Nm>& __arr)
00279 { return __arr[_Int]; }
00280
00281 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00282 template<std::size_t _Int, typename _Tp, std::size_t _Nm>
00283 #else
00284 template<int _Int, typename _Tp, std::size_t _Nm>
00285 #endif
00286 inline const _Tp&
00287 get(const array<_Tp, _Nm>& __arr)
00288 { return __arr[_Int]; }
00289
00290 _GLIBCXX_END_NAMESPACE_TR1
00291 }