mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
move assignment operator
This commit is contained in:
parent
7ebc4b2c7e
commit
7463621f56
@ -71,6 +71,7 @@ public:
|
|||||||
Task(const std::string& id = "",
|
Task(const std::string& id = "",
|
||||||
Stage::pointer &&container = std::make_unique<SerialContainer>("task pipeline"));
|
Stage::pointer &&container = std::make_unique<SerialContainer>("task pipeline"));
|
||||||
Task(Task &&other);
|
Task(Task &&other);
|
||||||
|
Task& operator=(Task&& other);
|
||||||
~Task();
|
~Task();
|
||||||
|
|
||||||
std::string id() const;
|
std::string id() const;
|
||||||
|
|||||||
@ -66,12 +66,18 @@ Task::Task(const std::string& id, ContainerBase::pointer &&container)
|
|||||||
|
|
||||||
Task::Task(Task&& other)
|
Task::Task(Task&& other)
|
||||||
: WrapperBase(std::string(), std::make_unique<SerialContainer>())
|
: WrapperBase(std::string(), std::make_unique<SerialContainer>())
|
||||||
, 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_);
|
std::swap(pimpl_, other.pimpl_);
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
planning_pipeline::PlanningPipelinePtr
|
planning_pipeline::PlanningPipelinePtr
|
||||||
|
|||||||
@ -462,4 +462,8 @@ TEST(Task, move) {
|
|||||||
Task t2 = std::move(t1);
|
Task t2 = std::move(t1);
|
||||||
EXPECT_EQ(t2.stages()->numChildren(), 2);
|
EXPECT_EQ(t2.stages()->numChildren(), 2);
|
||||||
EXPECT_EQ(t1.stages()->numChildren(), 0);
|
EXPECT_EQ(t1.stages()->numChildren(), 0);
|
||||||
|
|
||||||
|
t1 = std::move(t2);
|
||||||
|
EXPECT_EQ(t1.stages()->numChildren(), 2);
|
||||||
|
EXPECT_EQ(t2.stages()->numChildren(), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user