<?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[boost::function und funktionszeiger]]></title><description><![CDATA[<p>hallo,</p>
<p>hier gleich zu meinem problem</p>
<pre><code class="language-cpp">#include &lt;boost/bind.hpp&gt;
#include &lt;boost/function.hpp&gt;

// zu integrierende Funktion f_i(x,y,z), z.B.:
float xyzfunc (float x, float y, float z, int i) {
	return i+x*y*z;}

// Funktion zur Integration von f_i(x,y,z) über 0-x2, 0-y2, 0-z2
float intfunc (float (*func)(float,float,float),float x2,float y2, float z2) {
	return 0.5*(func(0,0,0)+func(x2,y2,z2));}

void main() 
{
	float x2=5, y2=3, z2=7, res[10];

	boost::function&lt;float (float, float, float)&gt; f;

	// nun möchte ich z.B. die funktion f_i(x,y,z) mit 
	// verschiedenen parametern i integrieren.
	// dazu möchte ich diese mit bind festlegen und der funktion
	// zum integrieren dann eine funktion von x,y,z übergeben
	for (int i=0; i&lt;10; i++){
		f=boost::bind(xyzfunc,_1,_2,_3,i);
		res=intfunc(f,x2,y2,z2);						// &lt;- und hier ist das problem
		std::cout &lt;&lt; res &lt;&lt; std::endl;			
	}
	std::cin.get();
}
</code></pre>
<blockquote>
<p>1&gt;c:\projektarbeit\boost-test\main.cpp(19) : error C2664: 'intfunc': Konvertierung des Parameters 1 von 'boost::function&lt;Signature&gt;' in 'float (__cdecl *)(float,float,float)' nicht möglich<br />
1&gt; with<br />
1&gt; [<br />
1&gt; Signature=float (float,float,float)<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden</p>
</blockquote>
<p>krieg ich mit function bzw. bind nun funktionzeiger oder funktionsobjekte? oder wie könnte ich das ganze so abändern, dass es funtkioniert?</p>
<p>gruß christian</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/183750/boost-function-und-funktionszeiger</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 10:28:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/183750.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 Jun 2007 13:12:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to boost::function und funktionszeiger on Fri, 08 Jun 2007 13:12:18 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>hier gleich zu meinem problem</p>
<pre><code class="language-cpp">#include &lt;boost/bind.hpp&gt;
#include &lt;boost/function.hpp&gt;

// zu integrierende Funktion f_i(x,y,z), z.B.:
float xyzfunc (float x, float y, float z, int i) {
	return i+x*y*z;}

// Funktion zur Integration von f_i(x,y,z) über 0-x2, 0-y2, 0-z2
float intfunc (float (*func)(float,float,float),float x2,float y2, float z2) {
	return 0.5*(func(0,0,0)+func(x2,y2,z2));}

void main() 
{
	float x2=5, y2=3, z2=7, res[10];

	boost::function&lt;float (float, float, float)&gt; f;

	// nun möchte ich z.B. die funktion f_i(x,y,z) mit 
	// verschiedenen parametern i integrieren.
	// dazu möchte ich diese mit bind festlegen und der funktion
	// zum integrieren dann eine funktion von x,y,z übergeben
	for (int i=0; i&lt;10; i++){
		f=boost::bind(xyzfunc,_1,_2,_3,i);
		res=intfunc(f,x2,y2,z2);						// &lt;- und hier ist das problem
		std::cout &lt;&lt; res &lt;&lt; std::endl;			
	}
	std::cin.get();
}
</code></pre>
<blockquote>
<p>1&gt;c:\projektarbeit\boost-test\main.cpp(19) : error C2664: 'intfunc': Konvertierung des Parameters 1 von 'boost::function&lt;Signature&gt;' in 'float (__cdecl *)(float,float,float)' nicht möglich<br />
1&gt; with<br />
1&gt; [<br />
1&gt; Signature=float (float,float,float)<br />
1&gt; ]<br />
1&gt; Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden</p>
</blockquote>
<p>krieg ich mit function bzw. bind nun funktionzeiger oder funktionsobjekte? oder wie könnte ich das ganze so abändern, dass es funtkioniert?</p>
<p>gruß christian</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1301339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1301339</guid><dc:creator><![CDATA[djang0]]></dc:creator><pubDate>Fri, 08 Jun 2007 13:12:18 GMT</pubDate></item><item><title><![CDATA[Reply to boost::function und funktionszeiger on Fri, 08 Jun 2007 14:09:14 GMT]]></title><description><![CDATA[<p>ok, hat sich anscheinend erledigt. mit</p>
<pre><code class="language-cpp">// Funktion zur Integration von f_i(x,y,z) über 0-x2, 0-y2, 0-z2
float intfunc (boost::function&lt;float(float,float,float)&gt; func,float x2,float y2, float z2) {
    return 0.5*(func(0,0,0)+func(x2,y2,z2));}
</code></pre>
<p>läufts erstmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1301367</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1301367</guid><dc:creator><![CDATA[djang0]]></dc:creator><pubDate>Fri, 08 Jun 2007 14:09:14 GMT</pubDate></item><item><title><![CDATA[Reply to boost::function und funktionszeiger on Sat, 09 Jun 2007 04:45:44 GMT]]></title><description><![CDATA[<p>djang0 schrieb:</p>
<blockquote>
<p>ok, hat sich anscheinend erledigt. mit</p>
<pre><code class="language-cpp">// Funktion zur Integration von f_i(x,y,z) über 0-x2, 0-y2, 0-z2
float intfunc (boost::function&lt;float(float,float,float)&gt; func,float x2,float y2, float z2) {
    return 0.5*(func(0,0,0)+func(x2,y2,z2));}
</code></pre>
<p>läufts erstmal.</p>
</blockquote>
<p>is ja auch die richtige Lösung <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>
<p>der functor ist nunmal ein polymorphes objekt das sich wie eine Funktion verhält, und keine Funktion.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1301755</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1301755</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Sat, 09 Jun 2007 04:45:44 GMT</pubDate></item></channel></rss>