From 3df5ef85bd00188d65b1d5b6624f110bf613c281 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 18 Oct 2000 04:28:05 +0000 Subject: [PATCH] Remove unimplemented Tuple constructors, and add some others for convenience. [SVN r7991] --- objects.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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);