1 | /* tests for using boost::hash with boost::array |
2 | * (C) Copyright Marshall Clow 2012 |
3 | * Distributed under the Boost Software License, Version 1.0. (See |
4 | * accompanying file LICENSE_1_0.txt or copy at |
5 | * http://www.boost.org/LICENSE_1_0.txt) |
6 | */ |
7 | |
8 | #include <string> |
9 | #include <iostream> |
10 | #include <boost/array.hpp> |
11 | #include <algorithm> |
12 | #include <boost/functional/hash.hpp> |
13 | |
14 | #include <boost/core/lightweight_test_trait.hpp> |
15 | |
16 | namespace { |
17 | |
18 | template< class T > |
19 | void RunTests() |
20 | { |
21 | // std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ()); |
22 | // std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ()); |
23 | |
24 | typedef boost::array< T, 5 > barr; |
25 | typedef T arr[5]; |
26 | barr test_barr = {{ 1, 1, 2, 3, 5 }}; |
27 | arr test_arr = { 1, 1, 2, 3, 5 }; |
28 | |
29 | std::size_t bhash = boost::hash<barr> () ( test_barr ); |
30 | std::size_t ahash = boost::hash<arr> () ( test_arr ); |
31 | BOOST_TEST ( ahash == bhash ); |
32 | } |
33 | |
34 | } |
35 | |
36 | int main() |
37 | { |
38 | RunTests< int >(); |
39 | RunTests< long >(); |
40 | RunTests< long double >(); |
41 | |
42 | return boost::report_errors(); |
43 | } |
44 | |
45 | |