#include #include #include #include #include #include using namespace std; template struct leaking { union { T data; }; leaking() { new(&data) T(); } template leaking(A&&... args) { new(&data) T(std::forward(args)...); } template leaking(std::initializer_list inli) { new(&data) T(inli); } ~leaking() { // leak } T& get() { return data; } explicit operator T&() { return data; } auto operator ->() { return &data; } }; struct hello { static int dtor; ~hello() { dtor += 1; } }; int hello::dtor = 0; int main() { { leaking vec; } assert(hello::dtor == 0); { hello vec; } assert(hello::dtor == 1); system("pause"); return 0; }