<?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[Template Probleme]]></title><description><![CDATA[<p>Folgende Definition</p>
<pre><code class="language-cpp">template&lt;class T&gt; complex&lt;T&gt; 
inline mathext::Expi (const double wt)
{
	return complex&lt;T&gt;(cos(wt),sin(wt));
}
</code></pre>
<p>liefert mir bei diesem Code</p>
<pre><code class="language-cpp">double c1 = 1.0;
complex&lt;double&gt; test = Expi(c1);
</code></pre>
<p>den Fehler</p>
<blockquote>
<p>1&gt;.\src\DialogSimpleHologramm.cpp(60) : error C2784: &quot;std::complex&lt;_Other&gt; mathext::Expi(const std::complex&lt;_Other&gt; &amp;)&quot;: template-Argument für &quot;const std::complex&lt;_Other&gt; &amp;&quot; konnte nicht von &quot;double&quot; hergeleitet werden.<br />
1&gt; e:\Daten\Dev\SVN\hibiscus\Cpp\QBeamShaping\QBeamShaping\include\Common\mathext.h(70): Siehe Deklaration von 'mathext::Expi'<br />
1&gt;.\src\DialogSimpleHologramm.cpp(60) : error C2783: &quot;std::complex&lt;_Other&gt; mathext::Expi(const double)&quot;: template-Argument für &quot;T&quot; konnte nicht hergeleitet werden.<br />
1&gt; e:\Daten\Dev\SVN\hibiscus\Cpp\QBeamShaping\QBeamShaping\include\Common\mathext.h(69): Siehe Deklaration von 'mathext::Expi'</p>
</blockquote>
<p>was mache ich falsch ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/212129/template-probleme</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 15:55:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/212129.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 May 2008 08:42:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Template Probleme on Fri, 02 May 2008 08:42:29 GMT]]></title><description><![CDATA[<p>Folgende Definition</p>
<pre><code class="language-cpp">template&lt;class T&gt; complex&lt;T&gt; 
inline mathext::Expi (const double wt)
{
	return complex&lt;T&gt;(cos(wt),sin(wt));
}
</code></pre>
<p>liefert mir bei diesem Code</p>
<pre><code class="language-cpp">double c1 = 1.0;
complex&lt;double&gt; test = Expi(c1);
</code></pre>
<p>den Fehler</p>
<blockquote>
<p>1&gt;.\src\DialogSimpleHologramm.cpp(60) : error C2784: &quot;std::complex&lt;_Other&gt; mathext::Expi(const std::complex&lt;_Other&gt; &amp;)&quot;: template-Argument für &quot;const std::complex&lt;_Other&gt; &amp;&quot; konnte nicht von &quot;double&quot; hergeleitet werden.<br />
1&gt; e:\Daten\Dev\SVN\hibiscus\Cpp\QBeamShaping\QBeamShaping\include\Common\mathext.h(70): Siehe Deklaration von 'mathext::Expi'<br />
1&gt;.\src\DialogSimpleHologramm.cpp(60) : error C2783: &quot;std::complex&lt;_Other&gt; mathext::Expi(const double)&quot;: template-Argument für &quot;T&quot; konnte nicht hergeleitet werden.<br />
1&gt; e:\Daten\Dev\SVN\hibiscus\Cpp\QBeamShaping\QBeamShaping\include\Common\mathext.h(69): Siehe Deklaration von 'mathext::Expi'</p>
</blockquote>
<p>was mache ich falsch ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1501880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1501880</guid><dc:creator><![CDATA[pospiech]]></dc:creator><pubDate>Fri, 02 May 2008 08:42:29 GMT</pubDate></item><item><title><![CDATA[Reply to Template Probleme on Fri, 02 May 2008 08:48:10 GMT]]></title><description><![CDATA[<p>=&gt;</p>
<pre><code class="language-cpp">template&lt;class T&gt;
inline complex&lt;T&gt; mathext::Expi (const T wt)
{
    return complex&lt;T&gt;(cos(wt),sin(wt));
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1501883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1501883</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Fri, 02 May 2008 08:48:10 GMT</pubDate></item><item><title><![CDATA[Reply to Template Probleme on Fri, 02 May 2008 08:50:55 GMT]]></title><description><![CDATA[<p>Der Rückgabetyp von Expi ist complex&lt;T&gt; udn damit abhängig vom templateparameter. Auf der anderen Seite ist der parameter von Expi immer double und NICHT abhängig vom templateparameter. Daher gibts keine Möglichkeit, aus den Argumenten der Funktion den Templateparameter abzuleiten -&gt; du musst den Parameter explizit angeben.</p>
<p>Ich vermute mal ganz stark, dass wt eigentlich nicht immer ein double sein soll sondern ein T:</p>
<pre><code class="language-cpp">template&lt;class T&gt; inline
complex&lt;T&gt; mathext::Expi (const T wt)  //&lt;&lt;&lt; hier T statt double
{
    return complex&lt;T&gt;(cos(wt),sin(wt));
}
</code></pre>
<p>Dann klappts auch mit der template argument deduction <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1501884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1501884</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Fri, 02 May 2008 08:50:55 GMT</pubDate></item></channel></rss>