From f47e5174e4cbb891a886b06395da65cc8af79640 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 30 May 2024 12:51:13 -0700 Subject: [PATCH] disambiguate set(0) see https://github.com/lf-lang/lingua-franca/issues/2280 --- include/reactor-cpp/port.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/reactor-cpp/port.hh b/include/reactor-cpp/port.hh index 6fe01494..960c6517 100644 --- a/include/reactor-cpp/port.hh +++ b/include/reactor-cpp/port.hh @@ -133,8 +133,12 @@ public: void set(MutableValuePtr&& value_ptr) { set(ImmutableValuePtr(std::forward>(value_ptr))); } void set(const T& value) { set(make_immutable_value(value)); } void set(T&& value) { set(make_immutable_value(std::forward(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 >> void set(V) = delete; + void startup() final {} void shutdown() final {}