#include #include #include #include using namespace std; #define T printf("%s [%d]\n", __PRETTY_FUNCTION__, val) struct foo { foo(int x) : val(x) { T; } ~foo() { T; } void print() const { cout << "foo{" << val << "}\n"; } int val; }; void print(shared_ptr x) { x->print(); } int main() { shared_ptr x(new foo(5)); print(x); if (x) x->print(); //cout << *x << endl; { auto g = x; print(g); } print(x); }