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
00031
00032
00033
00034
00035 namespace std
00036 {
00037 _GLIBCXX_BEGIN_NAMESPACE_TR1
00038
00039
00040
00041 template<typename _Tp, std::size_t _Nm>
00042 struct array
00043 {
00044 typedef _Tp value_type;
00045 typedef value_type& reference;
00046 typedef const value_type& const_reference;
00047 typedef value_type* iterator;
00048 typedef const value_type* const_iterator;
00049 typedef std::size_t size_type;
00050 typedef std::ptrdiff_t difference_type;
00051 typedef std::reverse_iterator<iterator> reverse_iterator;
00052 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00053
00054
00055 value_type _M_instance[_Nm ? _Nm : 1];
00056
00057
00058
00059 void
00060 assign(const value_type& __u)
00061 { std::fill_n(begin(), size(), __u); }
00062
00063 void
00064 swap(array& __other)
00065 { std::swap_ranges(begin(), end(), __other.begin()); }
00066
00067
00068 iterator
00069 begin()
00070 { return iterator(&_M_instance[0]); }
00071
00072 const_iterator
00073 begin() const
00074 { return const_iterator(&_M_instance[0]); }
00075
00076 iterator
00077 end()
00078 { return iterator(&_M_instance[_Nm]); }
00079
00080 const_iterator
00081 end() const
00082 { return const_iterator(&_M_instance[_Nm]); }
00083
00084 reverse_iterator
00085 rbegin()
00086 { return reverse_iterator(end()); }
00087
00088 const_reverse_iterator
00089 rbegin() const
00090 { return const_reverse_iterator(end()); }
00091
00092 reverse_iterator
00093 rend()
00094 { return reverse_iterator(begin()); }
00095
00096 const_reverse_iterator
00097 rend() const
00098 { return const_reverse_iterator(begin()); }
00099
00100 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00101 const_iterator
00102 cbegin() const
00103 { return const_iterator(&_M_instance[0]); }
00104
00105 const_iterator
00106 cend() const
00107 { return const_iterator(&_M_instance[_Nm]); }
00108
00109 const_reverse_iterator
00110 crbegin() const
00111 { return const_reverse_iterator(end()); }
00112
00113 const_reverse_iterator
00114 crend() const
00115 { return const_reverse_iterator(begin()); }
00116 #endif
00117
00118
00119 size_type
00120 size() const { return _Nm; }
00121
00122 size_type
00123 max_size() const { return _Nm; }
00124
00125 bool
00126 empty() const { return size() == 0; }
00127
00128
00129 reference
00130 operator[](size_type __n)
00131 { return _M_instance[__n]; }
00132
00133 const_reference
00134 operator[](size_type __n) const
00135 { return _M_instance[__n]; }
00136
00137 reference
00138 at(size_type __n)
00139 {
00140 if (__builtin_expect(__n >= _Nm, false))
00141 std::__throw_out_of_range(__N("array::at"));
00142 return _M_instance[__n];
00143 }
00144
00145 const_reference
00146 at(size_type __n) const
00147 {
00148 if (__builtin_expect(__n >= _Nm, false))
00149 std::__throw_out_of_range(__N("array::at"));
00150 return _M_instance[__n];
00151 }
00152
00153 reference
00154 front()
00155 { return *begin(); }
00156
00157 const_reference
00158 front() const
00159 { return *begin(); }
00160
00161 reference
00162 back()
00163 { return _Nm ? *(end() - 1) : *end(); }
00164
00165 const_reference
00166 back() const
00167 { return _Nm ? *(end() - 1) : *end(); }
00168
00169 _Tp*
00170 data()
00171 { return &_M_instance[0]; }
00172
00173 const _Tp*
00174 data() const
00175 { return &_M_instance[0]; }
00176 };
00177
00178
00179 template<typename _Tp, std::size_t _Nm>
00180 inline bool
00181 operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00182 { return std::equal(__one.begin(), __one.end(), __two.begin()); }
00183
00184 template<typename _Tp, std::size_t _Nm>
00185 inline bool
00186 operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00187 { return !(__one == __two); }
00188
00189 template<typename _Tp, std::size_t _Nm>
00190 inline bool
00191 operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
00192 {
00193 return std::lexicographical_compare(__a.begin(), __a.end(),
00194 __b.begin(), __b.end());
00195 }
00196
00197 template<typename _Tp, std::size_t _Nm>
00198 inline bool
00199 operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00200 { return __two < __one; }
00201
00202 template<typename _Tp, std::size_t _Nm>
00203 inline bool
00204 operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00205 { return !(__one > __two); }
00206
00207 template<typename _Tp, std::size_t _Nm>
00208 inline bool
00209 operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
00210 { return !(__one < __two); }
00211
00212
00213 template<typename _Tp, std::size_t _Nm>
00214 inline void
00215 swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
00216 { std::swap_ranges(__one.begin(), __one.end(), __two.begin()); }
00217
00218
00219
00220
00221 template<typename _Tp>
00222 class tuple_size;
00223
00224
00225 template<int _Int, typename _Tp>
00226 class tuple_element;
00227
00228 template<typename _Tp, std::size_t _Nm>
00229 struct tuple_size<array<_Tp, _Nm> >
00230 { static const int value = _Nm; };
00231
00232 template<typename _Tp, std::size_t _Nm>
00233 const int tuple_size<array<_Tp, _Nm> >::value;
00234
00235 template<int _Int, typename _Tp, std::size_t _Nm>
00236 struct tuple_element<_Int, array<_Tp, _Nm> >
00237 { typedef _Tp type; };
00238
00239 template<int _Int, typename _Tp, std::size_t _Nm>
00240 inline _Tp&
00241 get(array<_Tp, _Nm>& __arr)
00242 { return __arr[_Int]; }
00243
00244 template<int _Int, typename _Tp, std::size_t _Nm>
00245 inline const _Tp&
00246 get(const array<_Tp, _Nm>& __arr)
00247 { return __arr[_Int]; }
00248
00249 _GLIBCXX_END_NAMESPACE_TR1
00250 }