Skip to content

Instantly share code, notes, and snippets.

View shibd's full-sized avatar
🏠
Working from home

Baodi Shi shibd

🏠
Working from home
View GitHub Profile
@shibd
shibd / cyclic_references.cc
Created September 2, 2022 08:29 — forked from BewareMyPower/cyclic_references.cc
c++ shared_ptr cyclic references by capturing shared_from_this()
#include <atomic>
#include <functional>
#include <iostream>
#include <memory>
using namespace std;
static std::atomic_int idGenerator{0};
struct Object {
int id;