|
Boost Users : |
From: François Duranleau (duranlef_at_[hidden])
Date: 2006-08-28 13:26:54
On Sun, 27 Aug 2006, Qinfeng(Javen) Shi wrote:
> Dear All,
>
> How can I wrap a c++ template function(not a member of any class) by pyste
> or manually?
> /**************************************/
> for example :
> template<class T>
> void push(v_array<T>& v, const T &new_ele)
> {
> while(v.index >= v.length)
> {
> v.length = 2*v.length + 3;
> v.elements = (T *)realloc(v.elements,sizeof(T) * v.length);
> }
> v[v.index++] = new_ele;
> }
> /***************************************/
> Here v_array is a class.
> I know how to wrap a c++ template class into python by pyste.
> But what should I do if the template function is not a member of a class.
> (I don't want to put the function"push()" into a class).
It's similar to template class. You just need to explicit give the
template arguments, e.g.
boost::python::def( "push" , & push< int > ) ;
-- François Duranleau LIGUM, Université de Montréal
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net