brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 2e407ad Raw
51 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <functional>10 11// template <class T>12// struct hash13// {14//     size_t operator()(T val) const;15// };16 17#include <bitset>18#include <cassert>19#include <type_traits>20 21#include "test_macros.h"22 23template <std::size_t N>24void25test()26{27    typedef std::bitset<N> T;28    typedef std::hash<T> H;29#if TEST_STD_VER <= 1430    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#endif33    ASSERT_NOEXCEPT(H()(T()));34 35    H h;36    T bs(static_cast<unsigned long long>(N));37    const std::size_t result = h(bs);38    LIBCPP_ASSERT(result == N);39    ((void)result); // Prevent unused warning40}41 42int main(int, char**)43{44    test<0>();45    test<10>();46    test<100>();47    test<1000>();48 49  return 0;50}51