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