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