[C++-sig] Wrapping multiple class_<T> objects
David Abrahams
dave at boost-consulting.com
Wed Nov 20 14:02:03 CET 2002
Peter Bienstman <Peter.Bienstman at rug.ac.be> writes:
> Hello,
>
> I'm trying to wrap a class and two specific instances of it:
>
> class_<SlabWallMixed, bases<SlabWall> >
> ("SlabWallMixed", init<const Complex&, const Complex&>());
>
> object slab_E_wall
> = (class_<SlabWallMixed, bases<SlabWall> >
> ("slab_E_wall", init<const Complex&, const Complex&>()))(1.0,1.0);
>
> object slab_H_wall
> = (class_<SlabWallMixed, bases<SlabWall> >
> ("slab_H_wall", init<const Complex&, const Complex&>()))(1.0,-1.0);
>
> Any of these statements by themselves work fine, but if I combine two or more,
> I get:
>
> RuntimeError: trying to register to_python_converter for a type which already
> has a registered to_python_converter
>
> Did I get the syntax wrong or is this currenty impossible?
There are lots of ways to write this so you don't instantiate the same
class_<> twice. One is:
object slabwallmixed
= class_<SlabWallMixed, bases<SlabWall> >
("SlabWallMixed", init<const Complex&, const Complex&>());
object slab_E_wall = slabwallmixed(1.0,1.0);
object slab_H_wall = slabwallmixed(1.0,-1.0);
--
David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution
More information about the Cplusplus-sig
mailing list