diff --git a/objects.h b/objects.h index c2d1eabe..4f54befc 100644 --- a/objects.h +++ b/objects.h @@ -13,6 +13,7 @@ # include "pyconfig.h" # include "pyptr.h" # include "boost/operators.hpp" +# include namespace py { @@ -36,8 +37,31 @@ class Tuple : public Object public: Tuple(std::size_t n = 0); explicit Tuple(Ptr p); + + template + Tuple(const std::pair& x) + : Object(Ptr(PyTuple_New(2))) + { + set_item(0, Ptr(to_python(x.first))); + set_item(1, Ptr(to_python(x.second))); + } - Tuple(const Ptr* start, const Ptr* finish); // not yet implemented. + template + Tuple(const First& first, const Second& second) + : Object(Ptr(PyTuple_New(2))) + { + set_item(0, Ptr(to_python(first))); + set_item(1, Ptr(to_python(second))); + } + + template + Tuple(const First& first, const Second& second, const Third& third) + : Object(Ptr(PyTuple_New(3))) + { + set_item(0, Ptr(to_python(first))); + set_item(1, Ptr(to_python(second))); + set_item(2, Ptr(to_python(third))); + } static PyTypeObject* type_object(); static bool accepts(Ptr p);