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 <type_traits>
23 
24 #include "min_allocator.h"
25 
26 int main(int, char**)
27 {
28     {
29     typedef std::vector<bool> T;
30     typedef std::hash<T> H;
31     static_assert((std::is_same<H::argument_type, T>::value), "" );
32     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
33     ASSERT_NOEXCEPT(H()(T()));
34 
35     bool ba[] = {true, false, true, true, false};
36     T vb(std::begin(ba), std::end(ba));
37     H h;
38     assert(h(vb) != 0);
39     }
40 #if TEST_STD_VER >= 11
41     {
42     typedef std::vector<bool, min_allocator<bool>> T;
43     typedef std::hash<T> H;
44     static_assert((std::is_same<H::argument_type, T>::value), "" );
45     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
46     ASSERT_NOEXCEPT(H()(T()));
47     bool ba[] = {true, false, true, true, false};
48     T vb(std::begin(ba), std::end(ba));
49     H h;
50     assert(h(vb) != 0);
51     }
52 #endif
53 
54   return 0;
55 }
56