<?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&amp;lt;&amp;quot;uncopyable&amp;quot;&amp;gt;::construct]]></title><description><![CDATA[<p>Mahlzeit zusammen...<br />
Folgendes stark vereinfachtes Modell:</p>
<pre><code class="language-cpp">#include &lt;memory&gt;

template&lt;template &lt;typename&gt; class Allocator = std::allocator&gt;
class Node
{
public:
    typedef Allocator&lt;Node&gt; Alloc;

    static Node* Create()
    {
        Node* n = alloc_.allocate(1);
        alloc_.construct(n, Node());
        return n;
    }

    static void Delete(Node* n)
    {
        alloc_.destroy(n);
        alloc_.deallocate(n, 1);
    }

private:
    friend class Alloc;  // access to move ctor
    Node(){}
    Node(Node&amp;);
    Node(Node&amp;&amp; other)
    {
        // steal from other...
    }
    static Alloc alloc_;
};
template&lt;template &lt;typename&gt; class Allocator&gt;
typename Node&lt;Allocator&gt;::Alloc Node&lt;Allocator&gt;::alloc_;

int main()
{
    Node&lt;&gt;* n = Node&lt;&gt;::Create();
    Node&lt;&gt;::Delete(n);
    return 0;
}
</code></pre>
<p>msvc akzepiert diesen nicht standardkonformen Code. Erst als ich im gcc kompilierte, hab ich dann bemerkt, dass ja Templateparameter nicht als friend deklariert werden können. Hat irgendwer eine andere Idee als den Move ctor public zumachen (der von allocator::construct benötigt wird)?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/276053/allocator-lt-quot-uncopyable-quot-gt-construct</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 14:44:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/276053.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Oct 2010 09:56:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to allocator&amp;lt;&amp;quot;uncopyable&amp;quot;&amp;gt;::construct on Tue, 26 Oct 2010 09:56:12 GMT]]></title><description><![CDATA[<p>Mahlzeit zusammen...<br />
Folgendes stark vereinfachtes Modell:</p>
<pre><code class="language-cpp">#include &lt;memory&gt;

template&lt;template &lt;typename&gt; class Allocator = std::allocator&gt;
class Node
{
public:
    typedef Allocator&lt;Node&gt; Alloc;

    static Node* Create()
    {
        Node* n = alloc_.allocate(1);
        alloc_.construct(n, Node());
        return n;
    }

    static void Delete(Node* n)
    {
        alloc_.destroy(n);
        alloc_.deallocate(n, 1);
    }

private:
    friend class Alloc;  // access to move ctor
    Node(){}
    Node(Node&amp;);
    Node(Node&amp;&amp; other)
    {
        // steal from other...
    }
    static Alloc alloc_;
};
template&lt;template &lt;typename&gt; class Allocator&gt;
typename Node&lt;Allocator&gt;::Alloc Node&lt;Allocator&gt;::alloc_;

int main()
{
    Node&lt;&gt;* n = Node&lt;&gt;::Create();
    Node&lt;&gt;::Delete(n);
    return 0;
}
</code></pre>
<p>msvc akzepiert diesen nicht standardkonformen Code. Erst als ich im gcc kompilierte, hab ich dann bemerkt, dass ja Templateparameter nicht als friend deklariert werden können. Hat irgendwer eine andere Idee als den Move ctor public zumachen (der von allocator::construct benötigt wird)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1970773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970773</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Tue, 26 Oct 2010 09:56:12 GMT</pubDate></item><item><title><![CDATA[Reply to allocator&amp;lt;&amp;quot;uncopyable&amp;quot;&amp;gt;::construct on Tue, 26 Oct 2010 10:23:53 GMT]]></title><description><![CDATA[<p>Kommt hier der <em>using</em> Trick zum tragen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1970794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970794</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Tue, 26 Oct 2010 10:23:53 GMT</pubDate></item><item><title><![CDATA[Reply to allocator&amp;lt;&amp;quot;uncopyable&amp;quot;&amp;gt;::construct on Tue, 26 Oct 2010 14:01:40 GMT]]></title><description><![CDATA[<p>theta schrieb:</p>
<blockquote>
<p>Kommt hier der <em>using</em> Trick zum tragen?</p>
</blockquote>
<p>Hm? Versteh ich nicht. Erklär mal was du meinst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1970881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1970881</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Tue, 26 Oct 2010 14:01:40 GMT</pubDate></item></channel></rss>