<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Warum hat C++ keine Tuples?]]></title><description><![CDATA[<pre><code>a,b = foo(1)
</code></pre>
<p>Sowas wie in Python wäre doch cool.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/224064/warum-hat-c-keine-tuples</link><generator>RSS for Node</generator><lastBuildDate>Fri, 02 Oct 2026 20:51:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/224064.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Oct 2008 04:48:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warum hat C++ keine Tuples? on Sun, 05 Oct 2008 04:48:03 GMT]]></title><description><![CDATA[<pre><code>a,b = foo(1)
</code></pre>
<p>Sowas wie in Python wäre doch cool.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593568</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593568</guid><dc:creator><![CDATA[schreiben]]></dc:creator><pubDate>Sun, 05 Oct 2008 04:48:03 GMT</pubDate></item><item><title><![CDATA[Reply to Warum hat C++ keine Tuples? on Sun, 05 Oct 2008 06:00:40 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::pair&lt;T, U&gt; p = foo(1);

p.first // a
p.second // b
// oder
std::tr1::tuple&lt;T, U, V, W&gt; t = foo(1);

std::tr1::get&lt;0&gt;(t) // a
// ...
</code></pre>
<p>oder wenn man die Schreibweise anders haben will, kann man sich auch helfen.</p>
<pre><code class="language-cpp">template&lt;typename T, typename U&gt;
struct pair_binder_ {
  T &amp;a;
  U &amp;b;

  pair_binder_(T &amp;a, U &amp;b) : a(a), b(b) { }
  pair_binder_(pair_binder &amp;p) : a(p.a), b(p.b) { }

  pair_binder_ &amp;operator=(std::pair&lt;T, U&gt; &amp;p) {
    a = p.first;
    b = p.second;
    return *this;
  }
};

template&lt;typename T, typename U&gt;
pair_binder_&lt;T, U&gt; pair_bind(T &amp;a, U &amp;b) { return pair_binder(a, b); }

// ...
pair_bind(a, b) = foo(1);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1593572</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593572</guid><dc:creator><![CDATA[rüdiger]]></dc:creator><pubDate>Sun, 05 Oct 2008 06:00:40 GMT</pubDate></item><item><title><![CDATA[Reply to Warum hat C++ keine Tuples? on Sun, 05 Oct 2008 06:20:03 GMT]]></title><description><![CDATA[<p>Ist aber ganz schön umständlich. Und tuple != pair.</p>
<pre><code>a,b,c = foo2()
</code></pre>
<p>geht auch</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593573</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593573</guid><dc:creator><![CDATA[schreiben]]></dc:creator><pubDate>Sun, 05 Oct 2008 06:20:03 GMT</pubDate></item><item><title><![CDATA[Reply to Warum hat C++ keine Tuples? on Sun, 05 Oct 2008 07:00:35 GMT]]></title><description><![CDATA[<p>schreiben schrieb:</p>
<blockquote>
<p>Ist aber ganz schön umständlich. Und tuple != pair.</p>
<pre><code>a,b,c = foo2()
</code></pre>
<p>geht auch</p>
</blockquote>
<p>std::tr1::tuple</p>
<p>pair_bind finde ich jetzt nicht viel umständlicher (bzw. tuple bind als Erweiterung).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1593577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1593577</guid><dc:creator><![CDATA[rüdiger]]></dc:creator><pubDate>Sun, 05 Oct 2008 07:00:35 GMT</pubDate></item></channel></rss>