diff options
Diffstat (limited to '')
-rw-r--r-- | src/boost/libs/python/test/operators_wrapper.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/boost/libs/python/test/operators_wrapper.cpp b/src/boost/libs/python/test/operators_wrapper.cpp new file mode 100644 index 000000000..12f30048d --- /dev/null +++ b/src/boost/libs/python/test/operators_wrapper.cpp @@ -0,0 +1,42 @@ +#include "boost/python.hpp" +#include <memory> + +struct vector +{ + virtual ~vector() {} + + vector operator+( const vector& ) const + { return vector(); } + + vector& operator+=( const vector& ) + { return *this; } + + vector operator-() const + { return *this; } +}; + +struct dvector : vector +{}; + +using namespace boost::python; + +struct vector_wrapper + : vector, wrapper< vector > +{ + vector_wrapper(vector const&) {} + vector_wrapper() {} +}; + +BOOST_PYTHON_MODULE( operators_wrapper_ext ) +{ + class_< vector_wrapper >( "vector" ) + .def( self + self ) + .def( self += self ) + .def( -self ) + ; + + scope().attr("v") = vector(); + std::auto_ptr<vector> dp(new dvector); + register_ptr_to_python< std::auto_ptr<vector> >(); + scope().attr("d") = dp; +} |