boost python code involving both static and overloaded member functions

  boost, c++, overloading, python, static

I’m trying to compile some boost python code involving both static and overloaded member functions. Any hint? I just can’t get it compiled using pointers on functions (never done it before) but may be there is another track to follow?

#include<iostream>
#include <boost/python.hpp>
#include <boost/python/raw_function.hpp>


namespace python = boost::python;


class ORM
{
public:
  static void print() {std::cout << "Fou statique!!!!" << std::endl;}
  static void print(std::string st) {std::cout << st << std::endl;}
  static void print(std::string st1, std::string st2) {std::cout << st1 << std::endl; std::cout << st2 << std::endl;}
};

void (ORM::*print1)() = &ORM::print;
void (ORM::*print2)(std::string st) = &ORM::print;
void (ORM::*print3)(std::string st1, std::string st2) = &ORM::print;


BOOST_PYTHON_MODULE(politopy)
{
  python::class_<ORM>("ORM")
    .def("print", &ORM::print1).staticmethod("print")
    .def("print", &ORM::print2).staticmethod("print")
    .def("print", &ORM::print3).staticmethod("print")
;
}

Source: Windows Questions C++

LEAVE A COMMENT