From 385ca55461a63d605b3a476d8b1d75852f875363 Mon Sep 17 00:00:00 2001 From: Daisuke Nishimatsu Date: Mon, 20 Jul 2026 05:48:27 +1000 Subject: [PATCH] Use use_count in LockedRobotState This upstreams the C++20-compatible part of the RoboStack moveit_ros_robot_interaction build fix. std::shared_ptr::unique() was removed in C++20. Comparing use_count() with one keeps the existing copy-on-write behavior while avoiding the removed API in toolchains that build MoveIt with newer C++ standards. Origin: patch/ros-rolling-moveit-ros-robot-interaction.patch, authored by Daisuke Nishimatsu. Signed-off-by: Tobias Fischer --- moveit_ros/robot_interaction/src/locked_robot_state.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moveit_ros/robot_interaction/src/locked_robot_state.cpp b/moveit_ros/robot_interaction/src/locked_robot_state.cpp index 15b8d0c845..35c859bdac 100644 --- a/moveit_ros/robot_interaction/src/locked_robot_state.cpp +++ b/moveit_ros/robot_interaction/src/locked_robot_state.cpp @@ -66,7 +66,7 @@ void robot_interaction::LockedRobotState::setState(const moveit::core::RobotStat // If someone else has a reference to the state, then make a new copy. // The old state is orphaned (does not change, but is now out of date). - if (state_.unique()) + if (state_.use_count() == 1) { *state_ = state; } @@ -87,7 +87,7 @@ void robot_interaction::LockedRobotState::modifyState(const ModifyStateFunction& // If someone else has a reference to the state, then make a copy. // The old state is orphaned (does not change, but is now out of date). - if (!state_.unique()) + if (state_.use_count() != 1) state_ = std::make_shared(*state_); modify(state_.get());