<?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[Ergebnis von boost::bind in boost::function verpacken und als Template-Argument als Callback uebergeben.]]></title><description><![CDATA[<p>Hi:<br />
Ich hab ein Problem mit boost::bind und boost::function, habs in etwa auf folgendes runterminimiert:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/bind.hpp&gt;
#include &lt;boost/function.hpp&gt;
using namespace std;
using namespace boost;

class Dummy
{
	public:
	void execute_me(int d)
	{
		cout &lt;&lt; &quot;hello: &quot; &lt;&lt; d &lt;&lt; '\n';
	}
};

template&lt;class Function&gt;
void run(Function f)
{
	f(42);
}

template&lt;class Function&gt;
void wrapper(Function f)
{
	boost::function&lt;void()&gt; g = bind(&amp;run&lt;Function&gt;, f);
	g();
}

int main()
{
	Dummy d;
	wrapper(bind(&amp;Dummy::execute_me, ref(d), _1));
	return 0;
}
</code></pre>
<p>Das ganze fuehrt beim GCC zu einer wahren Textwueste an Fehlermeldungen, kann mir wer sagen was falsch ist?</p>
<p>EDIT: Code hatte Fehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/257155/ergebnis-von-boost-bind-in-boost-function-verpacken-und-als-template-argument-als-callback-uebergeben</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 14:51:11 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/257155.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Dec 2009 20:26:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ergebnis von boost::bind in boost::function verpacken und als Template-Argument als Callback uebergeben. on Thu, 24 Dec 2009 00:08:34 GMT]]></title><description><![CDATA[<p>Hi:<br />
Ich hab ein Problem mit boost::bind und boost::function, habs in etwa auf folgendes runterminimiert:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;boost/bind.hpp&gt;
#include &lt;boost/function.hpp&gt;
using namespace std;
using namespace boost;

class Dummy
{
	public:
	void execute_me(int d)
	{
		cout &lt;&lt; &quot;hello: &quot; &lt;&lt; d &lt;&lt; '\n';
	}
};

template&lt;class Function&gt;
void run(Function f)
{
	f(42);
}

template&lt;class Function&gt;
void wrapper(Function f)
{
	boost::function&lt;void()&gt; g = bind(&amp;run&lt;Function&gt;, f);
	g();
}

int main()
{
	Dummy d;
	wrapper(bind(&amp;Dummy::execute_me, ref(d), _1));
	return 0;
}
</code></pre>
<p>Das ganze fuehrt beim GCC zu einer wahren Textwueste an Fehlermeldungen, kann mir wer sagen was falsch ist?</p>
<p>EDIT: Code hatte Fehler.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1827009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827009</guid><dc:creator><![CDATA[Blue-Tiger]]></dc:creator><pubDate>Thu, 24 Dec 2009 00:08:34 GMT</pubDate></item><item><title><![CDATA[Reply to Ergebnis von boost::bind in boost::function verpacken und als Template-Argument als Callback uebergeben. on Thu, 24 Dec 2009 18:59:43 GMT]]></title><description><![CDATA[<p>So, hab das Problem mittlerweile selbst geloest: Wenn das Ergebnis von boost::bind explizit in einer boost::function gespeichert wird, funktioniert das Ganze:</p>
<pre><code class="language-cpp">int main()
{
	Dummy d;
	function&lt;void(int)&gt; x = bind(&amp;Dummy::execute_me, ref(d), _1);
	wrapper(x);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1827439</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1827439</guid><dc:creator><![CDATA[Blue-Tiger]]></dc:creator><pubDate>Thu, 24 Dec 2009 18:59:43 GMT</pubDate></item></channel></rss>