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