Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/tr1/test/test_hash.cpp @ 44

Last change on this file since 44 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.8 KB
Line 
1//  (C) Copyright John Maddock 2005.
2//  Use, modification and distribution are subject to the
3//  Boost Software License, Version 1.0. (See accompanying file
4//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#ifdef TEST_STD_HEADERS
7#include <functional>
8#else
9#include <boost/tr1/functional.hpp>
10#endif
11
12#include <string>
13#include <boost/static_assert.hpp>
14#include <boost/type_traits/is_same.hpp>
15#include <boost/type_traits/is_base_of.hpp>
16#include "verify_return.hpp"
17
18template <class T>
19void check_hash(T t)
20{
21   typedef std::tr1::hash<T> hash_type;
22   typedef typename hash_type::argument_type arg_type;
23   typedef typename hash_type::result_type result_type;
24   BOOST_STATIC_ASSERT((::boost::is_same<result_type, std::size_t>::value));
25   BOOST_STATIC_ASSERT((::boost::is_same<arg_type, T>::value));
26   BOOST_STATIC_ASSERT((::boost::is_base_of<std::unary_function<arg_type, result_type>, hash_type>::value));
27
28   hash_type h;
29   const hash_type& ch = h;
30
31   verify_return_type(ch(t), std::size_t(0));
32}
33
34class UDT;
35
36int main()
37{
38   check_hash(0);
39   check_hash(0u);
40   check_hash(0L);
41   check_hash(0uL);
42   check_hash(static_cast<short>(0));
43   check_hash(static_cast<unsigned short>(0));
44   check_hash(static_cast<signed char>(0));
45   check_hash(static_cast<unsigned char>(0));
46   check_hash(static_cast<char>(0));
47   check_hash(static_cast<wchar_t>(0));
48   check_hash(static_cast<bool>(0));
49   check_hash(static_cast<float>(0));
50   check_hash(static_cast<double>(0));
51   check_hash(static_cast<long double>(0));
52   check_hash(std::string(""));
53   check_hash(std::wstring(L""));
54   check_hash(static_cast<UDT*>(0));
55   check_hash(static_cast<const UDT*>(0));
56   check_hash(static_cast<volatile UDT*>(0));
57   check_hash(static_cast<const volatile UDT*>(0));
58   return 0;
59}
60
Note: See TracBrowser for help on using the repository browser.