Skip to content

Commit cd4b49a

Browse files
authored
Update py::kwargs examples to pass by reference (#3038)
1 parent 4c7697d commit cd4b49a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/advanced/functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ For instance, the following statement iterates over a Python ``dict``:
254254

255255
.. code-block:: cpp
256256
257-
void print_dict(py::dict dict) {
257+
void print_dict(const py::dict& dict) {
258258
/* Easily interact with Python types */
259259
for (auto item : dict)
260260
std::cout << "key=" << std::string(py::str(item.first)) << ", "
@@ -292,7 +292,7 @@ Such functions can also be created using pybind11:
292292

293293
.. code-block:: cpp
294294
295-
void generic(py::args args, py::kwargs kwargs) {
295+
void generic(py::args args, const py::kwargs& kwargs) {
296296
/// .. do something with args
297297
if (kwargs)
298298
/// .. do something with kwargs

0 commit comments

Comments
 (0)