2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 17:52:17 +00:00

Added make_tuple

[SVN r15052]
This commit is contained in:
Dave Abrahams
2002-08-22 13:20:58 +00:00
parent 68c8901c2a
commit e1099e9370
3 changed files with 48 additions and 49 deletions

View File

@@ -0,0 +1,31 @@
# // Copyright David Abrahams 2002. Permission to copy, use,
# // modify, sell and distribute this software is granted provided this
# // copyright notice appears in all copies. This software is provided
# // "as is" without express or implied warranty, and with no claim as
# // to its suitability for any purpose.
#if !defined(BOOST_PP_IS_ITERATING)
# error Boost.Python - do not include this file!
#endif
#define N BOOST_PP_ITERATION()
#define BOOST_PYTHON_MAKE_TUPLE_ARG(N, ignored) \
PyTuple_SET_ITEM( \
result.ptr() \
, N \
, python::incref(python::object(a##N).ptr()) \
);
template <BOOST_PYTHON_UNARY_ENUM(N, class A)>
tuple
make_tuple(BOOST_PYTHON_BINARY_ENUM(N, A, const& a))
{
tuple result((detail::new_reference)::PyTuple_New(N));
BOOST_PP_REPEAT(N, BOOST_PYTHON_MAKE_TUPLE_ARG, _)
return result;
}
#undef BOOST_PYTHON_MAKE_TUPLE_ARG
#undef N

View File

@@ -28,6 +28,11 @@ class tuple : public object
static BOOST_PYTHON_DECL detail::new_reference call(object const&);
};
// for completeness
inline tuple make_tuple() { return tuple(); }
# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/make_tuple.hpp>))
# include BOOST_PP_ITERATE()
//
// Converter Specializations