File: sub.cpp

package info (click to toggle)
taskflow 3.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 45,948 kB
  • sloc: cpp: 39,058; xml: 35,572; python: 12,935; javascript: 1,732; makefile: 59; sh: 16
file content (14 lines) | stat: -rw-r--r-- 462 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <pybind11/pybind11.h>

struct Foo {
    static Foo aThing() { return {}; }
};

PYBIND11_MODULE(_sub, m) {
    pybind11::class_<Foo>{m, "Foo", "A class, renamed from Foo to Class"}
        .def("a_thing", &Foo::aThing, "A method");

    pybind11::module bar = m.def_submodule("bar");
    bar.doc() = "This submodule is renamed from bar to submodule and should have a function member.";
    bar.def("foo", [](Foo, int a) { return a*2; }, "A function");
}