-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Please make Graph move-only and avoid sharing node ownership. Copying a graph is ambiguous and expensive; move-only makes lifetime explicit and prevents accidental deep/shallow copies. Also, keep a single owner of layers inside Graph and pass raw pointers (or ids) for wiring to avoid refcount overhead on the hot path.
// graph.hpp
class Graph {
public:
Graph(const Graph&) = delete;
Graph& operator=(const Graph&) = delete;
Graph(Graph&&) noexcept = default;
Graph& operator=(Graph&&) noexcept = default;
~Graph() = default;
// ...
};
// preferred API inside Graph
Layer* addLayer(std::unique_ptr<Layer> L); // returns non-owning handle for connections
It's avoids atomic refcount churn from shared_ptr, eliminates hidden cycles, and makes lifetime rules crystal clear.
Metadata
Metadata
Assignees
Labels
No labels