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 // <memory>
10 
11 // default_delete
12 
13 // Test that default_delete<T[]> has a working default constructor
14 
15 #include <memory>
16 #include <cassert>
17 
18 #include "test_macros.h"
19 #include "unique_ptr_test_helper.h"
20 
test()21 TEST_CONSTEXPR_CXX23 bool test() {
22   std::default_delete<A[]> d;
23   A* p = new A[3];
24   if (!TEST_IS_CONSTANT_EVALUATED)
25     assert(A::count == 3);
26 
27   d(p);
28 
29   if (!TEST_IS_CONSTANT_EVALUATED)
30     assert(A::count == 0);
31 
32   return true;
33 }
34 
main(int,char **)35 int main(int, char**) {
36   test();
37 #if TEST_STD_VER >= 23
38   static_assert(test());
39 #endif
40 
41   return 0;
42 }
43