[C++-sig] [boost.python] How can I wrap operator==?

blp330 blp330 at msn.com
Wed Jan 13 07:57:31 CET 2010

Um... Sorry, I mean I have a class Document, which defined

class Document

 bool operator==(const Document& other) const
  return Compare(other);

It simply call Compare method, I need to something more when I use it in
python code but I don't want to change my Document class implementation
because it can be used by other language that do not need extra code.

Py++ generates:
Document_exposer.def( bp::self == bp::self );

For other Document method I can change Py++ generated code to do something
more, for example:
            typedef ::StringPtr ( ::Document::*Thumb_function_type )(
int,int ) const;
                //, Thumb_function_type( &::Document::Thumb )
                , &Document__ThumbWrap
                , ( bp::arg("width"), bp::arg("height") ) );
I can define a Document__ThumbWrap function to write my extra code in it.

But operator==, I don't know how to do that.
I can't simply change
Document_exposer.def( bp::self == bp::self );
     bp::self == bp::self
     , &Document__EqualWrap
to write my extra code in Document__EqualWrap.

Thank you very much.
View this message in context: http://old.nabble.com/-boost.python--How-can-I-wrap-operator%3D%3D--tp27105703p27140350.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.

More information about the Cplusplus-sig mailing list