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