// (C) Copyright John Maddock 2005. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifdef TEST_STD_HEADERS #include #else #include #endif #include #include #include #include #include "verify_return.hpp" template void check_hash(T t) { typedef std::tr1::hash hash_type; typedef typename hash_type::argument_type arg_type; typedef typename hash_type::result_type result_type; BOOST_STATIC_ASSERT((::boost::is_same::value)); BOOST_STATIC_ASSERT((::boost::is_same::value)); BOOST_STATIC_ASSERT((::boost::is_base_of, hash_type>::value)); hash_type h; const hash_type& ch = h; verify_return_type(ch(t), std::size_t(0)); } class UDT { int m_value; public: UDT(int v) : m_value(v) {} int value()const { return m_value; } }; namespace std{ namespace tr1{ template<> struct hash : public std::unary_function { typedef UDT argument_type; typedef std::size_t result_type; std::size_t operator()(const UDT& u)const { std::tr1::hash h; return h(u.value()); } }; }} int main() { check_hash(0); check_hash(0u); check_hash(0L); check_hash(0uL); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(std::string("")); check_hash(std::wstring(L"")); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(static_cast(0)); check_hash(UDT(1)); return 0; }