xref: /llvm-project/libcxx/test/std/utilities/function.objects/unord.hash/non_enum.pass.cpp (revision 3f3abaf40ad5c732277e0d0be3c0e86b8ba49f34)
145b7b448SEric Fiselier //===----------------------------------------------------------------------===//
245b7b448SEric Fiselier //
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
645b7b448SEric Fiselier //
745b7b448SEric Fiselier //===----------------------------------------------------------------------===//
845b7b448SEric Fiselier 
9*3f3abaf4SArthur O'Dwyer // UNSUPPORTED: c++03
1045b7b448SEric Fiselier 
1145b7b448SEric Fiselier // <functional>
1245b7b448SEric Fiselier 
1345b7b448SEric Fiselier //  Hashing a struct w/o a defined hash should *not* fail, but it should
1445b7b448SEric Fiselier // create a type that is not constructible and not callable.
15ade32237SStephan T. Lavavej // See also: https://cplusplus.github.io/LWG/lwg-defects.html#2543
1645b7b448SEric Fiselier 
1745b7b448SEric Fiselier #include <functional>
1845b7b448SEric Fiselier #include <cassert>
1945b7b448SEric Fiselier #include <type_traits>
2045b7b448SEric Fiselier 
2145b7b448SEric Fiselier #include "test_macros.h"
2245b7b448SEric Fiselier 
2345b7b448SEric Fiselier struct X {};
2445b7b448SEric Fiselier 
main(int,char **)252df59c50SJF Bastien int main(int, char**)
2645b7b448SEric Fiselier {
2745b7b448SEric Fiselier     using H = std::hash<X>;
2845b7b448SEric Fiselier     static_assert(!std::is_default_constructible<H>::value, "");
2945b7b448SEric Fiselier     static_assert(!std::is_copy_constructible<H>::value, "");
3045b7b448SEric Fiselier     static_assert(!std::is_move_constructible<H>::value, "");
3145b7b448SEric Fiselier     static_assert(!std::is_copy_assignable<H>::value, "");
3245b7b448SEric Fiselier     static_assert(!std::is_move_assignable<H>::value, "");
3345b7b448SEric Fiselier #if TEST_STD_VER > 14
34bcde6e71SZhihao Yuan     static_assert(!std::is_invocable<H, X&>::value, "");
35bcde6e71SZhihao Yuan     static_assert(!std::is_invocable<H, X const&>::value, "");
3645b7b448SEric Fiselier #endif
372df59c50SJF Bastien 
382df59c50SJF Bastien   return 0;
3945b7b448SEric Fiselier }
40