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 int main() 26 { 27 typedef std::vector<bool> T; 28 typedef std::hash<T> H; 29 static_assert((std::is_base_of<std::unary_function<T, std::size_t>, 30 H>::value), ""); 31 bool ba[] = {true, false, true, true, false}; 32 T vb(std::begin(ba), std::end(ba)); 33 H h; 34 assert(h(vb) != 0); 35 } 36