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 #include <bitset> 20 #include <cassert> 21 #include <type_traits> 22 23 #include "test_macros.h" 24 25 template <std::size_t N> 26 void test()27test() 28 { 29 typedef std::bitset<N> T; 30 typedef std::hash<T> H; 31 static_assert((std::is_same<typename H::argument_type, T>::value), "" ); 32 static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); 33 H h; 34 T bs(static_cast<unsigned long long>(N)); 35 const std::size_t result = h(bs); 36 LIBCPP_ASSERT(result == N); 37 ((void)result); // Prevent unused warning 38 } 39 main()40int main() 41 { 42 test<0>(); 43 test<10>(); 44 test<100>(); 45 test<1000>(); 46 } 47