11c7fe126SMarshall Clow //===----------------------------------------------------------------------===//
21c7fe126SMarshall Clow //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61c7fe126SMarshall Clow //
71c7fe126SMarshall Clow //===----------------------------------------------------------------------===//
81c7fe126SMarshall Clow 
91c7fe126SMarshall Clow // <functional>
101c7fe126SMarshall Clow 
111c7fe126SMarshall Clow // template <class T>
121c7fe126SMarshall Clow // struct hash
131c7fe126SMarshall Clow // {
141c7fe126SMarshall Clow //     size_t operator()(T val) const;
151c7fe126SMarshall Clow // };
161c7fe126SMarshall Clow 
171c7fe126SMarshall Clow #include <system_error>
181c7fe126SMarshall Clow #include <cassert>
191c7fe126SMarshall Clow #include <type_traits>
201c7fe126SMarshall Clow 
211c7fe126SMarshall Clow #include "test_macros.h"
221c7fe126SMarshall Clow 
231c7fe126SMarshall Clow void
test(int i)24105a3061SStephan T. Lavavej test(int i)
251c7fe126SMarshall Clow {
261c7fe126SMarshall Clow     typedef std::error_condition T;
271c7fe126SMarshall Clow     typedef std::hash<T> H;
28*681cde7dSNikolas Klauser #if TEST_STD_VER <= 14
291c7fe126SMarshall Clow     static_assert((std::is_same<H::argument_type, T>::value), "" );
301c7fe126SMarshall Clow     static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
31*681cde7dSNikolas Klauser #endif
327c803385SMarshall Clow     ASSERT_NOEXCEPT(H()(T()));
331c7fe126SMarshall Clow     H h;
341c7fe126SMarshall Clow     T ec(i, std::system_category());
351c7fe126SMarshall Clow     const std::size_t result = h(ec);
36105a3061SStephan T. Lavavej     LIBCPP_ASSERT(result == static_cast<std::size_t>(i));
371c7fe126SMarshall Clow     ((void)result); // Prevent unused warning
381c7fe126SMarshall Clow }
391c7fe126SMarshall Clow 
main(int,char **)402df59c50SJF Bastien int main(int, char**)
411c7fe126SMarshall Clow {
421c7fe126SMarshall Clow     test(0);
431c7fe126SMarshall Clow     test(2);
441c7fe126SMarshall Clow     test(10);
452df59c50SJF Bastien 
462df59c50SJF Bastien   return 0;
471c7fe126SMarshall Clow }
48