<?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::bind]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>kann mir eventuell jemand erklären, warum die dritte Variante in meinem Beispiel nicht kompiliert (C2825), wobei die boost::bind-Doku sagt, dass dort implizit men_fn verwendet werden sollte?</p>
<pre><code class="language-cpp">eventStartMove.connect( boost::function&lt;void()&gt;( &amp;NodeWidget::OnFrameStartMove, this ) );
eventMove     .connect( boost::bind( boost::mem_fn(&amp;NodeWidget::OnFrameMove), this, _1 ) );
eventStopMove .connect( boost::bind( &amp;NodeWidget::OnFrameStopMove, this, _1 ) );
</code></pre>
<p>Danke für alle Tipps!</p>
<p>Michael</p>
<p>PS: Naja, nun habe ich das _1 einfach mal weggelassen und es kompiliert wunderbar! Vielleicht habe ich das noch nicht so ganz durchstiegen, ich dachte der erste Parameter von ner mem_fn wäre halt der &quot;this&quot;-Zeiger.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/290914/boost-bind</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 00:21:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/290914.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 06 Aug 2011 14:20:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to boost::bind on Sat, 06 Aug 2011 14:35:56 GMT]]></title><description><![CDATA[<p>Hallo Leute,</p>
<p>kann mir eventuell jemand erklären, warum die dritte Variante in meinem Beispiel nicht kompiliert (C2825), wobei die boost::bind-Doku sagt, dass dort implizit men_fn verwendet werden sollte?</p>
<pre><code class="language-cpp">eventStartMove.connect( boost::function&lt;void()&gt;( &amp;NodeWidget::OnFrameStartMove, this ) );
eventMove     .connect( boost::bind( boost::mem_fn(&amp;NodeWidget::OnFrameMove), this, _1 ) );
eventStopMove .connect( boost::bind( &amp;NodeWidget::OnFrameStopMove, this, _1 ) );
</code></pre>
<p>Danke für alle Tipps!</p>
<p>Michael</p>
<p>PS: Naja, nun habe ich das _1 einfach mal weggelassen und es kompiliert wunderbar! Vielleicht habe ich das noch nicht so ganz durchstiegen, ich dachte der erste Parameter von ner mem_fn wäre halt der &quot;this&quot;-Zeiger.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2102656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2102656</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 06 Aug 2011 14:35:56 GMT</pubDate></item><item><title><![CDATA[Reply to boost::bind on Sun, 07 Aug 2011 10:11:45 GMT]]></title><description><![CDATA[<p>Fändest du nicht, dass wir den Codekontext kennen dürften? Und auch C2825 wissen wohl die wenigsten von uns auswendig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Aber ich nehme mal an, <code>NodeWidget::OnFrameStopMove()</code> nimmt keine Parameter. Dann musst du nur das <code>this</code> -Objekt als 2. Argument an <code>boost::bind()</code> übergeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2102874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2102874</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 07 Aug 2011 10:11:45 GMT</pubDate></item><item><title><![CDATA[Reply to boost::bind on Sun, 07 Aug 2011 10:54:24 GMT]]></title><description><![CDATA[<p>_1 ist ein Platzhalter für den ersten Parameter des Funktionsobjektes, das boost::bind zurückgibt. Mit</p>
<pre><code class="language-cpp">boost::bind( &amp;NodeWidget::OnFrameStopMove, this, _1 )
</code></pre>
<p>versuchst du, this an den ersten Parameter von NodeWidget::OnFrameStopMove (den this-Zeiger) zu ketten und den ersten Parameter des Funktionsobjektes, das du durch den Aufruf erhältst, an OnFrameStopMoves zweiten Parameter. Wenn OnFrameStopMove keinen zweiten Parameter hat, geht das schief.</p>
<p>Einfaches Anschauungsbeispiel:</p>
<pre><code class="language-cpp">#include &lt;boost/bind.hpp&gt;
#include &lt;iostream&gt;

void foo(int x, int y) {
  std::cout &lt;&lt; x &lt;&lt; &quot;, &quot; &lt;&lt; y &lt;&lt; std::endl;
}

int main() {
  boost::bind(foo, 2, _1)(3);     // Ausgabe: 2, 3
  boost::bind(foo, _1, _1)(3);    // Ausgabe: 3, 3
  boost::bind(foo, _2, _1)(2, 3); // Ausgabe: 3, 2
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2102895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2102895</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Sun, 07 Aug 2011 10:54:24 GMT</pubDate></item><item><title><![CDATA[Reply to boost::bind on Sun, 07 Aug 2011 14:54:39 GMT]]></title><description><![CDATA[<p>Wie funktioniert das mit den _1 und _2 usw.? Sind das Makros?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2102997</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2102997</guid><dc:creator><![CDATA[*Q* 1]]></dc:creator><pubDate>Sun, 07 Aug 2011 14:54:39 GMT</pubDate></item><item><title><![CDATA[Reply to boost::bind on Sun, 07 Aug 2011 16:17:20 GMT]]></title><description><![CDATA[<p>Q schrieb:</p>
<blockquote>
<p>Wie funktioniert das mit den _1 und _2 usw.? Sind das Makros?</p>
</blockquote>
<p>Nein, das sind std::placeholder's</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103034</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103034</guid><dc:creator><![CDATA[314159265358979]]></dc:creator><pubDate>Sun, 07 Aug 2011 16:17:20 GMT</pubDate></item><item><title><![CDATA[Reply to boost::bind on Mon, 08 Aug 2011 03:02:49 GMT]]></title><description><![CDATA[<p>Q schrieb:</p>
<blockquote>
<p>Wie funktioniert das mit den _1 und _2 usw.? Sind das Makros?</p>
</blockquote>
<p>Das sind Objekte spezieller Typen, die mit viel TMP-Magie innerhalb von <code>bind</code> gesonderd gehandhabt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2103206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2103206</guid><dc:creator><![CDATA[ipsec]]></dc:creator><pubDate>Mon, 08 Aug 2011 03:02:49 GMT</pubDate></item></channel></rss>