Untitled
unknown
plain_text
19 days ago
755 B
7
Indexable
class ResourcePool { struct Resource { std::string name; std::vector<std::shared_ptr<Resource>> dependencies; Resource(const std::string& n) : name(n) {} }; std::vector<std::shared_ptr<Resource>> resources; public: void addDependentResources(const std::string& name1, const std::string& name2) { auto res1 = std::make_shared<Resource>(name1); auto res2 = std::make_shared<Resource>(name2); res1->dependencies.push_back(res2); res2->dependencies.push_back(res1); resources.push_back(res1); resources.push_back(res2); } void clear() { resources.clear(); // This won't free all memory due to circular references } };
Editor is loading...
Leave a Comment