File tree Expand file tree Collapse file tree 4 files changed +15
-12
lines changed
py-demo/bindings/src/modules Expand file tree Collapse file tree 4 files changed +15
-12
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ namespace demo{
5
5
6
6
7
7
class CppException : public std ::runtime_error {
8
- // using std::runtime_error;
8
+ using std::runtime_error ::runtime_error;
9
9
};
10
10
11
11
struct Foo {
Original file line number Diff line number Diff line change @@ -59,7 +59,10 @@ install_pybind11() {
59
59
}
60
60
61
61
install_demo () {
62
- cmake -S " ${TESTS_ROOT} /demo-lib" -B " ${BUILD_ROOT} /demo"
62
+ cmake \
63
+ -S " ${TESTS_ROOT} /demo-lib" \
64
+ -B " ${BUILD_ROOT} /demo" \
65
+ -DCMAKE_CXX_STANDARD=17
63
66
cmake --build " ${BUILD_ROOT} /demo"
64
67
cmake --install " ${BUILD_ROOT} /demo" \
65
68
--prefix " ${INSTALL_PREFIX} "
Original file line number Diff line number Diff line change 1
1
#include " modules.h"
2
2
3
- namespace mymodules {
3
+ namespace {
4
4
struct Dummy {
5
5
int regular_method (int x) { return x + 1 ; }
6
6
static int static_method (int x) { return x + 1 ; }
@@ -9,8 +9,8 @@ struct Dummy {
9
9
} // namespace
10
10
11
11
void bind_methods_module (py::module && m) {
12
- auto &&pyDummy = py::class_<mymodules:: Dummy>(m, " Dummy" );
12
+ auto &&pyDummy = py::class_<Dummy>(m, " Dummy" );
13
13
14
- pyDummy.def_static (" static_method" , &mymodules:: Dummy::static_method);
15
- pyDummy.def (" regular_method" , &mymodules:: Dummy::regular_method);
14
+ pyDummy.def_static (" static_method" , &Dummy::static_method);
15
+ pyDummy.def (" regular_method" , &Dummy::regular_method);
16
16
}
Original file line number Diff line number Diff line change 4
4
5
5
#include < chrono>
6
6
7
- namespace myvalues {
7
+ namespace {
8
8
class Dummy {};
9
9
class Foo {};
10
10
} // namespace
11
11
12
12
void bind_values_module (py::module &&m) {
13
13
{
14
14
// python module as value
15
- auto &&pyDummy = py::class_<myvalues:: Dummy>(m, " Dummy" );
15
+ auto &&pyDummy = py::class_<Dummy>(m, " Dummy" );
16
16
17
17
pyDummy.def_property_readonly_static (
18
18
" linalg" , [](py::object &) { return py::module::import (" numpy.linalg" ); });
@@ -27,12 +27,12 @@ void bind_values_module(py::module &&m) {
27
27
m.attr (" list_with_none" ) = li;
28
28
}
29
29
{
30
- auto pyFoo = py::class_<myvalues:: Foo>(m, " Foo" );
31
- m.attr (" foovar" ) = myvalues:: Foo ();
30
+ auto pyFoo = py::class_<Foo>(m, " Foo" );
31
+ m.attr (" foovar" ) = Foo ();
32
32
33
33
py::list foolist;
34
- foolist.append (myvalues:: Foo ());
35
- foolist.append (myvalues:: Foo ());
34
+ foolist.append (Foo ());
35
+ foolist.append (Foo ());
36
36
37
37
m.attr (" foolist" ) = foolist;
38
38
m.attr (" none" ) = py::none ();
You can’t perform that action at this time.
0 commit comments