non_enum.pass.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03, c++11
  10. // <functional>
  11. // Hashing a struct w/o a defined hash should *not* fail, but it should
  12. // create a type that is not constructible and not callable.
  13. // See also: https://cplusplus.github.io/LWG/lwg-defects.html#2543
  14. #include <functional>
  15. #include <cassert>
  16. #include <type_traits>
  17. #include "test_macros.h"
  18. struct X {};
  19. int main()
  20. {
  21. using H = std::hash<X>;
  22. static_assert(!std::is_default_constructible<H>::value, "");
  23. static_assert(!std::is_copy_constructible<H>::value, "");
  24. static_assert(!std::is_move_constructible<H>::value, "");
  25. static_assert(!std::is_copy_assignable<H>::value, "");
  26. static_assert(!std::is_move_assignable<H>::value, "");
  27. #if TEST_STD_VER > 14
  28. static_assert(!std::is_callable<H(X&)>::value, "");
  29. static_assert(!std::is_callable<H(X const&)>::value, "");
  30. #endif
  31. }