<?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[Extraktion des Rückgabetypes]]></title><description><![CDATA[<p>Gegeben ist eine mehrfach übeladene Funktion und ein Typ T. Es soll nun der Rückgabetyp der Funktion bestimmt werden, wenn ein T übergeben wird. In C++11 ist das trivial dank decltype. Gibt es jedoch in C++03 einen Trick das zu bewerkstelligen?</p>
<p>Das Ganze kann man sich in etwa so vorstellen:</p>
<pre><code>int f(char);
float f(bool);
...

template&lt;class T&gt;
struct s
{
  typedef return_val&lt;f(T())&gt;::type type;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/326666/extraktion-des-rückgabetypes</link><generator>RSS for Node</generator><lastBuildDate>Mon, 25 May 2026 20:17:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/326666.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 30 Jun 2014 08:50:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Extraktion des Rückgabetypes on Mon, 30 Jun 2014 08:50:31 GMT]]></title><description><![CDATA[<p>Gegeben ist eine mehrfach übeladene Funktion und ein Typ T. Es soll nun der Rückgabetyp der Funktion bestimmt werden, wenn ein T übergeben wird. In C++11 ist das trivial dank decltype. Gibt es jedoch in C++03 einen Trick das zu bewerkstelligen?</p>
<p>Das Ganze kann man sich in etwa so vorstellen:</p>
<pre><code>int f(char);
float f(bool);
...

template&lt;class T&gt;
struct s
{
  typedef return_val&lt;f(T())&gt;::type type;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2406282</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2406282</guid><dc:creator><![CDATA[Naturextrakte]]></dc:creator><pubDate>Mon, 30 Jun 2014 08:50:31 GMT</pubDate></item><item><title><![CDATA[Reply to Extraktion des Rückgabetypes on Mon, 30 Jun 2014 08:53:40 GMT]]></title><description><![CDATA[<p><code>boost::result_of</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2406283</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2406283</guid><dc:creator><![CDATA[hetrazd]]></dc:creator><pubDate>Mon, 30 Jun 2014 08:53:40 GMT</pubDate></item><item><title><![CDATA[Reply to Extraktion des Rückgabetypes on Mon, 30 Jun 2014 10:02:17 GMT]]></title><description><![CDATA[<blockquote>
<p>Gibt es jedoch in C++03 einen Trick das zu bewerkstelligen?</p>
</blockquote>
<p>Naja, mittels Boost schon, wenns dich nicht stört:</p>
<pre><code>#include &lt;boost/typeof/typeof.hpp&gt;
#include &lt;boost/utility/declval.hpp&gt;
#include &lt;boost/static_assert.hpp&gt;
 #include &lt;boost/type_traits/is_same.hpp&gt;

int f(char);
float f(bool);

template&lt;class T&gt;
struct s
{
	typedef BOOST_TYPEOF(f(boost::declval&lt;T&gt;())) type;
};

int main()
{
	BOOST_STATIC_ASSERT(( boost::is_same&lt;s&lt;char&gt;::type, int&gt;::value ));
}
</code></pre>
<p>hetrazd schrieb:</p>
<blockquote>
<p><code>boost::result_of</code></p>
</blockquote>
<p>Das klappt doch gar nicht bei überladenen Funktionen in C++03? Ich meine, wie kommst du an den Typ der Funktion ran?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2406290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2406290</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 30 Jun 2014 10:02:17 GMT</pubDate></item></channel></rss>