1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // : public unary_function<T, size_t>
15 // size_t operator()(T val) const;
22 #include <type_traits>
24 #include "test_macros.h"
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 ASSERT_NOEXCEPT(H()(T()));
36 std::string g1
= "1234567890";
37 std::string g2
= "1234567891";
38 T
s1(g1
.begin(), g1
.end());
39 T
s2(g2
.begin(), g2
.end());
40 assert(h(s1
) != h(s2
));
46 #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
47 test
<std::u8string
>();
49 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
50 test
<std::u16string
>();
51 test
<std::u32string
>();
52 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS