//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // struct hash // : public unary_function // { // size_t operator()(T val) const; // }; // Not very portable #include #include #include #include #include "test_macros.h" template void test() { typedef std::hash H; static_assert((std::is_same::value), "" ); static_assert((std::is_same::value), "" ); ASSERT_NOEXCEPT(H()(T())); H h; typedef typename std::remove_pointer::type type; type i; type j; assert(h(&i) != h(&j)); } // can't hash nullptr_t until C++17 void test_nullptr() { #if TEST_STD_VER > 14 typedef std::nullptr_t T; typedef std::hash H; static_assert((std::is_same::value), "" ); static_assert((std::is_same::value), "" ); ASSERT_NOEXCEPT(H()(T())); #endif } int main() { test(); test_nullptr(); }