diff --git a/core/include/moveit/task_constructor/task.h b/core/include/moveit/task_constructor/task.h index 5ce6e136..64d02d67 100644 --- a/core/include/moveit/task_constructor/task.h +++ b/core/include/moveit/task_constructor/task.h @@ -71,6 +71,7 @@ public: Task(const std::string& id = "", Stage::pointer &&container = std::make_unique("task pipeline")); Task(Task &&other); + Task& operator=(Task&& other); ~Task(); std::string id() const; diff --git a/core/src/task.cpp b/core/src/task.cpp index 261fb234..595d9db5 100644 --- a/core/src/task.cpp +++ b/core/src/task.cpp @@ -66,12 +66,18 @@ Task::Task(const std::string& id, ContainerBase::pointer &&container) Task::Task(Task&& other) : WrapperBase(std::string(), std::make_unique()) - , id_(std::move(other.id_)) - , robot_model_(std::move(other.robot_model_)) - , introspection_(std::move(other.introspection_)) - , task_cbs_(std::move(other.task_cbs_)) { + *this = std::move(other); +} + +Task& Task::operator=(Task&& other) +{ + id_ = std::move(other.id_); + robot_model_ = std::move(other.robot_model_); + introspection_ = std::move(other.introspection_); + task_cbs_ = std::move(other.task_cbs_); std::swap(pimpl_, other.pimpl_); + return *this; } planning_pipeline::PlanningPipelinePtr diff --git a/core/test/test_container.cpp b/core/test/test_container.cpp index 96f77fab..fe457f64 100644 --- a/core/test/test_container.cpp +++ b/core/test/test_container.cpp @@ -462,4 +462,8 @@ TEST(Task, move) { Task t2 = std::move(t1); EXPECT_EQ(t2.stages()->numChildren(), 2); EXPECT_EQ(t1.stages()->numChildren(), 0); + + t1 = std::move(t2); + EXPECT_EQ(t1.stages()->numChildren(), 2); + EXPECT_EQ(t2.stages()->numChildren(), 0); }