|
14 | 14 |
|
15 | 15 | #include <utility>
|
16 | 16 |
|
| 17 | +// Classes needed for subclass test. |
| 18 | +class ArgsSubclass : public py::args { |
| 19 | + using py::args::args; |
| 20 | +}; |
| 21 | +class KWArgsSubclass : public py::kwargs { |
| 22 | + using py::kwargs::kwargs; |
| 23 | +}; |
| 24 | +template <> |
| 25 | +struct handle_type_name<ArgsSubclass> { |
| 26 | + static constexpr auto name = const_name("*args"); |
| 27 | +}; |
| 28 | +template <> |
| 29 | +struct handle_type_name<KWArgsSubclass> { |
| 30 | + static constexpr auto name = const_name("**kwargs"); |
| 31 | +}; |
| 32 | + |
17 | 33 | TEST_SUBMODULE(kwargs_and_defaults, m) {
|
18 | 34 | auto kw_func
|
19 | 35 | = [](int x, int y) { return "x=" + std::to_string(x) + ", y=" + std::to_string(y); };
|
@@ -324,20 +340,6 @@ TEST_SUBMODULE(kwargs_and_defaults, m) {
|
324 | 340 | py::arg("j"));
|
325 | 341 |
|
326 | 342 | // Test support for args and kwargs subclasses
|
327 |
| - class ArgsSubclass : public py::args { |
328 |
| - using py::args::args; |
329 |
| - }; |
330 |
| - class KWArgsSubclass : public py::kwargs { |
331 |
| - using py::kwargs::kwargs; |
332 |
| - }; |
333 |
| - template <> |
334 |
| - struct handle_type_name<ArgsSubclass> { |
335 |
| - static constexpr auto name = const_name("*args"); |
336 |
| - }; |
337 |
| - template <> |
338 |
| - struct handle_type_name<KWArgsSubclass> { |
339 |
| - static constexpr auto name = const_name("**kwargs"); |
340 |
| - }; |
341 | 343 | m.def("args_kwargs_subclass_function",
|
342 | 344 | [](const ArgsSubclass &args, const KWArgsSubclass &kwargs) {
|
343 | 345 | return py::make_tuple(args, kwargs);
|
|
0 commit comments