mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-13 09:03:54 +00:00
c743e1b1b4
A Python function can be called with the syntax: ```python foo(a1, a2, *args, ka=1, kb=2, **kwargs) ``` This commit adds support for the equivalent syntax in C++: ```c++ foo(a1, a2, *args, "ka"_a=1, "kb"_a=2, **kwargs) ``` In addition, generalized unpacking is implemented, as per PEP 448, which allows calls with multiple * and ** unpacking: ```python bar(*args1, 99, *args2, 101, **kwargs1, kz=200, **kwargs2) ``` and ```c++ bar(*args1, 99, *args2, 101, **kwargs1, "kz"_a=200, **kwargs2) ```
17 lines
305 B
C++
17 lines
305 B
C++
#pragma once
|
|
#include <pybind11/pybind11.h>
|
|
#include <iostream>
|
|
#include <functional>
|
|
#include <list>
|
|
|
|
using std::cout;
|
|
using std::endl;
|
|
|
|
namespace py = pybind11;
|
|
using namespace pybind11::literals;
|
|
|
|
class test_initializer {
|
|
public:
|
|
test_initializer(std::function<void(py::module &)> initializer);
|
|
};
|