[C++-sig] Instantiated template class exported to python

Stefan Seefeld seefeld at sympatico.ca
Mon Feb 13 22:21:47 CET 2006


Nicolas.Rougier at loria.fr wrote:
> 
> Hello,
> 
> 
> I'm trying to define a template class such that I can export
> instantiated derived classed with boost. I tried the code included
> at the end of this message but it doesn't compile. Error is:
> 
> /usr/include/boost/python/object/value_holder.hpp:157: error: no
> matching function for call to ‘VecInt::VecInt(PyObject*&, const
> VecInt&)’
> core.cc:17: note: candidates are: VecInt::VecInt(const VecInt&)
> core.cc:17: note:                 VecInt::VecInt()
> 
> 
> I do not quite understand why compiler doesn't found Vec constructors.
> Is there something I misunderstood about templates or is there some
> misconception in my code (and what would be the right way to do it in
> that case) ?

As with all methods and functions, constructors have to be exported
individually (and explicitely). You only exported the default constructor
with 'init<> ()'. Use your own signature such as 'init<int>()' to export
a constructor taking a single int argument. Etc.

HTH,
		Stefan



More information about the Cplusplus-sig mailing list