]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | [section boost/python/tuple.hpp] |
2 | [section Introduction] | |
3 | Exposes a [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] for the Python [@http://www.python.org/doc/current/tut/node7.html#SECTION007300000000000000000`tuple`] type. | |
4 | [endsect] | |
5 | [section Class `tuple`] | |
6 | Exposes the interface of Python's built-in tuple type. The semantics of the constructors and member functions defined below can be fully understood by reading the [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] concept definition. Since tuple is publicly derived from [link object_wrappers.boost_python_object_hpp.class_object `object`], the public `object` interface applies to `tuple` instances as well. | |
7 | `` | |
8 | namespace boost { namespace python | |
9 | { | |
10 | class tuple : public object | |
11 | { | |
12 | // tuple() -> an empty tuple | |
13 | tuple(); | |
14 | ||
15 | // tuple(sequence) -> tuple initialized from sequence's items | |
16 | template <class T> | |
17 | explicit tuple(T const& sequence) | |
18 | }; | |
19 | }} | |
20 | `` | |
21 | [endsect] | |
22 | [section Function `make_tuple`] | |
23 | `` | |
24 | namespace boost { namespace python | |
25 | { | |
26 | tuple make_tuple(); | |
27 | ||
28 | template <class A0> | |
29 | tuple make_tuple(A0 const& a0); | |
30 | ||
31 | template <class A0, class A1> | |
32 | tuple make_tuple(A0 const& a0, A1 const& a1); | |
33 | ... | |
34 | template <class A0, class A1,...class An> | |
35 | tuple make_tuple(A0 const& a0, A1 const& a1,...An const& an); | |
36 | }} | |
37 | `` | |
38 | [variablelist | |
39 | [[Effect][Constructs a new tuple object composed of `object(a0), | |
40 | object(a0),...object(an)`. ]] | |
41 | ] | |
42 | [endsect] | |
43 | [section Example] | |
44 | `` | |
45 | using namespace boost::python; | |
46 | tuple head_and_tail(object sequence) | |
47 | { | |
48 | return make_tuple(sequence[0],sequence[-1]); | |
49 | } | |
50 | `` | |
51 | [endsect] | |
52 | [endsect] |