2010-05-12 03:42:16 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-12 05:36:01 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
2010-11-17 06:09:02 +08:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <functional>
|
|
|
|
|
|
|
|
// template <class T>
|
|
|
|
// struct hash
|
|
|
|
// : public unary_function<T, size_t>
|
|
|
|
// {
|
|
|
|
// size_t operator()(T val) const;
|
|
|
|
// };
|
|
|
|
|
|
|
|
#include <system_error>
|
|
|
|
#include <cassert>
|
|
|
|
#include <type_traits>
|
|
|
|
|
2016-06-15 09:42:35 +08:00
|
|
|
#include "test_macros.h"
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
void
|
|
|
|
test(int i)
|
|
|
|
{
|
|
|
|
typedef std::error_code T;
|
|
|
|
typedef std::hash<T> H;
|
2015-01-08 05:53:23 +08:00
|
|
|
static_assert((std::is_same<H::argument_type, T>::value), "" );
|
|
|
|
static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
|
2010-05-12 03:42:16 +08:00
|
|
|
H h;
|
|
|
|
T ec(i, std::system_category());
|
2016-06-15 09:42:35 +08:00
|
|
|
const std::size_t result = h(ec);
|
|
|
|
LIBCPP_ASSERT(result == i);
|
|
|
|
((void)result); // Prevent unused warning
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
test(0);
|
|
|
|
test(2);
|
|
|
|
test(10);
|
|
|
|
}
|