Skip to content

fix: typo Slop->Slot and mark Signal::subscribe() [[nodiscard]] - #1199

Open
webzuweb wants to merge 1 commit into
BehaviorTree:masterfrom
webzuweb:fix/signal-typo-nodiscard
Open

fix: typo Slop->Slot and mark Signal::subscribe() [[nodiscard]]#1199
webzuweb wants to merge 1 commit into
BehaviorTree:masterfrom
webzuweb:fix/signal-typo-nodiscard

Conversation

@webzuweb

Copy link
Copy Markdown

Fixes #1159.

Two minimal changes to include/behaviortree_cpp/utils/signal.h:

  1. Doc-comment typo: "Signal/Slop implementation" -> "Signal/Slot implementation".
  2. Mark Signal::subscribe() as [[nodiscard]].

Rationale for the [[nodiscard]]: subscribe() returns a Subscriber (shared_ptr<CallableFunction>) that is the only strong reference keeping the subscription alive — subscribers_ stores weak_ptrs. If a caller discards the return value, the refcount drops to zero immediately, the weak_ptr expires, and the subscription is silently dropped before it can ever fire. [[nodiscard]] turns that silent footgun into a compile-time warning.

Verified locally: g++ -std=c++17 -Wall -Wextra -Werror on a small TU that includes the header and keeps the return value (no warnings; runs clean).

- Fix doc comment "Signal/Slop implementation" -> "Signal/Slot implementation"
- Mark subscribe() [[nodiscard]]: the returned shared_ptr is the only
  strong reference keeping the subscription alive (subscribers_ stores
  weak_ptrs), so discarding it silently drops the subscription before it
  can ever fire.

Closes BehaviorTree#1159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minor: typo "Slop" -> "Slot" and missing [[nodiscard]] on Signal::subscribe()

1 participant