Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 341d867

Browse files
committed
make Tree non copyable
1 parent 01ab2b7 commit 341d867

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

include/behaviortree_cpp/bt_factory.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,26 @@ struct Tree
8282
std::vector<Blackboard::Ptr> blackboard_stack;
8383
std::unordered_map<std::string, TreeNodeManifest> manifests;
8484

85-
Tree() : root_node(nullptr) { }
85+
Tree(): root_node(nullptr) {}
86+
87+
// non-copyable. Only movable
88+
Tree(const Tree& ) = delete;
89+
Tree& operator=(const Tree&) = delete;
90+
91+
Tree(Tree&& other)
92+
{
93+
(*this) = std::move(other);
94+
}
95+
96+
Tree& operator=(Tree&& other)
97+
{
98+
root_node = std::move(other.root_node);
99+
nodes = std::move(other.nodes);
100+
blackboard_stack = std::move(other.blackboard_stack);
101+
manifests = std::move(other.manifests);
102+
return *this;
103+
}
104+
86105
~Tree();
87106

88107
Blackboard::Ptr rootBlackboard();

0 commit comments

Comments
 (0)