Re: [pygccxml-development] special functions/operators
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2006-08-25 17:35:07
|
On 8/25/06, Matthias Baas <ba...@ir...> wrote:
> Roman Yakovenko wrote:
> > On 8/25/06, Neal Becker <ndb...@gm...> wrote:
> >> Is there a way to add special functions/operators to a class?
> >>
> >> For example:
> >>
> >> struct X {};
> >> X& addAssign (X& x1, X const& x2) { return x1; } // silly example
> >>
> >> I want this to do:
> >> .def ("__iadd__", addAssign, return_self<>())
> >
> > I think that if you rename addAssign to __iadd__ this will work, but I
> > am not sure.
> >
> > mb.free_function( 'addAssign' ).rename( '__iadd__' )
>
> I think this would only work when addAssign() was a member of X.
In this case it would work, because first argument of the function is X&.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|