[C++-sig] call policies

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Tue Nov 8 03:45:51 CET 2005


--- Ricardo Kirkner <ricardokirkner at gmail.com> wrote:

> Ok... thanks for the reply...
> 
> How will boost.python figure out that the corresponding method for
> 
> .def(self_ns::str(self))
> 
> should be (for example)
> 
> std::ostream& operator<< (in the c++ code)

Only David knows *how* Boost.Python does it, but this test proves that it does
exactly what you are looking for:

boost/libs/python/test/operators.cpp

Note that you can always provide your own custom string method via

.def("__str__", &yours::method)

or

.def("__str__", another_thin_wrapper)

BTW: I find the test source code extremely useful as a reference. It is worth
spending 30 minutes looking through all the .cpp files to get an overview.

Cheers,
        Ralf



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com



More information about the Cplusplus-sig mailing list