I have a class that has two functions, both of which take a different set of parameters and both of which have default arguments like so:
void PlaySound(const std::string &soundName, int channel = 0, bool UseStoredPath = true);
void PlaySound(FMOD::Sound* sound, int channel = 0);
I’ve found how to do default argument overloads from the tutorial here
http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/overloads.html
as well as how to do function overloads taking different parameter types here
http://boost.2283326.n4.nabble.com/Boost-Python-def-and-member-function-overloads-td2659648.html
and I end up doing something like this…
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(PlaySoundFromFile, Engine::PlaySound, 1, 3)
BOOST_PYTHON_MODULE(EngineModule)
{
class_<Engine>("Engine")
//Sound
.def("PlaySound", static_cast< void(Engine::*)(std::string, int, bool)>(&Engine::PlaySound));
}
The problem is I really have no idea how to use them together at the same time. I’d like to avoid having to change my base class function definitions.
Can someone who’s done this before, or knows how to do this help me out?
Thanks in advance
This works for me:
The trick is that you need to tell each
def()to use one of the overload specifiers (that seemed to be the biggest missing piece from what you had).