[C++-sig] Indexing_suite when container is newed
s_sourceforge at nedprod.com
Wed Oct 15 18:30:55 CEST 2003
Right, last error in the last file - everything else compiles! I have
a method called lasso() in FXGLViewer which returns an array of
FXGLObject pointers falling within the specified coordinates.
Unfortunately the list returned is malloced and if not freed after
python is done with it would leak memory. My initial attempt was as
static indexing::iterator_pair<FXGLObject **>
FXGLViewer_lasso(FXGLViewer &c, FXint x1,FXint y1,FXint x2,FXint y2)
typedef indexing::iterator_pair<FXGLObject **> IterPair;
class_<IterPair>( "FXGLViewer_lassoIndirect", init<FXGLObject **,
return IterPair(data, data+(1<<16));
However it would appear that setting a policy at the container_suite
level sets it for the iterator_pair which isn't what I want. Anyway
besides the list is malloced and not newed, though in fact I've
replaced new and delete with my own versions which do call malloc.
What one would want is the ability to call a destructor when the
iterator_pair is destroyed. Unfortunately I can't hack in a
destructor because it gets lost in the downcast and I can't use
auto_ptr because both of the iterators must be the same type (and the
end of array is not a valid memory location). So I'm guessing it
needs added support.
I'd imagine copy construction needs to be destructive so myBegin and
myEnd would need to become mutable and one would need a user-
Or perhaps one could create a new custom type of return policy and
set that instead?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 208 bytes
Desc: not available
More information about the Cplusplus-sig