//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // struct allocator_traits // { // template // static void destroy(allocator_type& a, Ptr p); // ... // }; #include #include #include #include #include "test_macros.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() { { 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); } #if 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 }