| 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 "test_macros.h" |
| 26 |
#include "test_convertible.h" |
| 27 |
|
| 28 |
#ifdef __cpp_impl_destroying_delete |
| 29 |
# ifndef __cpp_lib_destroying_delete |
| 30 |
# error "Expected __cpp_lib_destroying_delete to be defined" |
| 31 |
# elif __cpp_lib_destroying_delete < 201806L |
| 32 |
# error "Unexpected value of __cpp_lib_destroying_delete" |
| 33 |
# endif |
| 34 |
#else |
| 35 |
# ifdef __cpp_lib_destroying_delete |
| 36 |
# error "__cpp_lib_destroying_delete should not be defined unless the compiler supports it" |
| 37 |
# endif |
| 38 |
#endif |
| 39 |
|
| 40 |
constexpr bool test_constexpr(std::destroying_delete_t) { |
| 41 |
return true; |
| 42 |
} |
| 43 |
|
| 44 |
int main(int, char**) { |
| 45 |
static_assert(std::is_default_constructible<std::destroying_delete_t>::value, ""); |
| 46 |
static_assert(!test_convertible<std::destroying_delete_t>(), ""); |
| 47 |
constexpr std::destroying_delete_t dd{}; |
| 48 |
static_assert(&dd != &std::destroying_delete, ""); |
| 49 |
static_assert(test_constexpr(std::destroying_delete), ""); |
| 50 |
return 0; |
| 51 |
} |