jlblancoc / nanoflann

nanoflann: a C++11 header-only library for Nearest Neighbor (NN) search with KD-trees
Other
2.19k stars 486 forks source link

Request for Support with Copy and Move Semantics for KDTree in nanoflann Library #215

Open cbtxs opened 10 months ago

cbtxs commented 10 months ago

Hello, I've been using the nanoflann library, and the KDTree algorithm developed by your team is incredibly efficient, greatly benefiting my current project. However, I recently encountered an issue where I need to copy KDTree objects and use move semantics with the operator=. Unfortunately, my C++ skills are limited, and I'm unsure how to achieve this. I kindly request your team to consider adding this functionality or providing guidance on how to accomplish it.

jlblancoc commented 10 months ago

It could be done at the nanoflann level, but in other projects, I have normally used encapsulation into a std::shared_ptr or std::unique_ptr. In that way, we can keep nanoflann as "simple" as possible...

See an example implementation here: https://github.com/MRPT/mrpt/blob/c4e09e25ba225feb64b17396b351de1d23394738/libs/math/include/mrpt/math/KDTreeCapable.h#L716-L753