#include // for EXIT_SUCCESS #include // for std::shared_ptr, std::weak_ptr using std::shared_ptr; using std::weak_ptr; struct A { shared_ptr next; weak_ptr prev; }; int main(int argc, char **argv) { shared_ptr head(new A()); head->next = shared_ptr(new A()); head->next->prev = head; return EXIT_SUCCESS; }