@@ -707,20 +707,24 @@ template <typename T> inline object cast(const T &value, return_value_policy pol
707
707
template <typename T> inline T handle::cast () const { return pybind11::cast<T>(*this ); }
708
708
template <> inline void handle::cast () const { return ; }
709
709
710
- template <typename ... Args> inline object handle::call (Args&&... args_) const {
710
+ template <typename ... Args> inline tuple make_tuple (Args&&... args_) {
711
711
const size_t size = sizeof ...(Args);
712
712
std::array<object, size> args {
713
713
{ object (detail::type_caster<typename detail::intrinsic_type<Args>::type>::cast (
714
- std::forward<Args>(args_), return_value_policy::reference , nullptr ), false )... }
714
+ std::forward<Args>(args_), return_value_policy::automatic , nullptr ), false )... }
715
715
};
716
716
for (auto &arg_value : args)
717
717
if (!arg_value)
718
- throw cast_error (" handle::call(): unable to convert input "
719
- " arguments to Python objects" );
720
- tuple args_tuple (size);
718
+ throw cast_error (" make_tuple(): unable to convert arguments to Python objects" );
719
+ tuple result (size);
721
720
int counter = 0 ;
722
721
for (auto &arg_value : args)
723
- PyTuple_SET_ITEM (args_tuple.ptr (), counter++, arg_value.release ().ptr ());
722
+ PyTuple_SET_ITEM (result.ptr (), counter++, arg_value.release ().ptr ());
723
+ return result;
724
+ }
725
+
726
+ template <typename ... Args> inline object handle::call (Args&&... args) const {
727
+ tuple args_tuple = make_tuple (std::forward<Args>(args)...);
724
728
object result (PyObject_CallObject (m_ptr, args_tuple.ptr ()), false );
725
729
if (!result)
726
730
throw error_already_set ();
0 commit comments