Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctad #35

Merged
merged 2 commits into from
Sep 26, 2023
Merged

Ctad #35

merged 2 commits into from
Sep 26, 2023

Conversation

Jaybro
Copy link
Owner

@Jaybro Jaybro commented Sep 26, 2023

Added support for class template argument deduction (CTAD). This means that the space type can now be deduced from the argument given to the constructor of the KdTree:

std::size_t max_leaf_size = 10;
std::vector<std::array<double, 2>> points{{0.0, 1.0}, {2.0, 3.0}};

// Deduces to:
// pico_tree::KdTree<std::reference_wrapper<std::vector<std::array<double, 2>>>>
pico_tree::KdTree tree(std::ref(points), max_leaf_size);

Using the previous auto deduction method, we still have to specify the space type when we want to change any of the other template arguments, such as the metric type. In this case we can use the MakeKdTree method to make life a bit easier.

std::size_t max_leaf_size = 10;
std::vector<std::array<double, 2>> points{{0.0, 1.0}, {2.0, 3.0}};

auto tree = 
    pico_tree::MakeKdTree<pico_tree::LInf>(std::ref(points), max_leaf_size);

Updated various examples to use CTAD.
Split priority queue from priority search.
@Jaybro Jaybro added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 26, 2023
@Jaybro Jaybro self-assigned this Sep 26, 2023
@Jaybro Jaybro merged commit f6f65d0 into master Sep 26, 2023
6 checks passed
@Jaybro Jaybro deleted the ctad branch September 26, 2023 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant