This may have been a dumb question on one level: I copied those operators out of the example. Turns out when I delete them, the program compiles, but then when I call insert() I get a SIGSEGV in the STL headers, specifically stl_function.h line 519. The second arg is zero; the others look fine. <br>
<br>517 _Result<br>518 operator()(_Arg1 __x, _Arg2 __y) const<br>519 { return _M_ptr(__x, __y); }<br>520 };<br><br>So I am back where I was: can I use KDTree<> in this manner? Is it intended?<br>
<br>Eric<br><br><div class="gmail_quote">On Thu, Apr 24, 2008 at 9:16 PM, Eric Fowler <<a href="mailto:eric.fowler@gmail.com">eric.fowler@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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;}. <br><br>Since I am storing pointers I want to store pointers in my KDTree too. With that in mind, I wrote this: <br>
<br>//header PlanePoint.h: <br>class PlanePoint : blah blah .. <br><br>inline bool operator==(PlanePoint const * A, PlanePoint const * B);<br><br>//header main.cpp:<br>#include "PlanePoint.h"<br>typedef KDTree::KDTree<2, PlanePoint*, std::pointer_to_binary_function<PlanePoint*, int, double> > tree_type_ptr;<br>
<br>When I make I get this:<br>PlanePoint.h:24: error: 'bool operator==(const PlanePoint*, const PlanePoint*)' must have an argument of class or enumerated type<br>PlanePoint.cpp:16: error: 'bool operator==(const PlanePoint*, const PlanePoint*)' must have an argument of class or enumerated type<br>
<br>This is apparently rooted in some obscure C++ - ism to the effect that you can't define operators for pointers, or some such thing. <br><br>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. <br>
<br>Thanks<br><font color="#888888"><br>Eric<br><br>
</font></blockquote></div><br>