1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <functional>
11
12 // template <class T>
13 // struct hash
14 // : public unary_function<T, size_t>
15 // {
16 // size_t operator()(T val) const;
17 // };
18
19 // Not very portable
20
21 #include <vector>
22 #include <cassert>
23 #include <type_traits>
24
25 #include "min_allocator.h"
26
main()27 int main()
28 {
29 {
30 typedef std::vector<bool> T;
31 typedef std::hash<T> H;
32 static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
33 H>::value), "");
34 bool ba[] = {true, false, true, true, false};
35 T vb(std::begin(ba), std::end(ba));
36 H h;
37 assert(h(vb) != 0);
38 }
39 #if __cplusplus >= 201103L
40 {
41 typedef std::vector<bool, min_allocator<bool>> T;
42 typedef std::hash<T> H;
43 static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
44 H>::value), "");
45 bool ba[] = {true, false, true, true, false};
46 T vb(std::begin(ba), std::end(ba));
47 H h;
48 assert(h(vb) != 0);
49 }
50 #endif
51 }
52