1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <functional>
10 
11 // template <class T>
12 // struct hash
13 //     : public unary_function<T, size_t>
14 // {
15 //     size_t operator()(T val) const;
16 // };
17 
18 // Not very portable
19 
20 #include <vector>
21 #include <cassert>
22 #include <iterator>
23 #include <type_traits>
24 
25 #include "test_macros.h"
26 #include "min_allocator.h"
27 
28 int main(int, char**)
29 {
30     {
31     typedef std::vector<bool> T;
32     typedef std::hash<T> H;
33     static_assert((std::is_same<H::argument_type, T>::value), "" );
34     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
35     ASSERT_NOEXCEPT(H()(T()));
36 
37     bool ba[] = {true, false, true, true, false};
38     T vb(std::begin(ba), std::end(ba));
39     H h;
40     assert(h(vb) != 0);
41     }
42 #if TEST_STD_VER >= 11
43     {
44     typedef std::vector<bool, min_allocator<bool>> T;
45     typedef std::hash<T> H;
46     static_assert((std::is_same<H::argument_type, T>::value), "" );
47     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
48     ASSERT_NOEXCEPT(H()(T()));
49     bool ba[] = {true, false, true, true, false};
50     T vb(std::begin(ba), std::end(ba));
51     H h;
52     assert(h(vb) != 0);
53     }
54 #endif
55 
56   return 0;
57 }
58