brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 1311933 Raw
47 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// <system_error>10//11// template <>12// struct hash<error_code>;13 14#include <system_error>15#include <cassert>16#include <cstddef>17#include <functional>18#include <type_traits>19 20#include "test_macros.h"21 22void23test(int i)24{25    typedef std::error_code T;26    typedef std::hash<T> H;27#if TEST_STD_VER <= 1428    static_assert((std::is_same<H::argument_type, T>::value), "" );29    static_assert((std::is_same<H::result_type, std::size_t>::value), "" );30#endif31    ASSERT_NOEXCEPT(H()(T()));32    H h;33    T ec(i, std::system_category());34    const std::size_t result = h(ec);35    LIBCPP_ASSERT(result == static_cast<std::size_t>(i));36    ((void)result); // Prevent unused warning37}38 39int main(int, char**)40{41    test(0);42    test(2);43    test(10);44 45  return 0;46}47