From fc58b0f92814eaeb105d1557abd4b12df23d689a Mon Sep 17 00:00:00 2001 From: Marius Muja Date: Fri, 4 Nov 2011 18:36:14 -0700 Subject: [PATCH] Nicer way of instantiating indexes based on runtime values --- src/cpp/flann/algorithms/all_indices.h | 129 ++++++++++++++++++++- src/cpp/flann/algorithms/autotuned_index.h | 2 + src/cpp/flann/algorithms/dist.h | 41 ++----- src/cpp/flann/algorithms/kdtree_index.h | 1 + src/cpp/flann/algorithms/kmeans_index.h | 1 + src/cpp/flann/defines.h | 5 +- src/cpp/flann/util/any.h | 5 +- src/cpp/flann/util/result_set.h | 2 +- 8 files changed, 148 insertions(+), 38 deletions(-) diff --git a/src/cpp/flann/algorithms/all_indices.h b/src/cpp/flann/algorithms/all_indices.h index 7ac7265..5d4cbae 100644 --- a/src/cpp/flann/algorithms/all_indices.h +++ b/src/cpp/flann/algorithms/all_indices.h @@ -72,7 +72,7 @@ struct index_creator nnIndex = new KDTreeCuda3dIndex(dataset, params, distance); break; #endif - + case FLANN_INDEX_KMEANS: nnIndex = new KMeansIndex(dataset, params, distance); break; @@ -151,12 +151,133 @@ struct index_creator } }; + + +/** + * enable_if sfinae helper + */ +template struct enable_if{}; +template struct enable_if { typedef T type; }; + +/** + * disable_if sfinae helper + */ +template struct disable_if{ typedef T type; }; +template struct disable_if { }; + +/** + * Check if two type are the same + */ +template +struct same_type +{ + enum {value = false}; +}; + +template +struct same_type +{ + enum {value = true}; +}; + + +/** + * Checks if an index and a distance can be used together + */ +template