blob: 12f30048d0a9b8d6aeba9b5f5e5dc02caded9c8f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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;
}
|