[C++-sig] Quick question about wrapping methods that have multiple versions
Jean-Sébastien Guay
jean-sebastien.guay at cm-labs.com
Wed Sep 9 05:30:22 CEST 2009
Hi all,
This may be an FAQ, but if so I haven't seen it in the FAQs (on the wiki
and in the docs).
Say I have this:
class A {};
class B
{
public:
A* getA();
const A* getA() const;
};
If I just add .def("getA", &B::getA, some_return_policy) to my class_
wrapper, on compile it will complain that it doesn't know which version
of B::getA() I want. Up until now the way I wrapped this was to make a
trivial wrapper function:
A* (B::*B_getA1)() = &B::getA;
and then used .def("getA", B_getA1, some_return_policy). But as I wrap
many classes, I wind up with lost of these trivial wrappers at the top
of my source files, they're hard to read when skimming and just plain
look bad. Is there some template or preprocessor magic I could use to
generate these automatically, or even better, to allow me to specify in
the .def() which version I want?
Thanks in advance,
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-sebastien.guay at cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
More information about the Cplusplus-sig
mailing list