move assignment operator

This commit is contained in:
Robert Haschke 2018-04-08 09:19:07 +02:00
parent 7ebc4b2c7e
commit 7463621f56
3 changed files with 15 additions and 4 deletions

View File

@ -71,6 +71,7 @@ public:
Task(const std::string& id = "",
Stage::pointer &&container = std::make_unique<SerialContainer>("task pipeline"));
Task(Task &&other);
Task& operator=(Task&& other);
~Task();
std::string id() const;

View File

@ -66,12 +66,18 @@ Task::Task(const std::string& id, ContainerBase::pointer &&container)
Task::Task(Task&& other)
: 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_);
return *this;
}
planning_pipeline::PlanningPipelinePtr

View File

@ -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);
}