[C++-sig] Exposing a template class

Roman Yakovenko roman.yakovenko at gmail.com
Fri May 18 20:44:26 CEST 2007


On 5/18/07, Pertti Kellomäki <pk at cs.tut.fi> wrote:
> Roman Yakovenko wrote:
> > It is not that clear what you want to do. Exposing instantiation of
> > template class is not different from exposing non-template class.
>
> I have a template class, whose three different instantiations
> are used as base classes for some concrete classes. I was
> wondering whether I could write a template that would expand
> into the appropriate declarations for exposing a particular
> instantiation. Just writing the wrapper struct as a template
> would of course already go a long way.


Do you mean something like this:

template< class T >
void export_xx(const sd::string& name){
    boost::python::class_< T, ... >( name )
         ....
    ;
}

export_xx<X1>( "X1" );
export_xx<X2>( "X2" );
export_xx<X3>( "X3" );

Than yes, you can do this.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list