<?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[Kleines template-Problem (Spezialisierung)]]></title><description><![CDATA[<p>Hallo,</p>
<p>folgender Code (vereinfacht, inclusive Tippfehler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> )</p>
<p>Header</p>
<pre><code class="language-cpp">template&lt;class Method&gt;
class Transformation
{
public:

  template &lt;class X&gt;
  X mapWorldToObject ( const X &amp; obj ) const;

};

// eine Klasse die für template&lt;class Method&gt; verwendet wird
template&lt;typename T&gt;
class ConstantCoeffTransformation;

// eine Klasse die für template&lt;class X&gt; verwendet wird
template&lt;typename T&gt;
class Sphere;
</code></pre>
<p>Wie spezialisiere ich jetzt in der Klasse Transformation die mapWorldToObject-Methode für</p>
<ul>
<li>Method = ConstantCoeffTransformation&lt;T&gt;</li>
<li>X = Sphere&lt;T&gt;</li>
</ul>
<p>in der Source-Datei.</p>
<p>Kann mir da jemand weiter helfen?</p>
<p>Vielen Dank, Thomas</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/299871/kleines-template-problem-spezialisierung</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 01:27:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/299871.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Feb 2012 10:35:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Kleines template-Problem (Spezialisierung) on Mon, 20 Feb 2012 10:35:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>folgender Code (vereinfacht, inclusive Tippfehler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> )</p>
<p>Header</p>
<pre><code class="language-cpp">template&lt;class Method&gt;
class Transformation
{
public:

  template &lt;class X&gt;
  X mapWorldToObject ( const X &amp; obj ) const;

};

// eine Klasse die für template&lt;class Method&gt; verwendet wird
template&lt;typename T&gt;
class ConstantCoeffTransformation;

// eine Klasse die für template&lt;class X&gt; verwendet wird
template&lt;typename T&gt;
class Sphere;
</code></pre>
<p>Wie spezialisiere ich jetzt in der Klasse Transformation die mapWorldToObject-Methode für</p>
<ul>
<li>Method = ConstantCoeffTransformation&lt;T&gt;</li>
<li>X = Sphere&lt;T&gt;</li>
</ul>
<p>in der Source-Datei.</p>
<p>Kann mir da jemand weiter helfen?</p>
<p>Vielen Dank, Thomas</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2183335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2183335</guid><dc:creator><![CDATA[Siassei]]></dc:creator><pubDate>Mon, 20 Feb 2012 10:35:53 GMT</pubDate></item><item><title><![CDATA[Reply to Kleines template-Problem (Spezialisierung) on Mon, 20 Feb 2012 10:39:38 GMT]]></title><description><![CDATA[<p>Achja, mein Versuch bis jetzt</p>
<pre><code class="language-cpp">template &lt; &gt;
template &lt; &gt;
template &lt;typename T&gt;
Sphere&lt;T&gt; Transformation&lt; ConstantCoeffTransformation&lt;T&gt; &gt;::mapWorldToObject&lt; Sphere&lt;T&gt; &gt; ( const Sphere&lt;T&gt; &amp; obj ) const
{

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2183337</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2183337</guid><dc:creator><![CDATA[Siassei]]></dc:creator><pubDate>Mon, 20 Feb 2012 10:39:38 GMT</pubDate></item><item><title><![CDATA[Reply to Kleines template-Problem (Spezialisierung) on Mon, 20 Feb 2012 11:10:59 GMT]]></title><description><![CDATA[<p>Hm... vielleicht ohne die explizite Spezialisierung mit Überladung?</p>
<pre><code class="language-cpp">template &lt;typename T&gt;
Sphere&lt;T&gt; Transformation&lt; ConstantCoeffTransformation&lt;T&gt; &gt;::mapWorldToObject( const Sphere&lt;T&gt; &amp; obj ) const
{

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2183360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2183360</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Mon, 20 Feb 2012 11:10:59 GMT</pubDate></item><item><title><![CDATA[Reply to Kleines template-Problem (Spezialisierung) on Mon, 20 Feb 2012 20:46:13 GMT]]></title><description><![CDATA[<p>Hallo Siassei,</p>
<p>das sind je im Grunde zwei Spezialisierungen. Eine der Klasse und eine der Methode. Und genauso kann man es auch lösen.</p>
<pre><code class="language-cpp">template&lt;class Method&gt;
class Transformation
{
public:

  template &lt;class X&gt;
  X mapWorldToObject ( const X &amp; obj ) const;

};

// eine Klasse die für template&lt;class Method&gt; verwendet wird
template&lt;typename T&gt;
class ConstantCoeffTransformation;

// eine Klasse die für template&lt;class X&gt; verwendet wird
template&lt;typename T&gt;
class Sphere;

// ---  Spezialisierung der Klasse mit ConstantCoeffTransformation&lt; T &gt;
template&lt; typename T &gt;
class Transformation&lt; ConstantCoeffTransformation&lt; T &gt; &gt;
{
public:
    template &lt;class X&gt;
    X mapWorldToObject ( const X &amp; obj ) const;

    // --   Spezialisierung der Methode mit Sphere&lt; T &gt;
    template&lt;&gt;
    Sphere&lt; T &gt; mapWorldToObject&lt; Sphere&lt; T &gt; &gt;( const Sphere&lt; T &gt; &amp; obj ) const
    {
        // &gt;&gt;&gt; hier Code reinschreiben &lt;&lt;&lt;
        return obj;
    }
};

template&lt;typename T&gt;
class ConstantCoeffTransformation
{
};
template&lt;typename T&gt;
class Sphere
{
};

int main()
{
    using namespace std;
    Transformation&lt; ConstantCoeffTransformation&lt; double &gt; &gt; t;
    Sphere&lt; double &gt; s;
    t.mapWorldToObject( s );

    double doof;
    t.mapWorldToObject( doof ); // compiliert, aber linkt nicht, 
                                //  da mapWorldToObject&lt; double &gt; nicht implementiert ist
    return 0;
}
</code></pre>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2183615</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2183615</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Mon, 20 Feb 2012 20:46:13 GMT</pubDate></item><item><title><![CDATA[Reply to Kleines template-Problem (Spezialisierung) on Tue, 21 Feb 2012 07:23:39 GMT]]></title><description><![CDATA[<p>Ich würds wie wxSkip machen. Funktionstemplates sollte man allgemein lieber überladen als spezialisieren. Mal davon abgesehen dass partielle Spezialisierungen für Funtkionstemplates (also in deinem Fall mapToWorldObject&lt;Sphere&lt;T&gt; &gt;) in nicht erlaubt sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2183736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2183736</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 21 Feb 2012 07:23:39 GMT</pubDate></item></channel></rss>