1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // struct destroying_delete_t {
10 // explicit destroying_delete_t() = default;
12 // inline constexpr destroying_delete_t destroying_delete{};
14 // UNSUPPORTED: c++03, c++11, c++14, c++17
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.
19 // Other tests will check the language side of things -- but those are
20 // limited to newer compilers.
25 #include <type_traits>
27 #include "test_macros.h"
28 #include "test_convertible.h"
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"
37 # ifdef __cpp_lib_destroying_delete
38 # error "__cpp_lib_destroying_delete should not be defined unless the compiler supports it"
42 constexpr bool test_constexpr(std::destroying_delete_t
) {
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
), "");