//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // template // struct allocator_traits // { // template // static void destroy(allocator_type& a, Ptr p); // ... // }; #include #include #include #include #include "test_macros.h" #include "incomplete_type_helper.h" template struct A { typedef T value_type; }; int b_destroy = 0; template struct B { typedef T value_type; template void destroy(U* p) { ++b_destroy; p->~U(); } }; struct A0 { static int count; ~A0() {++count;} }; int A0::count = 0; int main(int, char**) { { A0::count = 0; A a; std::aligned_storage::type a0; std::allocator_traits >::construct(a, (A0*)&a0); assert(A0::count == 0); std::allocator_traits >::destroy(a, (A0*)&a0); assert(A0::count == 1); } { typedef IncompleteHolder* VT; typedef A Alloc; Alloc a; std::aligned_storage::type store; std::allocator_traits::destroy(a, (VT*)&store); } #if defined(_LIBCPP_VERSION) || TEST_STD_VER >= 11 { A0::count = 0; b_destroy = 0; B b; std::aligned_storage::type a0; std::allocator_traits >::construct(b, (A0*)&a0); assert(A0::count == 0); assert(b_destroy == 0); std::allocator_traits >::destroy(b, (A0*)&a0); assert(A0::count == 1); assert(b_destroy == 1); } #endif return 0; }