brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 94cc9d9 Raw
40 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// UNSUPPORTED: c++0310 11// <functional>12 13//  Hashing a struct w/o a defined hash should *not* fail, but it should14// create a type that is not constructible and not callable.15// See also: https://cplusplus.github.io/LWG/lwg-defects.html#254316 17#include <functional>18#include <cassert>19#include <type_traits>20 21#include "test_macros.h"22 23struct X {};24 25int main(int, char**)26{27    using H = std::hash<X>;28    static_assert(!std::is_default_constructible<H>::value, "");29    static_assert(!std::is_copy_constructible<H>::value, "");30    static_assert(!std::is_move_constructible<H>::value, "");31    static_assert(!std::is_copy_assignable<H>::value, "");32    static_assert(!std::is_move_assignable<H>::value, "");33#if TEST_STD_VER > 1434    static_assert(!std::is_invocable<H, X&>::value, "");35    static_assert(!std::is_invocable<H, X const&>::value, "");36#endif37 38  return 0;39}40