diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/python/test/operators_wrapper.cpp | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/python/test/operators_wrapper.cpp')
-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; +} |