mirror of
https://github.com/boostorg/array.git
synced 2025-06-26 12:31:41 +02:00
Compare commits
28 Commits
svn-branch
...
boost-1.52
Author | SHA1 | Date | |
---|---|---|---|
3871bae20b | |||
ba1a2437cf | |||
3db6930a22 | |||
859fb5aa97 | |||
5a97de6f2e | |||
eea368fadf | |||
26edbea113 | |||
9644ee6662 | |||
a603bffc48 | |||
0c8902e8c2 | |||
88868ba0df | |||
99631823f6 | |||
5661b8cd63 | |||
86b069ad0e | |||
3d20bb1310 | |||
e7122b3f20 | |||
4dd2cf1b64 | |||
2e88dc228d | |||
0a4d7e81ef | |||
96d4c5f737 | |||
5a23b06a83 | |||
e85feee293 | |||
b6522b3f60 | |||
3044ab376c | |||
69188c998f | |||
4c5212f5e4 | |||
276cd991f3 | |||
1f8298fb08 |
@ -70,6 +70,11 @@
|
|||||||
Technical Report, which will extend the C++ Standard (see
|
Technical Report, which will extend the C++ Standard (see
|
||||||
<ulink url="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
|
<ulink url="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
|
||||||
|
|
||||||
|
<para>Update: <code>std::array</code> is (as of C++11) part of the C++ standard.
|
||||||
|
The differences between <code>boost::array</code> and <code>std::array</code> are minimal.
|
||||||
|
If you are using C++11, you should consider using <code>std::array</code> instead of <code>boost::array</code>.
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>Class <code><classname>array</classname></code> fulfills most
|
<para>Class <code><classname>array</classname></code> fulfills most
|
||||||
but not all of the requirements of "reversible containers" (see
|
but not all of the requirements of "reversible containers" (see
|
||||||
Section 23.1, [lib.container.requirements] of the C++
|
Section 23.1, [lib.container.requirements] of the C++
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* accompanying file LICENSE_1_0.txt or copy at
|
* accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*
|
*
|
||||||
|
* 14 Apr 2012 - (mtc) Added support for boost::hash
|
||||||
* 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility.
|
* 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility.
|
||||||
* 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group.
|
* 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group.
|
||||||
* See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
|
* See <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
|
||||||
@ -46,6 +47,7 @@
|
|||||||
// Handles broken standard libraries better than <iterator>
|
// Handles broken standard libraries better than <iterator>
|
||||||
#include <boost/detail/iterator.hpp>
|
#include <boost/detail/iterator.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
|
#include <boost/functional/hash_fwd.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
// FIXES for broken compilers
|
// FIXES for broken compilers
|
||||||
@ -427,6 +429,13 @@ namespace boost {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
std::size_t hash_value(const array<T,N>& arr)
|
||||||
|
{
|
||||||
|
return boost::hash_range(arr.begin(), arr.end());
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace boost */
|
} /* namespace boost */
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,4 +12,5 @@ test-suite array :
|
|||||||
[ run array4.cpp ]
|
[ run array4.cpp ]
|
||||||
[ run array5.cpp ]
|
[ run array5.cpp ]
|
||||||
[ run array6.cpp ]
|
[ run array6.cpp ]
|
||||||
|
[ run array_hash.cpp ]
|
||||||
;
|
;
|
||||||
|
49
test/array_hash.cpp
Normal file
49
test/array_hash.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* tests for using boost::hash with boost::array
|
||||||
|
* (C) Copyright Marshall Clow 2012
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
* accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <boost/functional/hash.hpp>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
unsigned int failed_tests = 0;
|
||||||
|
|
||||||
|
void fail_test( const char * reason ) {
|
||||||
|
++failed_tests;
|
||||||
|
std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
template< class T >
|
||||||
|
void RunTests()
|
||||||
|
{
|
||||||
|
// std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ());
|
||||||
|
// std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ());
|
||||||
|
|
||||||
|
typedef boost::array< T, 5 > barr;
|
||||||
|
typedef T arr[5];
|
||||||
|
barr test_barr = {{ 1, 1, 2, 3, 5 }};
|
||||||
|
arr test_arr = { 1, 1, 2, 3, 5 };
|
||||||
|
|
||||||
|
std::size_t bhash = boost::hash<barr> () ( test_barr );
|
||||||
|
std::size_t ahash = boost::hash<arr> () ( test_arr );
|
||||||
|
if ( ahash != bhash )
|
||||||
|
fail_test ( "Array_hash: Hash-mismatch on " );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
RunTests< int >();
|
||||||
|
RunTests< long >();
|
||||||
|
RunTests< long double >();
|
||||||
|
|
||||||
|
return failed_tests;
|
||||||
|
}
|
||||||
|
|
Reference in New Issue
Block a user