Skip to content
Welcome to the new CppUtils documentation!

Proxy view over a named branch of a MeshNodePtr, holding an RAII lock.

Template parameterDescription
IsConsttrue for read-only shared access (ConstBranch), false for mutable unique access (MutableBranch).
using CppUtils::Container::MeshNodePtr<Key, Value, Policy>::Branch<IsConst>::VectorAccessor = std::conditional_t<IsConst, Thread::ReadOnlyAccessor<std::vector<Link>>, Thread::Accessor<std::vector<Link>, Thread::SharedMutex>>;
constexpr Branch::Branch() = default;

Constructs an empty, unbound branch proxy.

constexpr Branch::Branch(MeshNodePtr parent, Key key, SafeShared<std::vector<Link>> branchLinks, VectorAccessor vectorAccessor);

Constructs a branch proxy bound to a parent node, key, and link vector accessor.

[[nodiscard]] constexpr auto Branch::size() const noexcept -> std::size_t;

Returns the number of links currently stored on this branch.

[[nodiscard]] constexpr auto Branch::empty() const noexcept -> bool;

Checks whether this branch has no links.

[[nodiscard]] constexpr auto Branch::contains(const MeshNodePtr& node) const -> bool;

Checks whether node is linked on this branch.

ParameterDescription
nodeTarget node to search for.

Returns: true if node is present on this branch.

void Branch::clear();

Detaches all target nodes from this branch.

[[nodiscard]] constexpr auto Branch::operator[](std::size_t index) const -> std::expected<MeshNodePtr, std::string_view>;

Retrieves the target node at index, resolving via Policy if unloaded.

ParameterDescription
indexPosition in the branch.

Returns: The target MeshNodePtr on success, or an error message if invalid/out of bounds/expired.

const MeshNodePtr& Branch::operator>>(const MeshNodePtr& other);

Creates a link from this branch to other.

ParameterDescription
otherTarget child node to attach.

Returns: Reference to other, for chained linking.

ParameterDescription
std::logic_errorif the parent node is not connected to any root.
Branch<false>&& Branch::operator>>(Branch<false>&& other);

Creates a link from this branch to the parent node of other.

ParameterDescription
otherTarget branch whose parent node is attached.

Returns: Rvalue reference to other for chained branch linking.

void Branch::operator-(const MeshNodePtr& other);

Detaches a specific target node other from this branch.

ParameterDescription
otherTarget node to disconnect.
template <bool OtherIsConst>
void Branch::operator&(const Branch<OtherIsConst>& other);

Creates reciprocal bidirectional links between this branch and other.

ParameterDescription
otherTarget branch to link with.
template <bool OtherIsConst>
void Branch::operator/(const Branch<OtherIsConst>& other);

Detaches reciprocal bidirectional links between this branch and other.

ParameterDescription
otherTarget branch to detach from.
[[nodiscard]] constexpr auto Branch::front() const -> std::expected<MeshNodePtr, std::string_view>;

Returns the first node on this branch, or an error if empty/expired.

[[nodiscard]] constexpr auto Branch::back() const -> std::expected<MeshNodePtr, std::string_view>;

Returns the last node on this branch, or an error if empty/expired.

[[nodiscard]] constexpr auto Branch::begin() const [[clang::lifetimebound, msvc::lifetimebound]];

Returns an iterator to the first link on this branch.

[[nodiscard]] constexpr auto Branch::end() const [[clang::lifetimebound, msvc::lifetimebound]];

Returns a sentinel iterator past the last link on this branch.