<?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[C++0x decltype und Vererbung]]></title><description><![CDATA[<p>Hallo</p>
<p>Darf man in C++0x folgendes schreiben?</p>
<pre><code class="language-cpp">struct foo
{
  typedef decltype(*this) ThisType;
  void operator= (const ThisType&amp; OtherFoo)
  {
    std::memcpy(this, &amp;OtherFoo, sizeof ThisType);
  };
};
struct bar : foo
{  
};
</code></pre>
<p>Dannach hat <code>bar</code> einen Zuweisungsoperator.</p>
<p>MfG EOutOfResources</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/284198/c-0x-decltype-und-vererbung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 05:34:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/284198.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 27 Mar 2011 18:30:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++0x decltype und Vererbung on Sun, 27 Mar 2011 18:30:28 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Darf man in C++0x folgendes schreiben?</p>
<pre><code class="language-cpp">struct foo
{
  typedef decltype(*this) ThisType;
  void operator= (const ThisType&amp; OtherFoo)
  {
    std::memcpy(this, &amp;OtherFoo, sizeof ThisType);
  };
};
struct bar : foo
{  
};
</code></pre>
<p>Dannach hat <code>bar</code> einen Zuweisungsoperator.</p>
<p>MfG EOutOfResources</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2040971</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040971</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Sun, 27 Mar 2011 18:30:28 GMT</pubDate></item><item><title><![CDATA[Reply to C++0x decltype und Vererbung on Sun, 27 Mar 2011 18:34:01 GMT]]></title><description><![CDATA[<p>Nein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2040974</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040974</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Sun, 27 Mar 2011 18:34:01 GMT</pubDate></item><item><title><![CDATA[Reply to C++0x decltype und Vererbung on Sun, 27 Mar 2011 18:34:56 GMT]]></title><description><![CDATA[<p>audacia schrieb:</p>
<blockquote>
<p>Nein.</p>
</blockquote>
<p>Grund?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2040975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040975</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Sun, 27 Mar 2011 18:34:56 GMT</pubDate></item><item><title><![CDATA[Reply to C++0x decltype und Vererbung on Sun, 27 Mar 2011 18:36:00 GMT]]></title><description><![CDATA[<blockquote>
<p>decltype - In the C++ programming language, decltype is an operator for querying the type of an expression.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2040977</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2040977</guid><dc:creator><![CDATA[Zeus]]></dc:creator><pubDate>Sun, 27 Mar 2011 18:36:00 GMT</pubDate></item><item><title><![CDATA[Reply to C++0x decltype und Vererbung on Mon, 28 Mar 2011 12:41:47 GMT]]></title><description><![CDATA[<p>EOutOfResources schrieb:</p>
<blockquote>
<p>Darf man in C++0x folgendes schreiben?</p>
<pre><code class="language-cpp">struct foo
{
  typedef decltype(*this) ThisType;
  void operator= (const ThisType&amp; OtherFoo)
  {
    std::memcpy(this, &amp;OtherFoo, sizeof ThisType);
  };
};
struct bar : foo
{  
};
</code></pre>
<p>Dannach hat <code>bar</code> einen Zuweisungsoperator.</p>
</blockquote>
<p>Ich denke nicht, dass die Verwendung von this in diesem Kontext erlaubt ist. Ich glaube, this darf nur innerhalb der Definition einer nicht-statischen Elementfunktion auftauchen.</p>
<p>Das, was Du mit Deinem Code erreichen willst, ist mir nicht klar. Der Zuweisungsoperator ist sowieso etwas besonderes. Der Compiler deklariert das Ding ganz automatisch in bar, unabhängig davon, was ThisType bei Dir ist. Diese vom Compiler erzeugte Deklaration von bar::operator=(bar const); &quot;versteckt&quot; den bzw die Operatore(n) foo::operator= aus der Basisklasse.</p>
<p>Übrigens wäre decltype(*this) bei</p>
<pre><code class="language-cpp">struct foo {
  void blah1() {}
  void blah2() const {}
};
</code></pre>
<p>innerhalb von blah1 der Typ <code>foo&amp;</code> und innerhalb von blah2 der Typ <code>foo const&amp;</code></p>
<p>Eventuell ist CRTP noch etwas für Dich (curiously recurring template pattern).</p>
<p>kk</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2041266</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2041266</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Mon, 28 Mar 2011 12:41:47 GMT</pubDate></item></channel></rss>