// Copyright 2001 Karl Einar Nelson #include #include #ifdef SIGC_CXX_NAMESPACES using namespace std; using namespace SigC; #endif class Foo : public Object { public: static bool alive; Foo() { cout << "Foo()" <> test 1 (containment)" < f=manage(new Foo()); fail|=!Foo::alive; } fail|=Foo::alive; cout << "\n>> test 2 (extend)" < f2; { Ptr f=manage(new Foo()); f2=f; fail|=!Foo::alive; } cout << "(extend)" << endl; fail|=!Foo::alive; } fail|=Foo::alive; cout << "\n>> test 3 (destruction)" < f=manage(new Foo()); cout << (Foo*)f << endl; delete f; fail|=Foo::alive; cout << (Foo*)f << endl; } fail|=Foo::alive; cout << "\n>> test 4 (self assign)" < f=manage(new Foo()); f=f; fail|=!Foo::alive; cout << (Foo*)f << endl; } fail|=Foo::alive; // This is a compile-time test { Ptr f = manage(new Foo()); } return fail; }