1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // test placement new 11 12 #include <new> 13 #include <cassert> 14 15 int A_constructed = 0; 16 17 struct A 18 { AA19 A() {++A_constructed;} ~AA20 ~A() {--A_constructed;} 21 }; 22 main()23int main() 24 { 25 char buf[sizeof(A)]; 26 27 A* ap = new(buf) A; 28 assert((char*)ap == buf); 29 assert(A_constructed == 1); 30 } 31