[C++-sig] Quick question about wrapping methods that have multiple versions
nico_ml at mgdesign.org
Wed Sep 9 12:15:09 CEST 2009
> You may disambiguate by using a cast inside .def(), such as
> .def("getA", (A*(B::*)())B::getA);
> Whether that's actually more readable is arguable, however.
IMHO, this is quite dangerous as the explicit cast prevents the compiler to
give you a proper error if the signature of B::getA changes at some point in
time. The original approach ( A* (B::*B_getA1)() = &B::getA; ) requires
extra typing but provides a safety net for refactoring B::getA.
More information about the Cplusplus-sig