diff --git a/docs/advanced.rst b/docs/advanced.rst index 6138af88..f5b48d4d 100644 --- a/docs/advanced.rst +++ b/docs/advanced.rst @@ -461,7 +461,9 @@ functions. The default policy is :enum:`return_value_policy::automatic`. | | See below for a description of what all of these different policies do. | +--------------------------------------------------+----------------------------------------------------------------------------+ | :enum:`return_value_policy::automatic_reference` | As above, but use policy :enum:`return_value_policy::reference` when the | -| | return value is a pointer. You probably won't need to use this. | +| | return value is a pointer. This is the default conversion policy for | +| | function arguments when calling Python functions manually from C++ code | +| | (i.e. via handle::operator()). You probably won't need to use this. | +--------------------------------------------------+----------------------------------------------------------------------------+ | :enum:`return_value_policy::take_ownership` | Reference an existing object (i.e. do not create a new copy) and take | | | ownership. Python will call the destructor and delete operator when the | diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 35726bf3..a4e76aab 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -842,16 +842,18 @@ template object handle::operator()(Args&&... args) const { - tuple args_tuple = pybind11::make_tuple(std::forward(args)...); +template object handle::operator()(Args&&... args) const { + tuple args_tuple = pybind11::make_tuple(std::forward(args)...); object result(PyObject_CallObject(m_ptr, args_tuple.ptr()), false); if (!result) throw error_already_set(); return result; } -template object handle::call(Args &&... args) const { - return operator()(std::forward(args)...); +template object handle::call(Args &&... args) const { + return operator()(std::forward(args)...); } inline object handle::operator()(detail::args_proxy args) const { diff --git a/include/pybind11/common.h b/include/pybind11/common.h index daafa7dd..3075fb3c 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -151,7 +151,9 @@ enum class return_value_policy : uint8_t { automatic = 0, /** As above, but use policy return_value_policy::reference when the return - value is a pointer. You probably won't need to use this. */ + value is a pointer. This is the default conversion policy for function + arguments when calling Python functions manually from C++ code (i.e. via + handle::operator()). You probably won't need to use this. */ automatic_reference, /** Reference an existing object (i.e. do not create a new copy) and take diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index 207e57d1..6eee186d 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -39,12 +39,13 @@ public: inline detail::accessor attr(const char *key) const; inline pybind11::str str() const; template T cast() const; - template + template #if __cplusplus > 201103L [[deprecated("call(...) was deprecated in favor of operator()(...)")]] #endif object call(Args&&... args) const; - template object operator()(Args&&... args) const; + template + object operator()(Args&&... args) const; inline object operator()(detail::args_proxy args) const; inline object operator()(detail::args_proxy f_args, detail::kwargs_proxy kwargs) const; operator bool() const { return m_ptr != nullptr; }