boost-python select between overloaded methods

后端 未结 4 2008
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 21:38

Assume exist some class Foo with two overloaded methods:

class Foo
{
  ...
   void m1(A& a);
   void m1(B& b);

I need expose one of

4条回答
  •  没有蜡笔的小新
    2021-01-03 22:31

    You can use static_cast to specify which signature to use. With this method, you do not need to create a named function pointer while also keeping your overload resolution within the context of a single line.

    boost::python::class_("Foo")
        .def("m1", static_cast(&Foo::m1))
        .def("m1", static_cast(&Foo::m1))
    

提交回复
热议问题