Gonsolo gonsolo at
Fri Jul 11 12:59:02 UTC 2008


I had to declare two operators in my predicate to get it working:

#include "kdtree++/kdtree.hpp"

class A
         float f;

typedef KDTree::KDTree<3, A, std::pointer_to_binary_function< 
A,int,float> > Atree;
inline double tac( A a, int k ) { return a.f; }

struct not_me
         A me;
         not_me( A m ) : me( m ) {}
         bool operator()( KDTree::_Node<A> const * n ) const { return 
true; }
         bool operator()( const A & n ) const { return true; }

Atree::iterator find_nearest()
         Atree tree;
         Atree::iterator it = tree.begin();
         A tmp = *it;
         Atree::const_iterator found = tree.find_nearest_if( tmp, 10.f, 
not_me( tmp ) ).first;
         assert( it != found );
         return found;

Note that I had to declare two operators, one with a const& and a second 
one with "KDTree::_Node<A> const*".
Without the first operator compilation fails at /kdtree++/node.hpp:367,
without the second one it fails at kdtree++/kdtree.hpp:494.

Is this intended? I find this very inconvenient.

Paul Harris wrote:
> this is not expected,  perhaps Sylvain has the time to look into this?

A second thing is that I think calling a class _and_ a namespace KDTree
very disturbing. I took me a long time to find out that "KDTree::_Node" is
not a member.


More information about the libkdtree-devel mailing list