Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/operators_wrapper.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 813 bytes
Line 
1#include "boost/python.hpp"
2#include <memory>
3
4struct vector
5{
6    virtual ~vector() {}
7   
8    vector operator+( const vector& x ) const
9    { return vector(); }
10
11    vector& operator+=( const vector& x )
12    { return *this; }
13   
14    vector operator-() const
15    { return *this; }
16};
17
18struct dvector : vector
19{};
20
21using namespace boost::python;
22
23struct vector_wrapper
24  : vector, wrapper< vector >
25{
26    vector_wrapper(vector const&) {}
27    vector_wrapper() {}
28};
29
30BOOST_PYTHON_MODULE( operators_wrapper_ext )
31{
32    class_< vector_wrapper >( "vector" )
33        .def( self + self )
34        .def( self += self )
35        .def( -self )
36        ;
37   
38    scope().attr("v") = vector();
39    std::auto_ptr<vector> dp(new dvector);
40    register_ptr_to_python< std::auto_ptr<vector> >();
41    scope().attr("d") = dp;
42}
Note: See TracBrowser for help on using the repository browser.