1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>boost/python/tuple.hpp</title> 5<link rel="stylesheet" href="../../boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../index.html" title="Boost.Python Reference Manual"> 8<link rel="up" href="../object_wrappers.html" title="Chapter 3. Object Wrappers"> 9<link rel="prev" href="boost_python_slice_hpp.html" title="boost/python/slice.hpp"> 10<link rel="next" href="../function_invocation_and_creation.html" title="Chapter 4. Function Invocation and Creation"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../../images/boost.png"></td></tr></table> 14<hr> 15<div class="spirit-nav"> 16<a accesskey="p" href="boost_python_slice_hpp.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../object_wrappers.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../function_invocation_and_creation.html"><img src="../../images/next.png" alt="Next"></a> 17</div> 18<div class="section"> 19<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 20<a name="object_wrappers.boost_python_tuple_hpp"></a><a class="link" href="boost_python_tuple_hpp.html" title="boost/python/tuple.hpp">boost/python/tuple.hpp</a> 21</h2></div></div></div> 22<div class="toc"><dl class="toc"> 23<dt><span class="section"><a href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.introduction">Introduction</a></span></dt> 24<dt><span class="section"><a href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.class_tuple">Class 25 <code class="computeroutput"><span class="identifier">tuple</span></code></a></span></dt> 26<dt><span class="section"><a href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.function_make_tuple">Function 27 <code class="computeroutput"><span class="identifier">make_tuple</span></code></a></span></dt> 28<dt><span class="section"><a href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.example">Example</a></span></dt> 29</dl></div> 30<div class="section"> 31<div class="titlepage"><div><div><h3 class="title"> 32<a name="object_wrappers.boost_python_tuple_hpp.introduction"></a><a class="link" href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.introduction" title="Introduction">Introduction</a> 33</h3></div></div></div> 34<p> 35 Exposes a <a class="link" href="../concepts/objectwrapper.html#concepts.objectwrapper.typewrapper_concept_requirements" title="TypeWrapper Concept Requirements">TypeWrapper</a> 36 for the Python <a href="http://www.python.org/doc/current/tut/node7.html#SECTION007300000000000000000%60tuple%60" target="_top">http://www.python.org/doc/current/tut/node7.html#SECTION007300000000000000000%60tuple%60</a> 37 type. 38 </p> 39</div> 40<div class="section"> 41<div class="titlepage"><div><div><h3 class="title"> 42<a name="object_wrappers.boost_python_tuple_hpp.class_tuple"></a><a class="link" href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.class_tuple" title="Class tuple">Class 43 <code class="computeroutput"><span class="identifier">tuple</span></code></a> 44</h3></div></div></div> 45<p> 46 Exposes the interface of Python's built-in tuple type. The semantics of 47 the constructors and member functions defined below can be fully understood 48 by reading the <a class="link" href="../concepts/objectwrapper.html#concepts.objectwrapper.typewrapper_concept_requirements" title="TypeWrapper Concept Requirements">TypeWrapper</a> 49 concept definition. Since tuple is publicly derived from <a class="link" href="boost_python_object_hpp.html#object_wrappers.boost_python_object_hpp.class_object" title="Class object"><code class="computeroutput"><span class="identifier">object</span></code></a>, the public <code class="computeroutput"><span class="identifier">object</span></code> interface applies to <code class="computeroutput"><span class="identifier">tuple</span></code> instances as well. 50 </p> 51<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span> 52<span class="special">{</span> 53 <span class="keyword">class</span> <span class="identifier">tuple</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">object</span> 54 <span class="special">{</span> 55 <span class="comment">// tuple() -> an empty tuple</span> 56 <span class="identifier">tuple</span><span class="special">();</span> 57 58 <span class="comment">// tuple(sequence) -> tuple initialized from sequence's items</span> 59 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> 60 <span class="keyword">explicit</span> <span class="identifier">tuple</span><span class="special">(</span><span class="identifier">T</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">sequence</span><span class="special">)</span> 61 <span class="special">};</span> 62<span class="special">}}</span> 63</pre> 64</div> 65<div class="section"> 66<div class="titlepage"><div><div><h3 class="title"> 67<a name="object_wrappers.boost_python_tuple_hpp.function_make_tuple"></a><a class="link" href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.function_make_tuple" title="Function make_tuple">Function 68 <code class="computeroutput"><span class="identifier">make_tuple</span></code></a> 69</h3></div></div></div> 70<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span> 71<span class="special">{</span> 72 <span class="identifier">tuple</span> <span class="identifier">make_tuple</span><span class="special">();</span> 73 74 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">></span> 75 <span class="identifier">tuple</span> <span class="identifier">make_tuple</span><span class="special">(</span><span class="identifier">A0</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a0</span><span class="special">);</span> 76 77 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">></span> 78 <span class="identifier">tuple</span> <span class="identifier">make_tuple</span><span class="special">(</span><span class="identifier">A0</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a1</span><span class="special">);</span> 79 <span class="special">...</span> 80 <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">A0</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,...</span><span class="keyword">class</span> <span class="identifier">An</span><span class="special">></span> 81 <span class="identifier">tuple</span> <span class="identifier">make_tuple</span><span class="special">(</span><span class="identifier">A0</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a0</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">a1</span><span class="special">,...</span><span class="identifier">An</span> <span class="keyword">const</span><span class="special">&</span> <span class="identifier">an</span><span class="special">);</span> 82<span class="special">}}</span> 83</pre> 84<div class="variablelist"> 85<p class="title"><b></b></p> 86<dl class="variablelist"> 87<dt><span class="term">Effect</span></dt> 88<dd><p> 89 Constructs a new tuple object composed of <code class="computeroutput"><span class="identifier">object</span><span class="special">(</span><span class="identifier">a0</span><span class="special">),</span> <span class="identifier">object</span><span class="special">(</span><span class="identifier">a0</span><span class="special">),...</span><span class="identifier">object</span><span class="special">(</span><span class="identifier">an</span><span class="special">)</span></code>. 90 </p></dd> 91</dl> 92</div> 93</div> 94<div class="section"> 95<div class="titlepage"><div><div><h3 class="title"> 96<a name="object_wrappers.boost_python_tuple_hpp.example"></a><a class="link" href="boost_python_tuple_hpp.html#object_wrappers.boost_python_tuple_hpp.example" title="Example">Example</a> 97</h3></div></div></div> 98<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span> 99<span class="identifier">tuple</span> <span class="identifier">head_and_tail</span><span class="special">(</span><span class="identifier">object</span> <span class="identifier">sequence</span><span class="special">)</span> 100<span class="special">{</span> 101 <span class="keyword">return</span> <span class="identifier">make_tuple</span><span class="special">(</span><span class="identifier">sequence</span><span class="special">[</span><span class="number">0</span><span class="special">],</span><span class="identifier">sequence</span><span class="special">[-</span><span class="number">1</span><span class="special">]);</span> 102<span class="special">}</span> 103</pre> 104</div> 105</div> 106<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 107<td align="left"></td> 108<td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2015 David Abrahams, Stefan Seefeld<p> 109 Distributed under the Boost Software License, Version 1.0. (See accompanying 110 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a> 111 </p> 112</div></td> 113</tr></table> 114<hr> 115<div class="spirit-nav"> 116<a accesskey="p" href="boost_python_slice_hpp.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../object_wrappers.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../function_invocation_and_creation.html"><img src="../../images/next.png" alt="Next"></a> 117</div> 118</body> 119</html> 120