#include #include #include #include void functionInPython(void){ std::cout << "call functionInCPP\n"; } class ClassInCpp { public: ClassInCpp(void) : varInClassInCpp("varInClassInCpp"){ } std::string varInClassInCpp ; void functionClassInCpp(void){ std::cout << "call functionClassInCpp\n"; } template TT1 templateFunctionInCpp(TT1 x){ std::cout << "call templateFunctionInCpp -arg= " << x << "\n"; return x * x; } }; PYBIND11_MODULE(examplePybind11, m) { m.def("functionInPython", &functionInPython); pybind11::class_(m, "classInPython") .def(pybind11::init<>()) .def_readwrite("varInPython", &ClassInCpp::varInClassInCpp) .def("functionClassInPython", &ClassInCpp::functionClassInCpp) // template function .def("templateFunctionInPython", (uint64_t (ClassInCpp::*)(uint64_t)) &ClassInCpp::templateFunctionInCpp) .def("templateFunctionInPython", (float (ClassInCpp::*)(float )) &ClassInCpp::templateFunctionInCpp); }