<?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[hilfs-template zur überladungsauflösung]]></title><description><![CDATA[<p>hi,</p>
<p>wieso funktioniert dieser code nicht?</p>
<pre><code>#include &lt;functional&gt;
#include &lt;cmath&gt;

template&lt;typename... T&gt;
struct pick
{
	template&lt;typename R, typename... U&gt;
	static auto from(R(*ptr)(T..., U...))
	{
		return ptr;
	}
};

int main()
{
	std::function&lt;double(double)&gt;{pick&lt;double&gt;::from(&amp;std::exp)};
}
</code></pre>
<p>exakte compiler-meldung hier:<br />
<a href="https://ideone.com/fiKBRc" rel="nofollow">https://ideone.com/fiKBRc</a></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/340060/hilfs-template-zur-überladungsauflösung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 13:44:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/340060.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Oct 2016 22:18:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to hilfs-template zur überladungsauflösung on Sun, 16 Oct 2016 22:18:33 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>wieso funktioniert dieser code nicht?</p>
<pre><code>#include &lt;functional&gt;
#include &lt;cmath&gt;

template&lt;typename... T&gt;
struct pick
{
	template&lt;typename R, typename... U&gt;
	static auto from(R(*ptr)(T..., U...))
	{
		return ptr;
	}
};

int main()
{
	std::function&lt;double(double)&gt;{pick&lt;double&gt;::from(&amp;std::exp)};
}
</code></pre>
<p>exakte compiler-meldung hier:<br />
<a href="https://ideone.com/fiKBRc" rel="nofollow">https://ideone.com/fiKBRc</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511792</guid><dc:creator><![CDATA[ulrich_mvp]]></dc:creator><pubDate>Sun, 16 Oct 2016 22:18:33 GMT</pubDate></item><item><title><![CDATA[Reply to hilfs-template zur überladungsauflösung on Sun, 16 Oct 2016 23:42:59 GMT]]></title><description><![CDATA[<p>Seit C++11 haben die Standard-math-Funktionen zusätzliche Überladungen (neben float,double,long double).</p>
<blockquote>
<p>For each set of overloaded functions within &lt;cmath&gt;, there shall be additional overloads sufficient to ensure:<br />
1. If any argument of arithmetic type corresponding to a double parameter has type long double, then<br />
all arguments of arithmetic type (3.9.1) corresponding to double parameters are effectively cast to<br />
long double.<br />
2. Otherwise, if any argument of arithmetic type corresponding to a double parameter has type double<br />
or an integer type, then all arguments of arithmetic type corresponding to double parameters are<br />
effectively cast to double.<br />
3. Otherwise, all arguments of arithmetic type corresponding to double parameters have type float.</p>
</blockquote>
<p>Der Standard sagt nicht, wie diese Funktionssignaturen exakt auszusehen haben, im Falle von GNUs stdlibc++ existiert eine Überladung der Form</p>
<pre><code class="language-cpp">template &lt;typename U&gt;
constexpr typename std::enable_if&lt;std::is_integral&lt;U&gt;{}, double&gt;::type exp(U);
</code></pre>
<p>für diesen Zweck.<br />
Das ist Problematisch, weil in dem gegebenen Kontext der endgültige Funktionstyp ja erst noch deduziert werden muss, U wiederum kann aber nur deduziert werden, wenn der Typ bereits bekannt ist (und nicht bloss ein Teil davon). Das ist daher leider auch kein Fall von SFINAE.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511795</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511795</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 16 Oct 2016 23:42:59 GMT</pubDate></item><item><title><![CDATA[Reply to hilfs-template zur überladungsauflösung on Mon, 17 Oct 2016 11:45:41 GMT]]></title><description><![CDATA[<p>Es fehlt leider ein Feature, dass es uns erlaubt, auflösbare Entitäten zu forwarden. Vielleicht kann man dazu ein Paper draften, aber in der Zwischenzeit</p>
<pre><code>#define wrapCallable(X) [] (auto&amp;&amp;... args) {return X(std::forward&lt;decltype(args)&gt;(args)...);}
</code></pre>
<p>Und dann einfach</p>
<pre><code>std::function&lt;double(double)&gt;{wrapCallable(std::exp)};
</code></pre>
<p>(ungetestet)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511829</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511829</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 17 Oct 2016 11:45:41 GMT</pubDate></item><item><title><![CDATA[Reply to hilfs-template zur überladungsauflösung on Mon, 17 Oct 2016 17:54:51 GMT]]></title><description><![CDATA[<p>ok, danke euch beiden. schade, dass das noch nicht möglich ist mit unserer version von c++.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511871</guid><dc:creator><![CDATA[ulrich_mvp]]></dc:creator><pubDate>Mon, 17 Oct 2016 17:54:51 GMT</pubDate></item></channel></rss>