| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…#1742) The two set() overloads in AnyServiceCallback and GenericServiceCallback were selected by detail::can_be_nullptr, whose non-QNX specialization probed the raw callable with decltype(std::declval<T&>() = nullptr). That expression is ill-formed for some callables/compilers, disabling both overloads and breaking compilation of create_service() (and the generic service) for affected callbacks. Replace the trait with a single set() that stores the callback and then checks the resulting std::function for emptiness via detail::callback_is_null(), which visits the variant. std::function's operator bool flags only genuine null targets (e.g. a null function pointer); lambdas and bind expressions are never empty, so behavior is preserved while the brittle SFINAE is removed. This also collapses the duplicated overload pair in both headers. Add regression tests for function-pointer and std::function callbacks (which previously failed to compile) and null-rejection for both. Fixes ros2#1742 Generated-by: Claude Opus 4.8 (Anthropic) Signed-off-by: Pavel Guzenfeld <pavelguzenfeld@gmail.com>
|
Tick the box to add this pull request to the merge queue (same as @mergifyio queue).
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #1742
AnyServiceCallback::set() (and GenericServiceCallback::set()) chose between two overloads using the detail::can_be_nullptr trait. Its non-QNX specialization probed the raw callable with decltype(std::declval<T &>() = nullptr), which is ill-formed for some callables/compilers — that disables both overloads and breaks compilation of create_service() for the affected callbacks.
This removes the trait and uses a single set() that stores the callback and then rejects it if the resulting std::function is empty (detail::callback_is_null() visits the variant). std::function's operator bool flags only genuine null targets such as a null function pointer; lambdas and bind expressions are never empty, so behaviour is unchanged. The duplicated overload pair in both headers collapses to one.
Adds regression tests for function-pointer and std::function callbacks (which previously failed to compile) and null-rejection for both.
Some of this change was produced with Claude Opus 4.8 (Anthropic).