Skip to content
This repository was archived by the owner on Jul 22, 2026. It is now read-only.
This repository was archived by the owner on Jul 22, 2026. It is now read-only.

Ownership & move-only Graph #225

Description

@allnes

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
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions