c++ - Binary Tree with std::unique_ptr -


I'm actually using std :: unique_ptr to make binary trees.

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 std :: move () with std :: unique_ptr .

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:

  Node = std :: move (node.get () -> addChild ());   

The function addChild refers to the new child (= std :: unique_ptr & lt; node & gt;) .

I really need to change the "node" to complete my algorithm, so how can I fix it?

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

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -