Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2007-07-21 19:13:32


on Sat Jul 21 2007, "Marcin Kalicinski" <kalita-AT-poczta.onet.pl> wrote:

> It's possible to expose free functions through "thin wrappers":
>
> void f()
> {
> //...
> }
>
> void f_wrapper()
> {
> // ... some extra functionality to be done when called from Python only
> f();
> }
>
> def("f", f_wrapper);
>
> But is it possible to write "thin wrappers" for member functions (without
> modifying the wrapped class)?
>
> struct foo
> {
> void f();
> };
>
> // f_wrapper defined somehow somewhere
>
> class_<foo>("foo")
> .def("f", f_wrapper???)
>

Yeah, just use a non-const reference to the class type as the first
argument to a free function.

         void f_wrapper(foo&, int);
         
         class_<foo>("foo")
             .def("f", f_wrapper???)

======

>>> foo.f(3)
>>>

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net