-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest_functional.cpp
More file actions
38 lines (29 loc) · 935 Bytes
/
test_functional.cpp
File metadata and controls
38 lines (29 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "pybind11_utils/functional.h"
#include <pybind11/pybind11.h>
PYBIND11_MODULE(functional, m)
{
m.def("fn_0_arg", [](std::function<int()> const& fn) {
return fn();
});
m.def("fn_1_arg", [](std::function<int(int)> const& fn, int a) {
return fn(a);
});
m.def("fn_2_arg", [](std::function<int(int, int)> const& fn, int a, int b) {
return fn(a, b);
});
m.def("fn_0_or_1_arg", [](std::function<int()> const& fn) {
return fn();
});
m.def("fn_0_or_1_arg", [](std::function<int(int)> const& fn) {
return fn(1);
});
m.def("fn_1_or_2_or_3_arg", [](std::function<int(int)> const& fn) {
return fn(1);
});
m.def("fn_1_or_2_or_3_arg", [](std::function<int(int, int)> const& fn) {
return fn(1, 2);
});
m.def("fn_1_or_2_or_3_arg", [](std::function<int(int, int, int)> const& fn) {
return fn(1, 2, 3);
});
}