Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disambiguated set(0) on ports #57

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include/reactor-cpp/port.hh
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ public:
void set(MutableValuePtr<T>&& value_ptr) { set(ImmutableValuePtr<T>(std::forward<MutableValuePtr<T>>(value_ptr))); }
void set(const T& value) { set(make_immutable_value<T>(value)); }
void set(T&& value) { set(make_immutable_value<T>(std::forward<T>(value))); }
// Setting a port to nullptr is not permitted.
void set(std::nullptr_t) = delete;

// Setting a port to nullptr is not permitted. We use enable_if to only delete
// set() if it is actually called with nullptr. Without enable_if set(0) would
// be ambiguous as 0 can be implicitly casted to nullptr_t.
template <typename V, typename = std::enable_if_t<std::is_same_v<V, std::nullptr_t>>> void set(V) = delete;

void startup() final {}
void shutdown() final {}

Expand Down
Loading