[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / utilities / template.bitset / bitset.hash / bitset.pass.cpp
blobdfac9d94af7c72c36b4909b1be2e744714e4b200
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <functional>
11 // template <class T>
12 // struct hash
13 // : public unary_function<T, size_t>
14 // {
15 // size_t operator()(T val) const;
16 // };
18 #include <bitset>
19 #include <cassert>
20 #include <type_traits>
22 #include "test_macros.h"
24 template <std::size_t N>
25 void
26 test()
28 typedef std::bitset<N> T;
29 typedef std::hash<T> H;
30 static_assert((std::is_same<typename H::argument_type, T>::value), "" );
31 static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
32 ASSERT_NOEXCEPT(H()(T()));
34 H h;
35 T bs(static_cast<unsigned long long>(N));
36 const std::size_t result = h(bs);
37 LIBCPP_ASSERT(result == N);
38 ((void)result); // Prevent unused warning
41 int main(int, char**)
43 test<0>();
44 test<10>();
45 test<100>();
46 test<1000>();
48 return 0;