Skip to content

Commit

Permalink
disambiguate set(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnrd committed May 30, 2024
1 parent 1539b11 commit f47e517
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit f47e517

Please sign in to comment.