15 return "test_function()";
19 return "test_function(enum=" + std::to_string(k) +
")";
23 return "test_function(" + std::to_string(
i) +
")";
32 const char *
data =
"\x01\x00\x02\x00";
33 return std::string(
data, 4);
37 std::string ret =
"bytes[";
38 const auto value =
static_cast<std::string
>(
bytes);
39 for (
size_t i = 0;
i <
value.length(); ++
i) {
40 ret += std::to_string(
static_cast<int>(
value[
i])) +
" ";
52 #if defined(__INTEL_COMPILER) && defined(PYBIND11_CPP17)
53 int f1(
int x) noexcept(
true) {
return x+1; }
55 int f1(
int x) noexcept {
return x+1; }
57 int f2(
int x) noexcept(
true) {
return x+2; }
58 int f3(
int x) noexcept(
false) {
return x+3; }
60 # pragma GCC diagnostic push
61 # pragma GCC diagnostic ignored "-Wdeprecated"
63 int f4(
int x)
throw() {
return x+4; }
65 # pragma GCC diagnostic pop
68 int m1(
int x) noexcept {
return x-1; }
69 int m2(
int x)
const noexcept {
return x-2; }
70 int m3(
int x) noexcept(
true) {
return x-3; }
71 int m4(
int x)
const noexcept(
true) {
return x-4; }
72 int m5(
int x) noexcept(
false) {
return x-5; }
73 int m6(
int x)
const noexcept(
false) {
return x-6; }
75 # pragma GCC diagnostic push
76 # pragma GCC diagnostic ignored "-Wdeprecated"
78 int m7(
int x)
throw() {
return x-7; }
79 int m8(
int x)
const throw() {
return x-8; }
81 # pragma GCC diagnostic pop
89 m.attr(
"some_constant") = py::int_(14);
96 #if defined(PYBIND11_OVERLOAD_CAST)
100 m.def(
"test_function", py::overload_cast<float, int>(&
test_function4));
103 m.def(
"test_function",
static_cast<py::str (*)(
char *)
>(&
test_function4));
104 m.def(
"test_function",
static_cast<py::str (*)(
int,
float)
>(&
test_function4));
105 m.def(
"test_function",
static_cast<py::str (*)(
float,
int)
>(&
test_function4));
108 py::enum_<MyEnum>(
m,
"MyEnum")
119 py::class_<C>(
m,
"C")
136 struct LargeCapture {
139 uint64_t zeros[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
141 m.def(
"register_large_capture_with_invalid_arguments", [](py::module_
m) {
143 m.def(
"should_raise", [
capture](
int) {
return capture.zeros[9] + 33; }, py::kw_only(), py::arg());
145 m.def(
"register_with_raising_repr", [](py::module_
m, py::object default_value) {
146 m.def(
"should_raise", [](
int,
int, py::object) {
return 42; },
"some docstring",
147 py::arg_v(
"x", 42), py::arg_v(
"y", 42,
"<the answer>"), py::arg_v(
"z", default_value));