c++ - Binary Tree with std::unique_ptr -
I'm actually using Actually, I use an algorithmic tour, which calculates the distance from the distance matrix, at least! In my algorithm, I encountered myself with the problem of My tree has been created, but do not just "make the branch" on the root node and Here is the code where I have a problem: The function I really need to change the "node" to complete my algorithm, so how can I fix it? std :: unique_ptr to make binary trees.
std :: move () with
std :: unique_ptr .
Node = std :: move (node.get () -> addChild ());
addChild
refers to the new child (= std :: unique_ptr & lt; node & gt;) .
addChild to return
unique_ptr Instead of returning a reference, the result will be a rvalue without the need of an artist with the result
std :: move . In your current code, you pass an original reference for
std :: move , which resulted in it still being a real reference and the copy constructor instead of
std :: unique_ptr's constructor Attempt to invoke .
Comments
Post a Comment