Chris@16
|
1 /* The following code declares class array,
|
Chris@16
|
2 * an STL container (as wrapper) for arrays of constant size.
|
Chris@16
|
3 *
|
Chris@16
|
4 * See
|
Chris@16
|
5 * http://www.boost.org/libs/array/
|
Chris@16
|
6 * for documentation.
|
Chris@16
|
7 *
|
Chris@16
|
8 * The original author site is at: http://www.josuttis.com/
|
Chris@16
|
9 *
|
Chris@16
|
10 * (C) Copyright Nicolai M. Josuttis 2001.
|
Chris@16
|
11 *
|
Chris@16
|
12 * Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
13 * accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
14 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
15 *
|
Chris@16
|
16 * 14 Apr 2012 - (mtc) Added support for boost::hash
|
Chris@16
|
17 * 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility.
|
Chris@16
|
18 * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group.
|
Chris@16
|
19 * See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
|
Chris@16
|
20 * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow)
|
Chris@16
|
21 * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow)
|
Chris@16
|
22 * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis)
|
Chris@16
|
23 * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries.
|
Chris@16
|
24 * 05 Aug 2001 - minor update (Nico Josuttis)
|
Chris@16
|
25 * 20 Jan 2001 - STLport fix (Beman Dawes)
|
Chris@16
|
26 * 29 Sep 2000 - Initial Revision (Nico Josuttis)
|
Chris@16
|
27 *
|
Chris@16
|
28 * Jan 29, 2004
|
Chris@16
|
29 */
|
Chris@16
|
30 #ifndef BOOST_ARRAY_HPP
|
Chris@16
|
31 #define BOOST_ARRAY_HPP
|
Chris@16
|
32
|
Chris@16
|
33 #include <boost/detail/workaround.hpp>
|
Chris@16
|
34
|
Chris@16
|
35 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
Chris@16
|
36 # pragma warning(push)
|
Chris@16
|
37 # pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe
|
Chris@16
|
38 # pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated
|
Chris@16
|
39 # pragma warning(disable:4610) // warning C4610: class 'boost::array<T,N>' can never be instantiated - user defined constructor required
|
Chris@16
|
40 #endif
|
Chris@16
|
41
|
Chris@16
|
42 #include <cstddef>
|
Chris@16
|
43 #include <stdexcept>
|
Chris@16
|
44 #include <boost/assert.hpp>
|
Chris@16
|
45 #include <boost/swap.hpp>
|
Chris@16
|
46
|
Chris@16
|
47 // Handles broken standard libraries better than <iterator>
|
Chris@16
|
48 #include <boost/detail/iterator.hpp>
|
Chris@16
|
49 #include <boost/throw_exception.hpp>
|
Chris@16
|
50 #include <boost/functional/hash_fwd.hpp>
|
Chris@16
|
51 #include <algorithm>
|
Chris@16
|
52
|
Chris@16
|
53 // FIXES for broken compilers
|
Chris@16
|
54 #include <boost/config.hpp>
|
Chris@16
|
55
|
Chris@16
|
56
|
Chris@16
|
57 namespace boost {
|
Chris@16
|
58
|
Chris@16
|
59 template<class T, std::size_t N>
|
Chris@16
|
60 class array {
|
Chris@16
|
61 public:
|
Chris@16
|
62 T elems[N]; // fixed-size array of elements of type T
|
Chris@16
|
63
|
Chris@16
|
64 public:
|
Chris@16
|
65 // type definitions
|
Chris@16
|
66 typedef T value_type;
|
Chris@16
|
67 typedef T* iterator;
|
Chris@16
|
68 typedef const T* const_iterator;
|
Chris@16
|
69 typedef T& reference;
|
Chris@16
|
70 typedef const T& const_reference;
|
Chris@16
|
71 typedef std::size_t size_type;
|
Chris@16
|
72 typedef std::ptrdiff_t difference_type;
|
Chris@16
|
73
|
Chris@16
|
74 // iterator support
|
Chris@16
|
75 iterator begin() { return elems; }
|
Chris@16
|
76 const_iterator begin() const { return elems; }
|
Chris@16
|
77 const_iterator cbegin() const { return elems; }
|
Chris@16
|
78
|
Chris@16
|
79 iterator end() { return elems+N; }
|
Chris@16
|
80 const_iterator end() const { return elems+N; }
|
Chris@16
|
81 const_iterator cend() const { return elems+N; }
|
Chris@16
|
82
|
Chris@16
|
83 // reverse iterator support
|
Chris@16
|
84 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
Chris@16
|
85 typedef std::reverse_iterator<iterator> reverse_iterator;
|
Chris@16
|
86 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
Chris@16
|
87 #elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
|
Chris@16
|
88 // workaround for broken reverse_iterator in VC7
|
Chris@16
|
89 typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
|
Chris@16
|
90 reference, iterator, reference> > reverse_iterator;
|
Chris@16
|
91 typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
Chris@16
|
92 const_reference, iterator, reference> > const_reverse_iterator;
|
Chris@16
|
93 #elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
|
Chris@16
|
94 typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
|
Chris@16
|
95 value_type, reference, iterator, difference_type> reverse_iterator;
|
Chris@16
|
96 typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
|
Chris@16
|
97 value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
|
Chris@16
|
98 #else
|
Chris@16
|
99 // workaround for broken reverse_iterator implementations
|
Chris@16
|
100 typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
Chris@16
|
101 typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
|
Chris@16
|
102 #endif
|
Chris@16
|
103
|
Chris@16
|
104 reverse_iterator rbegin() { return reverse_iterator(end()); }
|
Chris@16
|
105 const_reverse_iterator rbegin() const {
|
Chris@16
|
106 return const_reverse_iterator(end());
|
Chris@16
|
107 }
|
Chris@16
|
108 const_reverse_iterator crbegin() const {
|
Chris@16
|
109 return const_reverse_iterator(end());
|
Chris@16
|
110 }
|
Chris@16
|
111
|
Chris@16
|
112 reverse_iterator rend() { return reverse_iterator(begin()); }
|
Chris@16
|
113 const_reverse_iterator rend() const {
|
Chris@16
|
114 return const_reverse_iterator(begin());
|
Chris@16
|
115 }
|
Chris@16
|
116 const_reverse_iterator crend() const {
|
Chris@16
|
117 return const_reverse_iterator(begin());
|
Chris@16
|
118 }
|
Chris@16
|
119
|
Chris@16
|
120 // operator[]
|
Chris@16
|
121 reference operator[](size_type i)
|
Chris@16
|
122 {
|
Chris@16
|
123 BOOST_ASSERT_MSG( i < N, "out of range" );
|
Chris@16
|
124 return elems[i];
|
Chris@16
|
125 }
|
Chris@16
|
126
|
Chris@16
|
127 const_reference operator[](size_type i) const
|
Chris@16
|
128 {
|
Chris@16
|
129 BOOST_ASSERT_MSG( i < N, "out of range" );
|
Chris@16
|
130 return elems[i];
|
Chris@16
|
131 }
|
Chris@16
|
132
|
Chris@16
|
133 // at() with range check
|
Chris@16
|
134 reference at(size_type i) { rangecheck(i); return elems[i]; }
|
Chris@16
|
135 const_reference at(size_type i) const { rangecheck(i); return elems[i]; }
|
Chris@16
|
136
|
Chris@16
|
137 // front() and back()
|
Chris@16
|
138 reference front()
|
Chris@16
|
139 {
|
Chris@16
|
140 return elems[0];
|
Chris@16
|
141 }
|
Chris@16
|
142
|
Chris@16
|
143 const_reference front() const
|
Chris@16
|
144 {
|
Chris@16
|
145 return elems[0];
|
Chris@16
|
146 }
|
Chris@16
|
147
|
Chris@16
|
148 reference back()
|
Chris@16
|
149 {
|
Chris@16
|
150 return elems[N-1];
|
Chris@16
|
151 }
|
Chris@16
|
152
|
Chris@16
|
153 const_reference back() const
|
Chris@16
|
154 {
|
Chris@16
|
155 return elems[N-1];
|
Chris@16
|
156 }
|
Chris@16
|
157
|
Chris@16
|
158 // size is constant
|
Chris@16
|
159 static size_type size() { return N; }
|
Chris@16
|
160 static bool empty() { return false; }
|
Chris@16
|
161 static size_type max_size() { return N; }
|
Chris@16
|
162 enum { static_size = N };
|
Chris@16
|
163
|
Chris@16
|
164 // swap (note: linear complexity)
|
Chris@16
|
165 void swap (array<T,N>& y) {
|
Chris@16
|
166 for (size_type i = 0; i < N; ++i)
|
Chris@16
|
167 boost::swap(elems[i],y.elems[i]);
|
Chris@16
|
168 }
|
Chris@16
|
169
|
Chris@16
|
170 // direct access to data (read-only)
|
Chris@16
|
171 const T* data() const { return elems; }
|
Chris@16
|
172 T* data() { return elems; }
|
Chris@16
|
173
|
Chris@16
|
174 // use array as C array (direct read/write access to data)
|
Chris@16
|
175 T* c_array() { return elems; }
|
Chris@16
|
176
|
Chris@16
|
177 // assignment with type conversion
|
Chris@16
|
178 template <typename T2>
|
Chris@16
|
179 array<T,N>& operator= (const array<T2,N>& rhs) {
|
Chris@16
|
180 std::copy(rhs.begin(),rhs.end(), begin());
|
Chris@16
|
181 return *this;
|
Chris@16
|
182 }
|
Chris@16
|
183
|
Chris@16
|
184 // assign one value to all elements
|
Chris@16
|
185 void assign (const T& value) { fill ( value ); } // A synonym for fill
|
Chris@16
|
186 void fill (const T& value)
|
Chris@16
|
187 {
|
Chris@16
|
188 std::fill_n(begin(),size(),value);
|
Chris@16
|
189 }
|
Chris@16
|
190
|
Chris@16
|
191 // check range (may be private because it is static)
|
Chris@16
|
192 static void rangecheck (size_type i) {
|
Chris@16
|
193 if (i >= size()) {
|
Chris@16
|
194 std::out_of_range e("array<>: index out of range");
|
Chris@16
|
195 boost::throw_exception(e);
|
Chris@16
|
196 }
|
Chris@16
|
197 }
|
Chris@16
|
198
|
Chris@16
|
199 };
|
Chris@16
|
200
|
Chris@16
|
201 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
Chris@16
|
202 template< class T >
|
Chris@16
|
203 class array< T, 0 > {
|
Chris@16
|
204
|
Chris@16
|
205 public:
|
Chris@16
|
206 // type definitions
|
Chris@16
|
207 typedef T value_type;
|
Chris@16
|
208 typedef T* iterator;
|
Chris@16
|
209 typedef const T* const_iterator;
|
Chris@16
|
210 typedef T& reference;
|
Chris@16
|
211 typedef const T& const_reference;
|
Chris@16
|
212 typedef std::size_t size_type;
|
Chris@16
|
213 typedef std::ptrdiff_t difference_type;
|
Chris@16
|
214
|
Chris@16
|
215 // iterator support
|
Chris@16
|
216 iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); }
|
Chris@16
|
217 const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
Chris@16
|
218 const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); }
|
Chris@16
|
219
|
Chris@16
|
220 iterator end() { return begin(); }
|
Chris@16
|
221 const_iterator end() const { return begin(); }
|
Chris@16
|
222 const_iterator cend() const { return cbegin(); }
|
Chris@16
|
223
|
Chris@16
|
224 // reverse iterator support
|
Chris@16
|
225 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
Chris@16
|
226 typedef std::reverse_iterator<iterator> reverse_iterator;
|
Chris@16
|
227 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
Chris@16
|
228 #elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310)
|
Chris@16
|
229 // workaround for broken reverse_iterator in VC7
|
Chris@16
|
230 typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, iterator,
|
Chris@16
|
231 reference, iterator, reference> > reverse_iterator;
|
Chris@16
|
232 typedef std::reverse_iterator<std::_Ptrit<value_type, difference_type, const_iterator,
|
Chris@16
|
233 const_reference, iterator, reference> > const_reverse_iterator;
|
Chris@16
|
234 #elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
|
Chris@16
|
235 typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
|
Chris@16
|
236 value_type, reference, iterator, difference_type> reverse_iterator;
|
Chris@16
|
237 typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
|
Chris@16
|
238 value_type, const_reference, const_iterator, difference_type> const_reverse_iterator;
|
Chris@16
|
239 #else
|
Chris@16
|
240 // workaround for broken reverse_iterator implementations
|
Chris@16
|
241 typedef std::reverse_iterator<iterator,T> reverse_iterator;
|
Chris@16
|
242 typedef std::reverse_iterator<const_iterator,T> const_reverse_iterator;
|
Chris@16
|
243 #endif
|
Chris@16
|
244
|
Chris@16
|
245 reverse_iterator rbegin() { return reverse_iterator(end()); }
|
Chris@16
|
246 const_reverse_iterator rbegin() const {
|
Chris@16
|
247 return const_reverse_iterator(end());
|
Chris@16
|
248 }
|
Chris@16
|
249 const_reverse_iterator crbegin() const {
|
Chris@16
|
250 return const_reverse_iterator(end());
|
Chris@16
|
251 }
|
Chris@16
|
252
|
Chris@16
|
253 reverse_iterator rend() { return reverse_iterator(begin()); }
|
Chris@16
|
254 const_reverse_iterator rend() const {
|
Chris@16
|
255 return const_reverse_iterator(begin());
|
Chris@16
|
256 }
|
Chris@16
|
257 const_reverse_iterator crend() const {
|
Chris@16
|
258 return const_reverse_iterator(begin());
|
Chris@16
|
259 }
|
Chris@16
|
260
|
Chris@16
|
261 // operator[]
|
Chris@16
|
262 reference operator[](size_type /*i*/)
|
Chris@16
|
263 {
|
Chris@16
|
264 return failed_rangecheck();
|
Chris@16
|
265 }
|
Chris@16
|
266
|
Chris@16
|
267 const_reference operator[](size_type /*i*/) const
|
Chris@16
|
268 {
|
Chris@16
|
269 return failed_rangecheck();
|
Chris@16
|
270 }
|
Chris@16
|
271
|
Chris@16
|
272 // at() with range check
|
Chris@16
|
273 reference at(size_type /*i*/) { return failed_rangecheck(); }
|
Chris@16
|
274 const_reference at(size_type /*i*/) const { return failed_rangecheck(); }
|
Chris@16
|
275
|
Chris@16
|
276 // front() and back()
|
Chris@16
|
277 reference front()
|
Chris@16
|
278 {
|
Chris@16
|
279 return failed_rangecheck();
|
Chris@16
|
280 }
|
Chris@16
|
281
|
Chris@16
|
282 const_reference front() const
|
Chris@16
|
283 {
|
Chris@16
|
284 return failed_rangecheck();
|
Chris@16
|
285 }
|
Chris@16
|
286
|
Chris@16
|
287 reference back()
|
Chris@16
|
288 {
|
Chris@16
|
289 return failed_rangecheck();
|
Chris@16
|
290 }
|
Chris@16
|
291
|
Chris@16
|
292 const_reference back() const
|
Chris@16
|
293 {
|
Chris@16
|
294 return failed_rangecheck();
|
Chris@16
|
295 }
|
Chris@16
|
296
|
Chris@16
|
297 // size is constant
|
Chris@16
|
298 static size_type size() { return 0; }
|
Chris@16
|
299 static bool empty() { return true; }
|
Chris@16
|
300 static size_type max_size() { return 0; }
|
Chris@16
|
301 enum { static_size = 0 };
|
Chris@16
|
302
|
Chris@16
|
303 void swap (array<T,0>& /*y*/) {
|
Chris@16
|
304 }
|
Chris@16
|
305
|
Chris@16
|
306 // direct access to data (read-only)
|
Chris@16
|
307 const T* data() const { return 0; }
|
Chris@16
|
308 T* data() { return 0; }
|
Chris@16
|
309
|
Chris@16
|
310 // use array as C array (direct read/write access to data)
|
Chris@16
|
311 T* c_array() { return 0; }
|
Chris@16
|
312
|
Chris@16
|
313 // assignment with type conversion
|
Chris@16
|
314 template <typename T2>
|
Chris@16
|
315 array<T,0>& operator= (const array<T2,0>& ) {
|
Chris@16
|
316 return *this;
|
Chris@16
|
317 }
|
Chris@16
|
318
|
Chris@16
|
319 // assign one value to all elements
|
Chris@16
|
320 void assign (const T& value) { fill ( value ); }
|
Chris@16
|
321 void fill (const T& ) {}
|
Chris@16
|
322
|
Chris@16
|
323 // check range (may be private because it is static)
|
Chris@16
|
324 static reference failed_rangecheck () {
|
Chris@16
|
325 std::out_of_range e("attempt to access element of an empty array");
|
Chris@16
|
326 boost::throw_exception(e);
|
Chris@16
|
327 #if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__))
|
Chris@16
|
328 //
|
Chris@16
|
329 // We need to return something here to keep
|
Chris@16
|
330 // some compilers happy: however we will never
|
Chris@16
|
331 // actually get here....
|
Chris@16
|
332 //
|
Chris@16
|
333 static T placeholder;
|
Chris@16
|
334 return placeholder;
|
Chris@16
|
335 #endif
|
Chris@16
|
336 }
|
Chris@16
|
337 };
|
Chris@16
|
338 #endif
|
Chris@16
|
339
|
Chris@16
|
340 // comparisons
|
Chris@16
|
341 template<class T, std::size_t N>
|
Chris@16
|
342 bool operator== (const array<T,N>& x, const array<T,N>& y) {
|
Chris@16
|
343 return std::equal(x.begin(), x.end(), y.begin());
|
Chris@16
|
344 }
|
Chris@16
|
345 template<class T, std::size_t N>
|
Chris@16
|
346 bool operator< (const array<T,N>& x, const array<T,N>& y) {
|
Chris@16
|
347 return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
|
Chris@16
|
348 }
|
Chris@16
|
349 template<class T, std::size_t N>
|
Chris@16
|
350 bool operator!= (const array<T,N>& x, const array<T,N>& y) {
|
Chris@16
|
351 return !(x==y);
|
Chris@16
|
352 }
|
Chris@16
|
353 template<class T, std::size_t N>
|
Chris@16
|
354 bool operator> (const array<T,N>& x, const array<T,N>& y) {
|
Chris@16
|
355 return y<x;
|
Chris@16
|
356 }
|
Chris@16
|
357 template<class T, std::size_t N>
|
Chris@16
|
358 bool operator<= (const array<T,N>& x, const array<T,N>& y) {
|
Chris@16
|
359 return !(y<x);
|
Chris@16
|
360 }
|
Chris@16
|
361 template<class T, std::size_t N>
|
Chris@16
|
362 bool operator>= (const array<T,N>& x, const array<T,N>& y) {
|
Chris@16
|
363 return !(x<y);
|
Chris@16
|
364 }
|
Chris@16
|
365
|
Chris@16
|
366 // global swap()
|
Chris@16
|
367 template<class T, std::size_t N>
|
Chris@16
|
368 inline void swap (array<T,N>& x, array<T,N>& y) {
|
Chris@16
|
369 x.swap(y);
|
Chris@16
|
370 }
|
Chris@16
|
371
|
Chris@16
|
372 #if defined(__SUNPRO_CC)
|
Chris@16
|
373 // Trac ticket #4757; the Sun Solaris compiler can't handle
|
Chris@16
|
374 // syntax like 'T(&get_c_array(boost::array<T,N>& arg))[N]'
|
Chris@16
|
375 //
|
Chris@16
|
376 // We can't just use this for all compilers, because the
|
Chris@16
|
377 // borland compilers can't handle this form.
|
Chris@16
|
378 namespace detail {
|
Chris@16
|
379 template <typename T, std::size_t N> struct c_array
|
Chris@16
|
380 {
|
Chris@16
|
381 typedef T type[N];
|
Chris@16
|
382 };
|
Chris@16
|
383 }
|
Chris@16
|
384
|
Chris@16
|
385 // Specific for boost::array: simply returns its elems data member.
|
Chris@16
|
386 template <typename T, std::size_t N>
|
Chris@16
|
387 typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg)
|
Chris@16
|
388 {
|
Chris@16
|
389 return arg.elems;
|
Chris@16
|
390 }
|
Chris@16
|
391
|
Chris@16
|
392 // Specific for boost::array: simply returns its elems data member.
|
Chris@16
|
393 template <typename T, std::size_t N>
|
Chris@16
|
394 typename const detail::c_array<T,N>::type& get_c_array(const boost::array<T,N>& arg)
|
Chris@16
|
395 {
|
Chris@16
|
396 return arg.elems;
|
Chris@16
|
397 }
|
Chris@16
|
398 #else
|
Chris@16
|
399 // Specific for boost::array: simply returns its elems data member.
|
Chris@16
|
400 template <typename T, std::size_t N>
|
Chris@16
|
401 T(&get_c_array(boost::array<T,N>& arg))[N]
|
Chris@16
|
402 {
|
Chris@16
|
403 return arg.elems;
|
Chris@16
|
404 }
|
Chris@16
|
405
|
Chris@16
|
406 // Const version.
|
Chris@16
|
407 template <typename T, std::size_t N>
|
Chris@16
|
408 const T(&get_c_array(const boost::array<T,N>& arg))[N]
|
Chris@16
|
409 {
|
Chris@16
|
410 return arg.elems;
|
Chris@16
|
411 }
|
Chris@16
|
412 #endif
|
Chris@16
|
413
|
Chris@16
|
414 #if 0
|
Chris@16
|
415 // Overload for std::array, assuming that std::array will have
|
Chris@16
|
416 // explicit conversion functions as discussed at the WG21 meeting
|
Chris@16
|
417 // in Summit, March 2009.
|
Chris@16
|
418 template <typename T, std::size_t N>
|
Chris@16
|
419 T(&get_c_array(std::array<T,N>& arg))[N]
|
Chris@16
|
420 {
|
Chris@16
|
421 return static_cast<T(&)[N]>(arg);
|
Chris@16
|
422 }
|
Chris@16
|
423
|
Chris@16
|
424 // Const version.
|
Chris@16
|
425 template <typename T, std::size_t N>
|
Chris@16
|
426 const T(&get_c_array(const std::array<T,N>& arg))[N]
|
Chris@16
|
427 {
|
Chris@16
|
428 return static_cast<T(&)[N]>(arg);
|
Chris@16
|
429 }
|
Chris@16
|
430 #endif
|
Chris@16
|
431
|
Chris@16
|
432
|
Chris@16
|
433 template<class T, std::size_t N>
|
Chris@16
|
434 std::size_t hash_value(const array<T,N>& arr)
|
Chris@16
|
435 {
|
Chris@16
|
436 return boost::hash_range(arr.begin(), arr.end());
|
Chris@16
|
437 }
|
Chris@16
|
438
|
Chris@16
|
439 } /* namespace boost */
|
Chris@16
|
440
|
Chris@16
|
441
|
Chris@16
|
442 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
Chris@16
|
443 # pragma warning(pop)
|
Chris@16
|
444 #endif
|
Chris@16
|
445
|
Chris@16
|
446 #endif /*BOOST_ARRAY_HPP*/
|