destroying_delete_t_declaration.pass.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. // struct destroying_delete_t {
  10. // explicit destroying_delete_t() = default;
  11. // };
  12. // inline constexpr destroying_delete_t destroying_delete{};
  13. // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
  14. // Test only the library parts of destroying delete in this test.
  15. // Verify that it's properly declared after C++17 and that it's constexpr.
  16. //
  17. // Other tests will check the language side of things -- but those are
  18. // limited to newer compilers.
  19. #include <new>
  20. #include <cassert>
  21. #include "test_macros.h"
  22. #include "test_convertible.h"
  23. #ifdef __cpp_impl_destroying_delete
  24. # ifndef __cpp_lib_destroying_delete
  25. # error "Expected __cpp_lib_destroying_delete to be defined"
  26. # elif __cpp_lib_destroying_delete < 201806L
  27. # error "Unexpected value of __cpp_lib_destroying_delete"
  28. # endif
  29. #else
  30. # ifdef __cpp_lib_destroying_delete
  31. # error "__cpp_lib_destroying_delete should not be defined unless the compiler supports it"
  32. # endif
  33. #endif
  34. constexpr bool test_constexpr(std::destroying_delete_t) {
  35. return true;
  36. }
  37. int main() {
  38. static_assert(std::is_default_constructible<std::destroying_delete_t>::value, "");
  39. static_assert(!test_convertible<std::destroying_delete_t>(), "");
  40. constexpr std::destroying_delete_t dd{};
  41. static_assert((dd, true), "");
  42. static_assert(&dd != &std::destroying_delete, "");
  43. static_assert(test_constexpr(std::destroying_delete), "");
  44. }