[C++-sig] Newbie boost query

Simon Frost sdfrost at ucsd.edu
Thu Jan 23 02:22:54 CET 2003


Dear David,

At 07:19 PM 1/22/2003 -0500, you wrote:
>Simon Frost <sdfrost at ucsd.edu> writes:
>
> > Hi folks,
>
> > I'm trying to feel my way around Boost.Python, and I've come unstuck
> > whenever I've tried to wrap classes. For example, when I try to wrap
> > a test function ((in my case, RandMT, a Mersenne twister class from
> > Paul Gresham, from http://www.math.keio.ac.jp/~matumoto/july00.html)
>
>FWIW, we have a mersenne twister in Boost's "Random" library.

I'll give it a go; how does it compare with the C Mersenne Twister in 
Python 2.3?

> > with the following functions:
>
> > (i.e. just exposing the default constructor and the randomMT
> > function)
>
>The problems don't have anything to do with the code you used for wrapping.
>
> > I get a bunch of errors abput undefined references:
>
>These are linker errors due to the fact that you're not bringing in
>the Boost.Python DLL's import lib.  Are you following the instructions
>at
>http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boost/boost/libs/python/doc/building.html#building_ext
>??

I did when I first installed (and the examples worked fine); for some 
reason, since I last played with Boost, my installation broke. I 
reinstalled, and now the class wraps happily.

I'm now trying to wrap an AVL Tree (using William McKee's implementation):

template <class T>
class Tree
{
private :
     Node<T> * root;
public :
     Tree ()
     {
         root = NULL;
     }
     ~Tree ()
     {
         delete root;
     }
     void insert (const T & inData)
     {
         root = root -> insert_node (inData);
     }
     const T * find (const T & inData) const
     {
         const Node<T> * found = root -> find_node (inData);
         if (found != NULL)
             return & found -> data;
         else
             return NULL;
     }
     void remove (const T & inData)
     {
         root = root -> remove_node (inData);
     }
     void print (std::ostream & co) const
     {
         root -> print_node (co);
     }
};

Any pointers/similar examples on how to wrap these kinds of structures?

Best,
Simon

Simon D.W. Frost, M.A., D.Phil.
Department of Pathology
University of California, San Diego
Antiviral Research Center
150 W. Washington St., Suite 100
San Diego, CA 92103
USA

Tel: +1 619 543 8080 x275
Fax: +1 619 298 0177
Email: sdfrost at ucsd.edu

Register for the 10th International Discussion meeting on HIV Dynamics and 
Evolution:
http://ari.ucsd.edu/cfar/hivdynamics







More information about the Cplusplus-sig mailing list