Can I build a KDTree of pointers to objects?
Eric Fowler
eric.fowler at gmail.com
Fri Apr 25 04:16:28 UTC 2008
I have a toy app that is storing a set<> of pointers to a PlanePoint object,
itself little more than a wrapper for {int x, y;}.
Since I am storing pointers I want to store pointers in my KDTree too. With
that in mind, I wrote this:
//header PlanePoint.h:
class PlanePoint : blah blah ..
inline bool operator==(PlanePoint const * A, PlanePoint const * B);
//header main.cpp:
#include "PlanePoint.h"
typedef KDTree::KDTree<2, PlanePoint*,
std::pointer_to_binary_function<PlanePoint*, int, double> > tree_type_ptr;
When I make I get this:
PlanePoint.h:24: error: 'bool operator==(const PlanePoint*, const
PlanePoint*)' must have an argument of class or enumerated type
PlanePoint.cpp:16: error: 'bool operator==(const PlanePoint*, const
PlanePoint*)' must have an argument of class or enumerated type
This is apparently rooted in some obscure C++ - ism to the effect that you
can't define operators for pointers, or some such thing.
What I want to know is, do we have a workaround? I could just make copies of
my object in the kdtree but would like to avoid that if at all possible.
Thanks
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/libkdtree-devel/attachments/20080424/02ab8c12/attachment.htm
More information about the libkdtree-devel
mailing list