Subject: [Boost-users] [python] Alternative to explicitly defining function pointers?
From: Boris Schaeling (boris_at_[hidden])
Date: 2009-10-12 04:07:26


Is it possible to simplify this code without defining a function pointer?

-----
struct X {
   void y(std::string) { }
   std::string y() { return ""; }
};

std::string (X::*get_y)() = &X::y;

class_<X>("X").add_property("y", get_y);
-----

I tried to set the signature but if the documentation is right signatures
only make sense for function objects - so this code doesn't work:

class_<X>("X").add_property("y", make_function(&X::y,
default_call_policies(), mpl::vector<std::string>()));

Anything else Boost.Python offers to make adding properties even easier?
If there is nothing I know at least that I didn't miss a shortcut and have
to define function pointers myself.

Boris