<?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[allocator + list]]></title><description><![CDATA[<p>hallo, ich mal wieder ^^</p>
<p>wenn ich eine liste habe und einen allocator übergeben bekomme, muss ich den doch in etwa so rebinden, oder?!</p>
<pre><code class="language-cpp">template &lt; typename T, typename TAlloc = typename std::allocator&lt;T&gt; &gt;
struct list
{
  typedef typename TAlloc::rebind&lt;node&gt;::other allocator;
</code></pre>
<p>gibt es noch nen anderen (sinnvolleren) weg?<br />
darf ich das überhaupt so machen oder sollte ich eher</p>
<pre><code class="language-cpp">typedef typename TAlloc::rebind&lt; typename node&lt;TAlloc::value_type&gt; &gt;::other allocator;
</code></pre>
<p>machen?<br />
Gibt es überhaupt Anwendungsbereiche, wo man nen allocator auf nen anderen Typ braucht, als den Listen-Typ?<br />
also so was vll: <code>list&lt;char, allocator&lt;int&gt;&gt;</code><br />
oder wie auch immer</p>
<p>was würdet ihr machen?</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/244011/allocator-list</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 14:41:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/244011.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 Jun 2009 01:11:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to allocator + list on Wed, 24 Jun 2009 01:11:07 GMT]]></title><description><![CDATA[<p>hallo, ich mal wieder ^^</p>
<p>wenn ich eine liste habe und einen allocator übergeben bekomme, muss ich den doch in etwa so rebinden, oder?!</p>
<pre><code class="language-cpp">template &lt; typename T, typename TAlloc = typename std::allocator&lt;T&gt; &gt;
struct list
{
  typedef typename TAlloc::rebind&lt;node&gt;::other allocator;
</code></pre>
<p>gibt es noch nen anderen (sinnvolleren) weg?<br />
darf ich das überhaupt so machen oder sollte ich eher</p>
<pre><code class="language-cpp">typedef typename TAlloc::rebind&lt; typename node&lt;TAlloc::value_type&gt; &gt;::other allocator;
</code></pre>
<p>machen?<br />
Gibt es überhaupt Anwendungsbereiche, wo man nen allocator auf nen anderen Typ braucht, als den Listen-Typ?<br />
also so was vll: <code>list&lt;char, allocator&lt;int&gt;&gt;</code><br />
oder wie auch immer</p>
<p>was würdet ihr machen?</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1731891</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1731891</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Wed, 24 Jun 2009 01:11:07 GMT</pubDate></item><item><title><![CDATA[Reply to allocator + list on Wed, 24 Jun 2009 08:06:59 GMT]]></title><description><![CDATA[<blockquote>
<p>Gibt es überhaupt Anwendungsbereiche, wo man nen allocator auf nen anderen Typ braucht, als den Listen-Typ?</p>
</blockquote>
<p>Verstehe ich nicht. Dass du den für den &quot;Node&quot; Typ auch brauchst, hast du ja selbst schon geschrieben.<br />
Andere Container könnten auch mehr als nur einen &quot;Node&quot; Typ haben, die bräuchten dann auch mehr &quot;rebinds&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1731955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1731955</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 24 Jun 2009 08:06:59 GMT</pubDate></item><item><title><![CDATA[Reply to allocator + list on Wed, 24 Jun 2009 12:06:45 GMT]]></title><description><![CDATA[<p>Ich meinte, dass man absichtlich nen allocator von nem anderen Typen will, als den value_type - und zwar nicht intern sondern der aufrufer - es ging ja schließlich nur darum:</p>
<pre><code class="language-cpp">typedef typename TAlloc::rebind&lt;node&gt;::other allocator;
                             //typename node&lt;T&gt;
//vs
typedef typename TAlloc::rebind&lt; typename node&lt;TAlloc::value_type&gt; &gt;::other allocator;
</code></pre>
<p>Ich hab zwar die Aufgabe jetzt schon abgegeben und die erste lösung genommen, aber interessieren würd es mich dennoch, was man in der praxis da so macht (ich weiß, in der praxis nimmt man std::list - aber davon abgesehen) ^^</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1732083</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1732083</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Wed, 24 Jun 2009 12:06:45 GMT</pubDate></item></channel></rss>